Reverse radial axes of Matplotlib polar plot

后端 未结 2 1100
情歌与酒
情歌与酒 2020-12-11 18:35

I\'m trying to create an astronomical polar plot with a radial axis that starts from -45° on outer line and increases to 90° in the center of the plot. But I didn\'t find an

相关标签:
2条回答
  • 2020-12-11 18:58

    It's a little bit "hacky", but if you know the bounds (which it seems like you do as it corresponds to declination) you could do something like:

    import matplotlib.pyplot as plt
    import numpy as np
    
    fig = plt.figure()
    ax = fig.add_axes([0.1,0.1,0.8,0.8], polar=True)
    # ax.invert_yaxis()
    ax.set_theta_zero_location('N')
    ax.set_rlim(90, -45, 1)
    # Note: you must set the end of arange to be slightly larger than 90 or it won't include 90
    ax.set_yticks(np.arange(-45, 91, 15))
    ax.set_yticklabels(ax.get_yticks()[::-1])
    ax.plot([0,10,20], 90-np.array([12,13,14]), linestyle='', marker='.')
    fig.show()
    

    0 讨论(0)
  • 2020-12-11 19:14

    Old question, but I finally found an easy answer. Use ax.set_rlim(bottom=90, top=-45). Note that you have to set this BEFORE calling ax.plot(), or it will not transform the plotted points accordingly.

    0 讨论(0)
提交回复
热议问题