0
votes

Simple example of using Google prices in DataFrame format. Gadfly plot gives the following error: TypeError(u'There is no Line2D property "y"',). Also references matplotlib for some reason.

Here's code:

using Quandl
using DataFrames

google = quandl("GOOG/NASDAQ_QQQ", format = "DataFrame")

date = google[1]

dt_str = Array(Any,length(date))
for i=1:length(date)
dt_str[i] = string(date[i]);
end

price = google[5]

using Gadfly

set_default_plot_size(20cm, 10cm)

p1 = plot(x=dt_str, y=price,
Geom.point, 
Geom.smooth(method=:lm),
Guide.xticks(ticks=[1:25]),
Guide.yticks(ticks=[1:25]),
Guide.xlabel("Date"), 
Guide.ylabel("Price"),
Guide.title("Google: Close Price"))

LoadError: PyError (:PyObject_Call) 
TypeError(u'There is no Line2D property "y"',)
  File "C:\Anaconda2\lib\site-packages\matplotlib\pyplot.py", line 3154, in plot
    ret = ax.plot(*args, **kwargs)
  File "C:\Anaconda2\lib\site-packages\matplotlib\__init__.py", line 1811, in inner
    return func(ax, *args, **kwargs)
  File "C:\Anaconda2\lib\site-packages\matplotlib\axes\_axes.py", line 1424, in plot
    for line in self._get_lines(*args, **kwargs):
  File "C:\Anaconda2\lib\site-packages\matplotlib\axes\_base.py", line 395, in _grab_next_args
    for seg in self._plot_args(remaining[:isplit], kwargs):
  File "C:\Anaconda2\lib\site-packages\matplotlib\axes\_base.py", line 374, in _plot_args
    seg = func(x[:, j % ncx], y[:, j % ncy], kw, kwargs)
  File "C:\Anaconda2\lib\site-packages\matplotlib\axes\_base.py", line 281, in _makeline
    self.set_lineprops(seg, **kwargs)
  File "C:\Anaconda2\lib\site-packages\matplotlib\axes\_base.py", line 189, in set_lineprops
    line.set(**kwargs)
  File "C:\Anaconda2\lib\site-packages\matplotlib\artist.py", line 936, in set
    (self.__class__.__name__, k))

while loading In[64], in expression starting on line 1

 in getindex at C:\Users\yburkitbayev\.julia\v0.4\PyCall\src\PyCall.jl:239
1

1 Answers

1
votes

The presence of the PyError would imply to me that the session in which this example was executed has loaded PyPlot prior to loading Gadfly. Both PyPlot and Gadfly export the plot function, so uses of plot in a session where both PyPlot and Gadfly have been loaded require the qualification of the function name with the package name (e.g. PyPlot.plot or Gadfly.plot).

Executing your example in a session where PyPlot has not been loaded, but Gadfly is loaded, produces a Gadfly plot without displaying the error message provided in your post.