【发布时间】:2018-06-02 11:04:32
【问题描述】:
我在 matplotlib 中绘制极坐标散点图,每个数据点附近都有注释。
我需要将注释加粗(因为它们重叠),还要将 r 轴刻度标签加粗(以及垂直线右侧的轴标签)。
我的代码:
import numpy as np
import matplotlib.pyplot as plt
month = ['Feb-16','Mar-16', 'Apr-16', 'May-16', 'Jun-16', 'Jul-16',
'Aug-16', 'Sep-16', 'Nov-16', 'Dec-16', 'Jan-17']
phi = np.array([3.272, 3.185, 3.159, 2.13, 2.879, 2.617, 2.705,
2.53, 3.228, 3.054, np.pi])
r = np.array([1006.225, 1006.083, 1007.189, 1007.0614, 1002.909, 1001.053,
1001.953, 1006.609, 1011.403, 1013.885,1013.391])
fig = plt.figure()
ax = fig.add_subplot(111, projection='polar')
c = ax.scatter(phi, r, alpha=0.75)
ax.set_ylim(1000,1014)
ax.set_xlim(np.pi/2,(7/6.)*np.pi)
ax.yaxis.set_tick_params(labelsize=12)
for i in range(len(r)):
ax.annotate(month[i],
xy=(phi[i], r[i]))
lines, labels = ax.set_thetagrids( range(90,240,30),
('12:00', '11:00', '10:00','9:00', '8:00'),
fontweight='bold')
plt.show()
产生:
有什么建议吗?
谢谢!!
【问题讨论】:
标签: python matplotlib polar-coordinates