简体   繁体   中英

Rotate theta=0 on matplotlib polar plot

I have the following example code:

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

data_theta = range(10,171,10)

data_theta_rad = []
for i in data_theta:
    data_theta_rad.append(float(i)*np.pi/180.0)

data_r = random.sample(range(70, 90), 17)

print data_theta
print data_r

ax = plt.subplot(111, polar=True)
ax.plot(data_theta_rad, data_r, color='r', linewidth=3)
ax.set_rmax(95)
# ax.set_rmin(70.0)
ax.grid(True)

ax.set_title("Example", va='bottom')
plt.show()

...which produces something like this: 在此处输入图片说明

...but I would like to set theta=0 to the 'West'. So something like:

在此处输入图片说明

Any ideas how to do this with matplotlib (I made the pic below in powerpoint) ?

Simply use:

ax.set_theta_zero_location("W")

More info in the documentation of matplotlib.

A more flexible way:

ax.set_theta_offset(pi)

You can rotate the axis arbitrarily, just replace pi with the angle you want.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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