gpt4 book ai didi

python - Matplotlib 插图极坐标图

转载 作者:太空宇宙 更新时间:2023-11-04 10:58:43 25 4
gpt4 key购买 nike

我正在尝试在笛卡尔坐标系中的正常 x 与 y 图中插入极坐标图。我知道插图可以通过 pylab.axes 获得,如本 example 所示。 .但我不知道如何指定这是一个极坐标图,可能没有任何网格。欢迎任何帮助

最佳答案

这里有一个工作示例。
要点是为第二个图形指定一个新的、更小的轴

import numpy as np
from matplotlib import pyplot as plt
from scipy import randn, convolve

#data
t = np.arange(0.0, 20.0, 0.001)
r = np.exp(-t[:1000]/0.05)
x = randn(len(t))
s = convolve(x,r)[:len(x)]*0.001
theta = 2 * np.pi * t
#
fig = plt.figure(figsize=(7, 6))
#main
plt.plot(t, s)
plt.axis([0, 1, np.amin(s), 2.5*np.amax(s)])
plt.xlabel('xlabel')
plt.ylabel('ylabel')
#polar
ax = fig.add_axes([0.2, 0.47, 0.30, 0.40], polar=True, axisbg='yellow')
ax.plot(theta, t, color='blue', lw=3)
ax.set_rmax(1.0)
plt.grid(True)

plt.show()

enter image description here

关于python - Matplotlib 插图极坐标图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7610973/

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