pythonmatplotlibvisualizationpolar-coordinates

Matplotlib polar chart not showing all xy-ticks


no

Issue 1: The x-ticks (pie pieces) aren't ordered from 0 to 24 (my bad, should be 1)

Issue 2: all y-ticks (rings) aren't showing

Issue 3: Someone seems to have eaten a part of the polar chart ...

I expect to see 31 rings, and 24 "pie pieces".


Solution

  • import matplotlib.pyplot as plt
    import numpy as np
    
    fig = plt.figure()
    
    ax = fig.add_subplot(111, projection='polar')
    
    ax.set_xticks(np.arange(1, 25) * np.pi / 12) 
    ax.set_xticklabels([str(number) for number in range(1, 25)])
    
    ax.set_yticks(range(1, 32)) 
    ax.set_yticklabels([str(number) for number in range(1, 32)])
    
    ax.grid(True)
    
    ax.scatter(np.pi / 12 * 24, 31)  
    
    ax.set_ylim(0, 32)
    
    plt.show()
    

    Image