Gadfly.jl icon indicating copy to clipboard operation
Gadfly.jl copied to clipboard

Error messages

Open jtrakk opened this issue 3 years ago • 7 comments

When Gadfly.plot() fails, it displays Plot(...) but that doesn't help me figure out what's wrong. It would be great if I could get some helpful diagnostic messages when the plotting fails.

jtrakk avatar Oct 12 '20 19:10 jtrakk

Try e.g. draw(PNG(), p) where p is a plot. In the Gadfly docs, see Backends.

Mattriks avatar Oct 12 '20 21:10 Mattriks

Thanks, that works.

p = plot(DataFrame(a=[1,2,3], b=[missing,20,30]), Geom.point(), x=:a, y=:b)

just gives Plot(...).

p = plot(DataFrame(a=[1,2,3], b=[missing,20,30]), Geom.point(), x=:a, y=:b)
draw(PNG(),p)

shows

MethodError: no method matching *(::Missing, ::Measures.Length{:mm,Float64})

In Jupyter,

plot(DataFrame(a=[1,2,3], b=[10,20,30]), Geom.point(), x=:a, y=:b)

successfully displays a scatterplot without explicitly specifying a backend, but when it fails (in the missing case), there's no error message, only Plot(...) unless I explicitly call draw(PNG(), p).

Would it be a good idea to give errors for failing plots in Jupyter without explicitly calling draw(PNG(), p)?

jtrakk avatar Oct 12 '20 21:10 jtrakk

What version of Gadfly do you have? ]st Gadfly Your example works for me on Gadfly 1.3.1

Mattriks avatar Oct 12 '20 21:10 Mattriks

1.3.0

jtrakk avatar Oct 12 '20 22:10 jtrakk

Yep general support for missing got added to Gadfly in #1459 (by updating Compose to v0.9). #1459 was merged between Gadfly v1.3 and v1.3.1. So you need to upgrade.

Mattriks avatar Oct 12 '20 22:10 Mattriks

That's good to know. It would still be nice for the error messages to appear without needing to specify a backend.

jtrakk avatar Oct 13 '20 04:10 jtrakk

It would still be nice for the error messages to appear without needing to specify a backend.

Agreed. Do we know why the error messages get hidden behind Plot(...) seems like a bug in the display code.

tlnagy avatar Oct 15 '20 16:10 tlnagy