You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
All examples of heatmaps and contour plots should be modified if their z-array is of size (m,n), eventually with m=n, because
the plots do not display the right information I discovered a bug within heatmap1(), heatmap2(), and contour(s).
To illustrate it I take an example of heatmap, but not the one in the function heatmap1(), because there the z-array exhibits some symmetry.
First the plot of a heatmap with plotly.py
import plotly.graph_objects as go
fig= go.Figure(go.Heatmap(z=[[1, 24, 30], [28, 18, 40], [ 36, 54, 7]]))
fig.update_layout(width=400, height=400)
Therefore plotly.js interprets the Julia array columns as rows, and this leads to a wrong heatmap, contour or surface plot. end update
For both, heatmap and contour it is more obvious that the z-array must be transposed, when we are setting not only z, but also, x, and y of different lengths:
a, b = -1., 1.
c, d= 0., 1.
nx, ny= 200, 100
hx = (b-a)/(nx-1)
x = a:hx:b
hy = (d-c)/(ny-1)
y=c:hy:d
X = x' .* ones(length(y))
Y = ones(length(x))'.*y
Z= sin.(pi*pi*(X.*X+Y.*Y));
print(size(Z))
plot(contour(x=x, y=y, z=Z), Layout(width=650, height=350))
The corresponding plot:
has the xaxis range different from [-1,1], and yaxis range is not [0,1]. Running the same code with z=Z' we get the right contour plot:
PlotlyJS.jl version 0.13.1
The text was updated successfully, but these errors were encountered:
All examples of heatmaps and contour plots should be modified if their z-array is of size (m,n), eventually with m=n, because
the plots do not display the right information I discovered a bug within heatmap1(), heatmap2(), and contour(s).
To illustrate it I take an example of heatmap, but not the one in the function heatmap1(), because there the z-array exhibits some symmetry.
First the plot of a heatmap with plotly.py
Plot the same heatmap with PlotlyJS.jl:
The last image is not the right heatmap. But running with the transposed array:
we get the right one.
Update
Writing fig to json, from plotly.py:
fig.data.z
is listed as follows:while the same portion of json file created by
plotlyJS.jl
is different, because Julia has column major order:Therefore
plotly.js
interprets the Julia array columns as rows, and this leads to a wrong heatmap, contour or surface plot.end update
For both,
heatmap
andcontour
it is more obvious that the z-array must be transposed, when we are setting not only z, but also, x, and y of different lengths:The corresponding plot:
has the xaxis range different from [-1,1], and yaxis range is not [0,1]. Running the same code with z=Z' we get the right contour plot:
PlotlyJS.jl version 0.13.1
The text was updated successfully, but these errors were encountered: