繁体   English   中英

Python:Matplotlib Surface_plot

[英]Python: Matplotlib Surface_plot

我正在尝试绘制一个高分辨率的surface_plot,但我也非常喜欢它上面的一些漂亮的网格线。 如果我在同一个参数中使用网格线

ax.plot_surface(x_itp, y_itp, z_itp, rstride=1, cstride=1, facecolors=facecolors, linewidth=0.1)

我得到了很多网格线。 另一方面,如果我将“rstride”和“cstride”设置为更高的值,我的球体将变得丑陋。

然后我试图粉碎一个

ax.plot_wireframe(x_itp, y_itp, z_itp, rstride=3, cstride=3)

之后,它只是位于彩色球体的顶部..这意味着我可以看到线框的背面,然后是它背后的surface_plot。

有人试过吗?

另一个选择是使用“底图”,它可以创建一个漂亮的网格,但然后我将不得不调整我的彩色表面。

我的情节看起来像这样: surface_plot

如果我使用更高的“rstride”和“cstride”向地图添加边缘,那么它看起来像这样:

在此输入图像描述

代码:

norm = plt.Normalize()
facecolors = plt.cm.jet(norm(d_itp))

# surface plot 
fig, ax = plt.subplots(1, 1, subplot_kw={'projection':'3d', 'aspect':'equal'})
ax.hold(True)
surf = ax.plot_surface(x_itp, y_itp, z_itp, rstride=4, cstride=4, facecolors=facecolors)
surf.set_edgecolors("black")

我想在球体周围显示\\ theta和\\ phi角度..可能相隔30度。

干杯! 莫滕

看起来您可能需要使用底图。 使用plot_surface(),您可以使用高分辨率绘图或低分辨率,顶部有良好的网格。 但不是两个。 我刚刚用等高线图制作了一个简单的底图。 我认为你可以轻松地在它上面应用pcolor。 只是不要绘制大陆和国家边界。 然后,你有一个很好的球体,可以提供更多的控制。 制作绘图后,您可以轻松地在其上添加网格。

from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
import numpy as np

map = Basemap(projection='ortho',lat_0=45,lon_0=-150) 
map.drawmapboundary(fill_color='aquamarine')
map.drawmeridians(np.arange(0,360,30)) # grid every 30 deg
map.drawparallels(np.arange(-90,90,30))

nlats = 73; nlons = 145; delta = 2.*np.pi/(nlons-1)
lats = (0.5*np.pi-delta*np.indices((nlats,nlons))[0,:,:])
lons = (delta*np.indices((nlats,nlons))[1,:,:])
wave = 0.6*(np.sin(2.*lats)**6*np.cos(4.*lons))
mean = 0.5*np.cos(2.*lats)*((np.sin(2.*lats))**2 + 2.)

x, y = map(lons*180./np.pi, lats*180./np.pi) # projection from lat, lon to sphere
cs = map.contour(x,y,wave+mean,15,linewidths=1.5) # contour data. You can use pcolor() for your project
plt.title('test1')
plt.show()

使用底图在球体上的等高线图

暂无
暂无

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

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