Hello,

Is it possible to generate contour plots where the X and Y values are specified in 2D arrays like those produced from meshgrid?

For example, this was done in Matplotlib:

Thanks

Hello,

Is it possible to generate contour plots where the X and Y values are specified in 2D arrays like those produced from meshgrid?

For example, this was done in Matplotlib:

Thanks

Yes, we can rotate a Plotly heatmap or contour plot, via a `scipy.ndimage`

transformation.

Here is an example: https://plot.ly/~empet/14044

Thanks very much empet. This is halfway towards what I’d like.

Sometimes I have contour data where the grid coordinates are not formed from an orthogonal basis. And so my grid might have an arbitrary orientation and additionally be skewed. This is easy to do in matplotlib since you can assign x and y to be 2D arrays using np.meshgrid() rather than 1D arrays/lists.

Is something like that possible?

Thanks

If you have a 2d data set, given in an array of shape (2,N), and apply a rotation or other transformation to all its points, then the array of transformed points, `tr_pts`

, with `x, y=tr_pts`

, will generate a `Histogram2dcontour`

that is included in the rectangle `[xmin, xmax] x [ymin, ymax],`

If we could collect the z values, that are displayed on hover over the plot of the Histogram2dcontour, then we would be able to apply a `scipy.ndimage`

transformation to these z-values . But as far as I know, we cannot access the contour data computed from the given set of points.

I don’t think using a histogram really solves my problem, since I may have negative z values. My issue is really about being able to use np.meshgrid() to supply (x,y) coordinates to the contour plot - in this way any transformation can be applied to the data. As far as I can see, this is not possible in Plotly.

Thanks for your suggestions anyway.

Has anyone figured this out?

I have the same problem, trying to generate a contour plot where the X and Y values are specified in 2D arrays. Any help would be greatly appreciated.

Mean time Plotly introduced new axes attributes, that improved the appearance of linearly transformed heatmaps and contours.

To get such a contour replace in this notebook:

https://chart-studio.plotly.com/~empet/15762

`fig1 = ...`

, by:

```
fig1 = go.Figure(go.Contour(x=x[0], y=y[:, 0], z=z,
colorscale='curl',
contours_size=0.25,
colorbar_thickness=25))
```

and `fig2 = ....`

```
fig2 = go.Figure(go.Contour(z=transformed_image,
colorscale='curl',
contours_size=0.25,
colorbar_thickness=20,
hovertemplate='z: %{z:.3f%}<extra></extra>',
hoverongaps=False))
```