1

I am very new to Julia. I have tried a sample code posted in Julia site which uses Gadfly to demonstrate plotting. However, it gives me the below error. I believe that all the dependent packages were installed.
Code:

Pkg.add("Gadfly")
using Gadfly
draw(SVG("output.svg", 6inch, 3inch), plot([sin, cos], 0, 25))

Error I got is:

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

What is wrong with this sample code?

N Raghu
  • 706
  • 4
  • 13
  • 26
  • Maybe try (a) exiting and restarting Julia, (b) running `Pkg.update()`, (c) doing (b) then (a)? – Michael Ohlrogge Sep 13 '16 at 02:32
  • 2
    You appear to calling `plot` associated with PyPlot: try restarting and only loading Gadfly. – Simon Byrne Sep 13 '16 at 10:08
  • I advise you to check out [Plots.jl](https://juliaplots.github.io/) for backend agnostic plotting using the same consistent API across all the supported backends (Gadfly and PyPlot included). – HarmonicaMuse Sep 13 '16 at 18:41

1 Answers1

3

It indeed appears that the second comment is the issue, however at least in julia version 0.4 if you wish you can have both packages open, you just have to specify which one you are using. So if you have used the commands:

using PyPlot
using Gadfly
draw(SVG("output.svg", 6inch, 3inch), Gadfly.plot([sin, cos], 0, 25))

worked for me. This way you specify that you are using the Gadfly package rather than the PyPlot package for this specific plot

jfish003
  • 1,232
  • 8
  • 12