我对朱莉娅很新。我尝试过在Julia网站上发布的示例代码,该代码使用Gadfly来演示绘图。但是,它给了我以下错误。我相信所有依赖包都已安装 代码:
Pkg.add("Gadfly")
using Gadfly
draw(SVG("output.svg", 6inch, 3inch), plot([sin, cos], 0, 25))
我得到的错误是:
ERROR: PyError (:PyObject_Call) <type 'exceptions.ValueError'>
ValueError('third arg must be a format string',)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/pyplot.py", line 2987, in plot
ret = ax.plot(*args, **kwargs)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/axes.py", line 4137, in plot
for line in self._get_lines(*args, **kwargs):
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/axes.py", line 317, in _grab_next_args
for seg in self._plot_args(remaining, kwargs):
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/axes.py", line 279, in _plot_args
raise ValueError('third arg must be a format string')
[inlined code] from /Users/mango/.julia/v0.4/PyCall/src/exception.jl:81
in _pycall at /Users/mango/.julia/v0.4/PyCall/src/PyCall.jl:546
in pycall at /Users/mango/.julia/v0.4/PyCall/src/PyCall.jl:568
in plot at /Users/mango/.julia/v0.4/PyPlot/src/PyPlot.jl:395
此示例代码有什么问题?
答案 0 :(得分:3)
确实看来第二个评论是问题,但至少在julia版本0.4中,如果你希望你可以打开两个包,你只需要指定你正在使用哪一个。所以如果你使用了命令:
using PyPlot
using Gadfly
draw(SVG("output.svg", 6inch, 3inch), Gadfly.plot([sin, cos], 0, 25))
为我工作。这样您就可以指定使用Gadfly包而不是PyPlot包用于此特定绘图