Shade 'cells' in polar plot with matplotlib

前端 未结 3 1000
南方客
南方客 2020-12-28 21:25

I\'ve got a bunch of regularly distributed points (θ = n*π/6, r=1...8), each having a value in [0, 1]. I can plot them with their values in matplotlib using

         


        
3条回答
  •  情歌与酒
    2020-12-28 22:22

    This can be done quite nicely by treating it as a polar stacked barchart:

    import matplotlib.pyplot as plt
    import numpy as np
    from random import choice
    
    fig = plt.figure()
    ax = fig.add_axes([0.1, 0.1, 0.8, 0.8], polar=True)
    
    for i in xrange(12*8):
        color = choice(['navy','maroon','lightgreen'])
        ax.bar(i * 2 * np.pi / 12, 1, width=2 * np.pi / 12, bottom=i / 12,
               color=color, edgecolor = color)
    plt.ylim(0,10)
    ax.set_yticks([])
    plt.show()
    

    Produces:

    enter image description here

提交回复
热议问题