python matplolib polar chart x-axis label position

烈酒焚心 提交于 2019-12-06 11:29:20

you can do this by setting the labels on minor ticks, but then setting the minor tick width to zero so you don't see them:

import matplotlib.ticker as ticker

# Set the major and minor tick locations
ax.xaxis.set_major_locator(ticker.MultipleLocator(np.pi/4))
ax.xaxis.set_minor_locator(ticker.MultipleLocator(np.pi/8))

# Turn off major tick labels
ax.xaxis.set_major_formatter(ticker.NullFormatter())

# Set the minor tick width to 0 so you don't see them
for tick in ax.xaxis.get_minor_ticks():
    tick.tick1line.set_markersize(0)
    tick.tick2line.set_markersize(0)
    tick.label1.set_horizontalalignment('center')

# Set the names of your ticks, with blank spaces for the major ticks
ax.set_xticklabels(['','','Seg 1','','Seg 2','','Seg 3','','Seg 4','','Seg 5','','Seg 6','','Seg 7','','Seg 8'],minor=True)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!