JuliaPlots / Plots.jl

Powerful convenience for Julia visualizations and data analysis
https://docs.juliaplots.org
Other
1.83k stars 354 forks source link

Array comprehensions in labels work in GR but not in PlotlyJS #996

Open dpsanders opened 7 years ago

dpsanders commented 7 years ago
plot([x->sin(x+i) for i in 1:5], label=["Hello $i" for i in 1:5])

gives correct labels in GR but not in PlotlyJS. In PlotlyJS it is necessary to make the labels into a matrix:

plot([x->sin(x+i) for i in 1:5], label=reshape(["Hello $i" for i in 1:5], 1, 5))

This seems to be an actual bug. In any case, the distinction between when to use vectors versus matrices seems pretty confusing.

ChrisRackauckas commented 7 years ago

This is an unnatural consequence of the "columns are series" setup of Plots.jl. Each column of the labels matches a series. However, I think label should be special-cased so that Vector becomes the proper RowVector since the Vector case just isn't useful IMO.

dpsanders commented 7 years ago

Yes, agreed.

What I don't understand is why the behaviour is different for the two different backends.

mkborregaard commented 7 years ago

I think the distinction between vectors and matrices is clear - matrix columns are series (even if there's only one row), vector points are data points :-) @ChrisRackauckas I don't see anything wrong with automatically transposing label if the length corresponds to the number of series (other than it may cause confusion by overshadowing the columns-are-series fundamental Plots logic). @dpsanders no that's confusing - in fact the bug is currently in GR though. Any suggestions for making this clearer to users?