繁体   English   中英

matplotlib,极轴上的矩形图

[英]matplotlib, rectangular plot in polar axes

是否可以有一个标准的矩形(又称笛卡尔坐标)图,但显示在一组极坐标轴上?

我只想要Polar polar()函数提供的灰色边框的遮罩外观,但我不想将坐标转换为Polar,并使用polar()

如果您只想在极坐标网格上进行绘图时能够在直角坐标中调用两个数组,则将为您提供所需的内容。 在这里,x和y是矩形的数组,将为您提供x = y的线。 它返回相同的趋势线,但是在极坐标上。 如果您需要更多的掩码,实际上限制了所显示的某些数据,则在for循环中插入一行,内容如下: for r < 5.0:或您的掩码标准。

from math import cos, sin, atan2, sqrt
import matplotlib.pyplot as plt
plt.clf()
width, height = matplotlib.rcParams['figure.figsize']
size = min(width, height)
# make a square figure
fig = figure(figsize=(size, size))
ax = fig.add_axes([0.1, 0.1, 0.8, 0.8], polar=True, axisbg='#d5de9c')
x = range(10)
y = range(10)
r = []
phi = []
for ii in range(len(x)): 
  r.append(sqrt(x[ii]**2.+y[ii]**2.))
  phi.append(atan2(y[ii],x[ii]))
ax.scatter(phi,r)
show()

暂无
暂无

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

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