-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issues with traces types that accepts matrices as inputs #12
Comments
Some relevant issues I just found: |
Thanks for the issue and the links! An ugly workaround is I'd prefer that PlotlyLight didn't need to do special processing on its inputs, but that may be unavoidable. |
Yeah, it would be best if arrays were serialized like that directly in JSON3, but I think until then some pre-processing of inputs inside the package is the best way to provide a reliable experience with PlotlyLight I believe it should be |
Another option apart from what discussed in JuliaComputing/EasyConfig.jl#6 could be to have a processing function here before writing the Plot object to JSON like in PlotlyBase: https://github.com/sglyon/PlotlyBase.jl/blob/2a5c8b87679ced5af7ac3894950ef0ea845eaa61/src/json.jl#L6-L11 Though that is probably what you had in mind with the processor thing in JuliaComputing/EasyConfig.jl#6 |
I've added a utility function (looking at the examples in https://plotly.com/javascript/heatmaps/, it seems rows is correct): collectrows(x::AbstractMatrix) = collect.(eachrow(x)) and docs in the README as to why this is necessary. I think I'm ready to close this issue, as this is just an unfortunate consequence of JSON not having multidimensional arrays. If additional edge cases crop up, we can go the processing function route. |
Yeah |
Hello there, you could add the workaround for Greetz Max |
Funnily, for me collectcols(x::AbstractMatrix) = collect.(eachcol(x)) works for tables...but better doublecheck... |
Yeah, looks like it works out of the box as long as the table implements |
Some plotly trace types accepts input data in matrix format and the behavior of the trace changes whether the data is specified as a matrix or as a play 1D vector.
The issue comes from the serialization of JSON3 that by defaults serializes any ND-Array as its 1D content.
This can create issues that are different depending on the specific trace affected. I could identify the following problems in these traces, with some details in the examples below:
heatmap
surface
contour
Heatmap Example
The
heatmap
trace can accept thez
values as a matrix, in which case thex
andy
values can be provided as the vectors generating the underlying grid.If
z
is provided as a vector,x
andy
also has to be provided as 1D vectors containing the x/y values of each single point in z.This creates an issue when trying to provide
z
as matrix andx
,y
as generating vectors in PlolyLight:Surface Example
A different problem happens in
surface
still when trying to providex
andy
as generating vectors, where no Plot is produced with PlotlyLight:Contour Example
Finally, something very weird that I don't understand happens with
contour
. The plot is rendered but the resulting contour is not the correct one:The text was updated successfully, but these errors were encountered: