matplotlib,极轴矩形图

发布于 2024-12-07 04:56:20 字数 128 浏览 0 评论 0原文

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

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

Is it possible to have a standard rectangular (aka Cartesian) plot, but displayed on a polar set of axes?

I just want the masking appearance of the grey border provided by the polar() function, but I do not want to convert my coordinates to polar, and use polar().

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一刻暧昧 2024-12-14 04:56:20

如果您只想能够在直角坐标中调用两个数组,同时在极坐标网格上绘图,这将为您提供所需的内容。这里,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()

If you just want to be able to call two arrays in rectangular coordinates, while plotting on a polar grid, this will give you what you need. Here, x and y are your arrays that, in rectangular, would give you an x=y line. It returns the same trend line but on in polar coordinates. If you require more of a mask, that actually limits some of the data being presented, then insert a line in the for loop that says something like: for r < 5.0: or whatever your criteria is for the mask.

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()
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文