pyplot画图遇到的问题


#1
        bif_x1_r = readdlm("x1_bif_fw.txt")
        bif_x1 = bif_x1_r[1:length(100.0:100.0:10000.0),:]
        speed = 100.0:100.0:10000.0
        figure(11,figsize=(8,6))
        plot(speed, bif_x1 .*100,"c.",markersize = 1.5)
        plot([5300,5300], [7.6,9.8],"r--")
        # plot([10000,10000], [7.6,9.8],"r--")
        xlim(0.0,10000.0)
        ylim(7.6,9.8)
        xticks(0:1000:10000)
        yticks(7.6:0.2:9.8)
        xlabel("rotating speed (rpm)")
        ylabel("x1 (μm)")
        text(6800.0,8.05,"quasi-peridic",fontsize = 15)
        annotate("", xy=(5300.0,8.0),xytext=(10000.0,8.0),
                arrowprops = Dict("arrowstyle" => "<->"))
        annotate("700", xy=(700.0,8.2),xytext=(700.0,7.9), rotation = 90, ha = "center",
                arrowprops = Dict("width"=>1.0,"headwidth"=>5.0,"shrink"=>0.1,"color"=>"r"))
        annotate("1000", xy=(1000.0,8.1),xytext=(1000.0,7.8), rotation = 90, ha = "center",
                arrowprops = Dict("width"=>1.0,"headwidth"=>5.0,"shrink"=>0.1,"color"=>"r"))
        savefig("bifurcation_x1_film.svg")
        annotate("5200", xy=(5200.0,8.9),xytext=(5200.0,8.6), rotation = 90, ha = "center",
                arrowprops = Dict("width"=>1.0,"headwidth"=>5.0,"shrink"=>0.1,"color"=>"r"))
        savefig("bifurcation_x1_film.svg")

代码错误出现在annotate(“5200”)这行,将xy,xytext的值随便改一下就没问题,5199,5201或其他都没问题,单单5200报错,想知道问题出在哪里,请教下各位高手,谢谢!

另外,论坛里面不能上传txt文件吗?
image


#2

确认一下这个数据点真的存在?

论坛贴附件确实不方便,可以考虑 pastebin 或者网盘。如果只是这个点有问题,你可以把册数数据集弄小一点,几个点就用改足够了。再把 bug 无关的语句删一删,弄个 mcve 就更好了

保存信息直接 copy 然后贴过来,截图有时候不完整,也不方便复制搜索。

看这一节报错感觉是在保存 svg 时出错的。


另外你这个是拿什么作图的?
我看

using Plots
pyplot()

后只有 annotate! 可以用,参数也有所不同。


#3

这个应该和数据点没关系,我只是在5200(图的区间是0:10000)点这个点注释而已
画图我用的是pyplot
图形、注释可以正常画出来,就是savefig时报错,但换个点注释就没问题

报错信息:
PyError ($(Expr(:escape, :(ccall(#= C:\Users\vtchen.julia\packages\PyCall\0jMpb\src\pyfncall.jl:44 =# @pysym(:PyObject_Call), PyPtr, (PyPtr, PyPtr, PyPtr), o, pyargsptr, kw))))) <class ‘ValueError’>
ValueError(‘Given lines do not intersect. Please verify that the angles are not equal or differ by 180 degrees.’)
File “D:\Anaconda3\lib\site-packages\matplotlib\pyplot.py”, line 689, in savefig
res = fig.savefig(*args, **kwargs)
File “D:\Anaconda3\lib\site-packages\matplotlib\figure.py”, line 2094, in savefig
self.canvas.print_figure(fname, **kwargs)
File “D:\Anaconda3\lib\site-packages\matplotlib\backend_bases.py”, line 2075, in print_figure
**kwargs)
File “D:\Anaconda3\lib\site-packages\matplotlib\backends\backend_svg.py”, line 1218, in print_svg
result = self._print_svg(filename, fh, **kwargs)
File “D:\Anaconda3\lib\site-packages\matplotlib\backends\backend_svg.py”, line 1243, in _print_svg
self.figure.draw(renderer)
File “D:\Anaconda3\lib\site-packages\matplotlib\artist.py”, line 50, in draw_wrapper
return draw(artist, renderer, *args, **kwargs)
File “D:\Anaconda3\lib\site-packages\matplotlib\figure.py”, line 1649, in draw
renderer, self, artists, self.suppressComposite)
File “D:\Anaconda3\lib\site-packages\matplotlib\image.py”, line 138, in _draw_list_compositing_images
a.draw(renderer)
File “D:\Anaconda3\lib\site-packages\matplotlib\artist.py”, line 50, in draw_wrapper
return draw(artist, renderer, *args, **kwargs)
File “D:\Anaconda3\lib\site-packages\matplotlib\axes_base.py”, line 2610, in draw
mimage._draw_list_compositing_images(renderer, self, artists)
File “D:\Anaconda3\lib\site-packages\matplotlib\image.py”, line 138, in _draw_list_compositing_images
a.draw(renderer)
File “D:\Anaconda3\lib\site-packages\matplotlib\artist.py”, line 50, in draw_wrapper
return draw(artist, renderer, *args, **kwargs)
File “D:\Anaconda3\lib\site-packages\matplotlib\text.py”, line 2389, in draw
self.arrow_patch.draw(renderer)
File “D:\Anaconda3\lib\site-packages\matplotlib\patches.py”, line 4301, in draw
path, fillable = self.get_path_in_displaycoord()
File “D:\Anaconda3\lib\site-packages\matplotlib\patches.py”, line 4250, in get_path_in_displaycoord
self.get_mutation_aspect())
File “D:\Anaconda3\lib\site-packages\matplotlib\patches.py”, line 3210, in call
return self.transmute(path, mutation_size, linewidth)
File “D:\Anaconda3\lib\site-packages\matplotlib\patches.py”, line 3710, in transmute
tail_width / 2.)
File “D:\Anaconda3\lib\site-packages\matplotlib\bezier.py”, line 381, in get_parallels
cos_t2, sin_t2)
File “D:\Anaconda3\lib\site-packages\matplotlib\bezier.py”, line 35, in get_intersection
raise ValueError("Given lines do not intersect. Please verify that "
in top-level scope at base\none
in savefig at PyPlot\fZuOQ\src\PyPlot.jl:176
in #savefig#97 at PyPlot\fZuOQ\src\PyPlot.jl:179
in pycall at PyCall\0jMpb\src\pyfncall.jl:86
in #pycall#88 at PyCall\0jMpb\src\pyfncall.jl:11
in _pycall! at PyCall\0jMpb\src\pyfncall.jl:22
in __pycall! at PyCall\0jMpb\src\pyfncall.jl:44
in macro expansion at PyCall\0jMpb\src\exception.jl:84
in pyerr_check at PyCall\0jMpb\src\exception.jl:64
in pyerr_check at PyCall\0jMpb\src\exception.jl:60