【问题标题】:Polar contour plot in Bokeh or PlotlyBokeh 或 Plotly 中的极坐标等值线图
【发布时间】:2018-09-27 00:25:00
【问题描述】:

我需要使用 Bokeh 或 Plotly Python 绘制等高线图,以显示圆形区域中的波浪分布。我总是研究 49 个点,并且 x_cord 和 y_cord 是已知的,并且在不同情况下不会改变。波密度(z)可以通过python中的其他函数计算,并根据具体情况进行更改。

我在网上搜索并找不到解决方案。有熟悉 Bokeh/Plotly 的人可以提供帮助吗?

我要画的图是这样的:

谢谢!

这里是输入 x_cord、y_cord 和 z 的示例

x_cord = [0, -0.0, -34.6, -49, -34.6, 0.0, 34.6, 49, 34.6, -0.0, -37.5, -69.3, -90.5, -98, -90.5, -69.3, - 37.5、0.0、37.5、69.3、90.5、98、90.5、69.3、37.5、-0.0、-38.0、-73.5、-103.9、-127.3、-142.0、-147、-142.0、-127.3、-103.9、-73.5 , -38.0, 0.0, 38.0, 73.5, 103.9, 127.3, 142.0, 147, 142.0, 127.3, 103.9, 73.5, 38.0]

y_cord = [0, 49, 34.6, -0.0, -34.6, -49, -34.6, 0.0, 34.6, 98, 90.5, 69.3, 37.5, -0.0, -37.5, -69.3, -90.5, -98 , -90.5, -69.3, -37.5, 0.0, 37.5, 69.3, 90.5, 147, 142.0, 127.3, 103.9, 73.5, 38.0, -0.0, -38.0, -73.5, -103.9, -127.3, -142.0, -147 , -142.0, -127.3, -103.9, -73.5, -38.0, 0.0, 38.0, 73.5, 103.9, 127.3, 142.0]

Z = [0.932,0.93,0.93,0.932,0.933,0.933,0.932,0.931,0.93,0.924,0.925,0.926,0.927,0.928,0.929,0.929,0.929,0.93,0.929,0.928,0.927,0.926, 0.925,0.924,0.924,0.92,0.923,0.923,0.924,0.925,0.923,0.924,0.925,0.925,0.924,0.923,0.921,0.92,0.923,0.921,0.92,0.921,0.92,0.919,0.919,0.917,0.917, 0.918, 0.919]

【问题讨论】:

    标签: python plotly bokeh figure


    【解决方案1】:

    plotly 你可以得到类似的东西:

    Code:
    # import the necessaries libraries
    import plotly.offline as py
    import plotly.graph_objs as go
    # Create data
    data = [
        go.Histogram2dcontour(
              x = [0, -0.0, -34.6, -49, -34.6, 0.0, 34.6, 49, 34.6, -0.0, -37.5,\
                   -69.3, -90.5, -98, -90.5, -69.3, -37.5, 0.0, 37.5, 69.3, 90.5,\
                   98, 90.5, 69.3, 37.5, -0.0, -38.0, -73.5, -103.9, -127.3,\
                   -142.0, -147, -142.0, -127.3, -103.9, -73.5, -38.0, 0.0, 38.0,\
                   73.5, 103.9, 127.3, 142.0, 147, 142.0, 127.3, 103.9, 73.5, 38.0],
              y = [0, 49, 34.6, -0.0, -34.6, -49, -34.6, 0.0, 34.6, 98, 90.5, 69.3,\
                   37.5, -0.0, -37.5, -69.3, -90.5, -98, -90.5, -69.3, -37.5, 0.0,\
                   37.5, 69.3, 90.5, 147, 142.0, 127.3, 103.9, 73.5, 38.0, -0.0,\
                   -38.0, -73.5, -103.9, -127.3, -142.0, -147, -142.0, -127.3,\
                   -103.9, -73.5, -38.0, 0.0, 38.0, 73.5, 103.9, 127.3, 142.0],
              z = [0.932, 0.93, 0.93, 0.932, 0.933, 0.933, 0.932, 0.931, 0.93,\
                   0.924, 0.925, 0.926, 0.927, 0.928, 0.929, 0.929, 0.929, 0.93,\
                   0.929, 0.928, 0.927, 0.926, 0.925, 0.924, 0.924, 0.92, 0.92,\
                   0.921, 0.922, 0.923, 0.923, 0.924, 0.925, 0.924, 0.924, 0.925,\
                   0.925, 0.924, 0.923, 0.921, 0.92, 0.921, 0.92, 0.919, 0.919,\
                   0.917, 0.917, 0.918, 0.919],
             # You can choose another colorscale if you want
             #[‘Blackbody’,‘Bluered’,‘Blues’,‘Earth’,‘Electric’,‘Greens’,‘Greys’,\
             # ‘Hot’,‘Jet’,‘Picnic’,‘Portland’,‘Rainbow’,‘RdBu’,‘Reds’,‘Viridis’,
             # ‘YlGnBu’,‘YlOrRd’]
             colorscale='Portland',
             contours=dict(
                coloring='heatmap',
                start=3,
                end=9,
                size=1
             ),
        )
    ]
    # Layout usually need to set the title, size of plot etc.
    layout = go.Layout(
        height = 600,
        width = 600,
        bargap = 0,
        hovermode = 'closest',
        showlegend = False)
    # Create fig
    fig = go.Figure(data=data,layout=layout)
    # Save the plot in your Python script directory and open in a browser
    py.plot(fig, filename='contoursimple.html')
    

    有关如何正确绘制等高线图的更多信息,您可以访问 pagethis 上的 plotly 文档。

    【讨论】:

      猜你喜欢
      • 2011-09-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-12-20
      • 2016-08-17
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多