gpt4 book ai didi

python - Bokeh 或 Plotly 中的极坐标图

转载 作者:太空宇宙 更新时间:2023-11-03 21:45:27 24 4
gpt4 key购买 nike

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

网上查了也没找到解决办法。有熟悉 Bokeh/Plotly 的人可以提供帮助吗?

我想画的图是这样的: enter image description here

谢谢!

这里是输入 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, -14 7 ,-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.92 1、0.92、0.921、0.92、0.919、0.919、0.917、0.917、 0.918, 0.919]

最佳答案

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

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')

有关如何正确绘制等值线图的更多信息,您可以访问此 page 的plotly 文档。和 this .

关于python - Bokeh 或 Plotly 中的极坐标图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52527718/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com