1

I'm trying to inset a polar plot inside a normal x vs y plot in cartesian coordinate. I know that inset can be obtained through pylab.axes as illustrated in this example. But I do not know how to specify this is a polar plot, possibly without any grid. Any help is welcomed

1 Answer 1

7

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

enter image description here

Sign up to request clarification or add additional context in comments.

2 Comments

@NicolaVianello If the answer is useful then vote it up. You have a 0% acceptation rate...
@NicolaVianello I cleaned a bit the code I assembled too fast. Now I think is simpler

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.