简体   繁体   English

如何在 Python Plotly 中制作垂直截面轮廓 plot

[英]How can I make Vertical Section Contour plot in Python Plotly

Assuming I have a data for different levels and I want to plot it as different vertical sections of a contour plot.假设我有一个不同级别的数据,我想要 plot 它作为轮廓 plot 的不同垂直部分。

在此处输入图像描述

I may also need to do it with different datasets, for instance, plotting a volume plot and below it, its gradient, or the error, as a vertical section of a contour plot with a different colormap.我可能还需要对不同的数据集进行处理,例如,绘制体积 plot 及其下方的梯度或误差,作为具有不同颜色图的轮廓 plot 的垂直部分。

在此处输入图像描述

How can I do it using the Python package for Plotly?我如何使用 Python package 为 Plotly 做到这一点? I couldn't find this type of plot in their examples.我在他们的示例中找不到这种类型的 plot。

I kind of found a way to do it, but it works like a pcolor instead of contour .我找到了一种方法来做到这一点,但它的工作原理类似于pcolor而不是contour To do that, I have to plot a surface with fixed depth and use the attribute surfacecolor to define the color array.为此,我必须 plot 具有固定深度的表面并使用属性surfacecolor来定义颜色数组。

fig = go.Figure(data=[
    go.Surface(
        x=x,
        y=y,
        z=z1,
        colorbar=dict(len=0.3, x=0.8, y=0.75),
    ),
    go.Surface(
        x=x,
        y=y,
        z=z2*0-np.pi,
        surfacecolor=z2,
        opacity=0.5,
        cmin=-1,
        cmax=1,
        colorscale='RdBu',
        colorbar=dict(len=0.3, x=0.8, y=0.5),
    ),
    go.Surface(
        x=x,
        y=z2*0+2*np.pi,
        z=y-np.pi,
        surfacecolor=z2,
        opacity=0.5,
        cmin=-1,
        cmax=1,
        colorscale='Spectral',
        colorbar=dict(len=0.3, x=0.8, y=0.25),
    ),
])


fig.show() 

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM