简体   繁体   English

Matplotlib插入极坐标图

[英]Matplotlib inset polar plot

I'm trying to inset a polar plot inside a normal x vs y plot in cartesian coordinate. 我试图在笛卡尔坐标中插入正常x对y图内的极坐标图。 I know that inset can be obtained through pylab.axes as illustrated in this example . 我知道插入可以通过pylab.axes获得,如本例所示 But I do not know how to specify this is a polar plot, possibly without any grid. 但我不知道如何指定这是一个极地情节,可能没有任何网格。 Any help is welcomed 欢迎任何帮助

Here you have a working example. 这里有一个有效的例子。
The main point is to specify a new, smaller axes for the second figure 重点是为第二个数字指定一个新的较小的轴

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()    

在此输入图像描述

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

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