2024-05-16 01:07:42 发布
网友
我正在尝试绘制一个180度的极坐标图,而不是Matplotlib中的360度,类似于MATLAB中的http://www.mathworks.com/matlabcentral/fileexchange/27230-half-polar-coordinates-figure-plot-function-halfpolar。有什么想法吗?
在matplotlib 2.1或更高版本中,可以执行以下操作。matplotlib页上还有an example。 可以使用通常的极坐标图ax = fig.add_subplot(111, polar=True),并限制θ范围。对于半极坐标图
ax = fig.add_subplot(111, polar=True)
ax.set_thetamin(0) ax.set_thetamax(180)
或对于四分之一极坐标图
ax.set_thetamin(0) ax.set_thetamax(90)
完整示例:
import matplotlib.pyplot as plt import numpy as np theta = np.linspace(0,np.pi) r = np.sin(theta) fig = plt.figure() ax = fig.add_subplot(111, polar=True) c = ax.scatter(theta, r, c=r, s=10, cmap='hsv', alpha=0.75) ax.set_thetamin(0) ax.set_thetamax(180) plt.show()
官方matplotlib文档中的示例代码可能会稍微模糊一些,如果有人只需要简单的四分之一的半图。 我写了一段代码片段,可以帮助不太熟悉AxisArtistshere的人。
AxisArtists
在matplotlib 2.1或更高版本中,可以执行以下操作。matplotlib页上还有an example。
可以使用通常的极坐标图
ax = fig.add_subplot(111, polar=True)
,并限制θ范围。对于半极坐标图或对于四分之一极坐标图
完整示例:
官方matplotlib文档中的示例代码可能会稍微模糊一些,如果有人只需要简单的四分之一的半图。 我写了一段代码片段,可以帮助不太熟悉
AxisArtists
here的人。相关问题 更多 >
编程相关推荐