juanklopper / JuliaCourseNotebooks

Jupyter notebooks for the Julia Scientific Programming course on Coursera
https://www.coursera.org/learn/julia-programming
230 stars 192 forks source link

Week2_4-SimplePlots.ipynb shows error in cell with multiline plot #1

Open gaballench opened 7 years ago

gaballench commented 7 years ago

in the function call:

plot(epidays, allcases,   # here are the data to be plotted, below are the attributes
title       = "West African EVD epidemic, total cases", 
xlabel    = "Days since 22 March 2014",
ylabel    = "Total cases to date (three countries)",
marker  = (:diamond, 8),  # note the use of  parentheses to group the marker attributes into a composite of attributes 
line         = (:path, :dot, :gray),   # line attributes likewise put together as one unit by the use of parantheses
legend   = false,
grid        = false)

The value :gray in argument line provides the following error in emacs:

Truncated Traceback (Use C-c C-x to view full TB):
 in eventloop(::ZMQ.Socket) at /home/balleng/.julia/v0.5/IJulia/src/eventloop.jl:8
 in (::IJulia.##9#15)() at ./task.jl:360

The only difference with a jupyter notebook opened in firefox is that such error includes the whole traceback (see below):

PyError (:PyObject_Call) <type 'exceptions.ValueError'>
ValueError(u'to_rgba: Invalid rgba arg "[(5.119113838889112e-07, 2.0522701956616554e-06, 5.982577941045683e-06, 1.0), (0.012635372261218893, 0.012335021633001353, 0.012360877171488911, 1.0), (0.044490079205597936, 0.0435012249064101, 0.04340640025397465, 1.0), (0.07713594055593873, 0.07588867046670467, 0.07566786755046528, 1.0), (0.11178889127514621, 0.11032073740675324, 0.10995609611040333, 1.0), (0.14512501670019584, 0.14348952603947387, 0.14297737699866214, 1.0), (0.17765450576970573, 0.17589297587514247, 0.17522919919060903, 1.0), (0.20969965735391027, 0.20784549559783222, 0.2070258098028131, 1.0), (0.23796048310857054, 0.2360475214306363, 0.2350855890963675, 1.0), (0.2696569270618427, 0.2677005000273448, 0.26657436399140455, 1.0), (0.30138082493046714, 0.2994018026306029, 0.29810697690547344, 1.0), (0.3332444459470546, 0.33126104503880144, 0.32979296721613593, 1.0), (0.3653442112181758, 0.3633724431782132, 0.3617264613451084, 1.0), (0.39414504258482247, 0.39219552930598844, 0.39038742177072233, 1.0), (0.4269187984448541, 0.42500621977889325, 0.4230111265300785, 1.0), (0.460158604360502, 0.4582941323523669, 0.45610706159309317, 1.0), (0.4939355476732588, 0.49212900530265485, 0.4897448180837611, 1.0), (0.5244666093614033, 0.5227187960704766, 0.5201549485201331, 1.0), (0.5594473424891353, 0.5577726697981703, 0.55500154023374, 1.0), (0.5951655745855984, 0.5935704457174206, 0.5905863774429682, 1.0), (0.6316921719290114, 0.6301818997985384, 0.626979021888779, 1.0), (0.6691001601199109, 0.6676789871782777, 0.6642511944588598, 1.0), (0.7031529592909377, 0.7018136865365993, 0.6981806378980351, 1.0), (0.7424359788373007, 0.7411909081795812, 0.7373206957932009, 1.0), (0.782830460120099, 0.7816807284649387, 0.7775664424093063, 1.0), (0.8244250973312831, 0.823370722798173, 0.8190051235631107, 1.0), (0.8673145804816755, 0.8663544202760625, 0.8617299082816555, 1.0), (0.9066075595860337, 0.9057292049450164, 0.9008678509007446, 1.0), (0.9522264455488126, 0.9514367761124457, 0.9463010502097274, 1.0), (0.9994561956101177, 0.9987503615523224, 0.9933314215482737, 1.0)]"\nlength of rgba sequence should be either 3 or 4',)
  File "/usr/lib/python2.7/dist-packages/matplotlib/artist.py", line 61, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/matplotlib/figure.py", line 1159, in draw
    func(*args)
  File "/usr/lib/python2.7/dist-packages/matplotlib/artist.py", line 61, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/matplotlib/axes/_base.py", line 2324, in draw
    a.draw(renderer)
  File "/usr/lib/python2.7/dist-packages/matplotlib/artist.py", line 61, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/matplotlib/lines.py", line 739, in draw
    ln_color_rgba = self._get_rgba_ln_color()
  File "/usr/lib/python2.7/dist-packages/matplotlib/lines.py", line 1251, in _get_rgba_ln_color
    return colorConverter.to_rgba(self._color, self._alpha)
  File "/usr/lib/python2.7/dist-packages/matplotlib/colors.py", line 376, in to_rgba
    'to_rgba: Invalid rgba arg "%s"\n%s' % (str(arg), exc))

 in pyerr_check at /home/balleng/.julia/v0.5/PyCall/src/exception.jl:56 [inlined]
 in pyerr_check at /home/balleng/.julia/v0.5/PyCall/src/exception.jl:61 [inlined]
 in macro expansion at /home/balleng/.julia/v0.5/PyCall/src/exception.jl:81 [inlined]
 in #_pycall#62(::Array{Any,1}, ::Function, ::PyCall.PyObject, ::PyCall.PyObject, ::Vararg{PyCall.PyObject,N}) at /home/balleng/.julia/v0.5/PyCall/src/PyCall.jl:546
 in _pycall(::PyCall.PyObject, ::PyCall.PyObject, ::Vararg{PyCall.PyObject,N}) at /home/balleng/.julia/v0.5/PyCall/src/PyCall.jl:534
 in #pycall#66(::Array{Any,1}, ::Function, ::PyCall.PyObject, ::Type{PyCall.PyAny}, ::PyCall.PyObject, ::Vararg{PyCall.PyObject,N}) at /home/balleng/.julia/v0.5/PyCall/src/PyCall.jl:568
 in pycall(::PyCall.PyObject, ::Type{PyCall.PyAny}, ::PyCall.PyObject, ::Vararg{PyCall.PyObject,N}) at /home/balleng/.julia/v0.5/PyCall/src/PyCall.jl:568
 in #call#67(::Array{Any,1}, ::PyCall.PyObject, ::PyCall.PyObject, ::Vararg{PyCall.PyObject,N}) at /home/balleng/.julia/v0.5/PyCall/src/PyCall.jl:571
 in (::PyCall.PyObject)(::PyCall.PyObject, ::Vararg{PyCall.PyObject,N}) at /home/balleng/.julia/v0.5/PyCall/src/PyCall.jl:571
 in _before_layout_calcs(::Plots.Plot{Plots.PyPlotBackend}) at /home/balleng/.julia/v0.5/Plots/src/backends/pyplot.jl:1072
 in prepare_output(::Plots.Plot{Plots.PyPlotBackend}) at /home/balleng/.julia/v0.5/Plots/src/plot.jl:248
 in show(::Base64EncodePipe, ::MIME{Symbol("image/png")}, ::Plots.Plot{Plots.PyPlotBackend}) at /home/balleng/.julia/v0.5/Plots/src/output.jl:170
 in base64encode(::Function, ::MIME{Symbol("image/png")}, ::Vararg{Any,N}) at ./base64.jl:160
 in show(::Base.AbstractIOBuffer{Array{UInt8,1}}, ::MIME{Symbol("text/html")}, ::Plots.Plot{Plots.PyPlotBackend}) at /home/balleng/.julia/v0.5/Plots/src/output.jl:148
 in show(::Base.AbstractIOBuffer{Array{UInt8,1}}, ::String, ::Plots.Plot{Plots.PyPlotBackend}) at ./multimedia.jl:33
 in #sprint#304(::Void, ::Function, ::Int64, ::Function, ::String, ::Vararg{Any,N}) at ./strings/io.jl:37
 in display_dict(::Plots.Plot{Plots.PyPlotBackend}) at /home/balleng/.julia/v0.5/Plots/src/output.jl:240
 in execute_request(::ZMQ.Socket, ::IJulia.Msg) at /home/balleng/.julia/v0.5/IJulia/src/execute_request.jl:200
 in eventloop(::ZMQ.Socket) at /home/balleng/.julia/v0.5/IJulia/src/eventloop.jl:8
 in (::IJulia.##9#15)() at ./task.jl:360

Given some of the information (I had no patience for going through the whole traceback by calls related to rbg colors pointed to something related to color) I tried changing the value associated to a color (:gray in the line argument) to the values :grey, :black, and even getting rid of such portion, and the error does not show up anymore in all three cases.

Don't understand if this is something related to julia 0.5.0, jupyter, or even emacs. The latter seems less viable since the error shows up both in emacs using ein (latest version installed from MELPA) and firefox.

I'm taking julia programming in coursera so I'm very interested in a possible explanation for this behavior.

Thanks in advance,

Gustavo

newton108 commented 7 years ago

Same here. I don't use emacs.