mpld3 fails to plot polar

21 Views Asked by At

I want to save a matlibplot polar plot as html and it fails miserably.

import numpy as np
import matplotlib.pyplot as plt
import mpld3

n = 20
frame=500
totalframes=8000
theta = np.linspace(2*np.pi/4, 3*np.pi/4, n)
rout = np.ones(n)*30
rin= np.ones(n)*20

fig = plt.figure(figsize=(7,8))
ax = fig.add_subplot(111, polar=True)
ax.set_rgrids(np.array((20,30)))
ax.set_ylim(0, 30)
ax.fill_between(theta, rin, rout, color='green', alpha=0.5, label="Goal Zone")
# ax.plot(theta, rout, theta, rin, '*')
ax.plot(2*np.pi/5, 25, 'r*', markersize=20, label="animal's position")
ax.set_title(f"Frames: {frame} of {totalframes}", fontsize=20)
# ax.legend()
mpld3.fig_to_html(fig)
mpld3.show()

instead of a nice circular plot, i get a messy totaly wrong cartesian represenation.

Thank you for helping me with this problem in advance.

0

There are 0 best solutions below