Search code examples
pythonmatplotlibplotpolar-coordinates

Polar plot with Python changing the thickness of my grid


I am working with Python 2.7 on a live plot of data, that I get from a Spectrum analyzer.

The live plot is working perfectly fine and plots the data continuously in a polar plot.

I changed the labels of my y-data which refer to the radius.

plt.yticks((0, 30000000, 230000000, 750000000, 1000000000, 1500000000), ( 0, '30MHz', '230MHz',  ' 0.75GHz', '1GHz', ' 1.5GHz') )

That will give me a grid line on every of this label.

I want to increase the thickness of these grid lines ( the dashed line) to see them better because they are covered with color.

I hope you can help me. And if you need more code I am happy to share more of it with you.

Here is an example of my plot:

enter image description here

EDIT

Although the question is already answered (thanks tom) I want to share some useful commands with you.

I googled again and found that you can add some more keywords to grid()

grid( color = 'r', linestyle = '-', linewidth = 3 )

color is actually pretty obvious but with linestyle = '-' the line is drew through.


Solution

  • you can do this by setting the linewidth of ax.grid:

    import matplotlib.pyplot as plt
    
    fig=plt.figure(figsize=(8,4))
    ax1=fig.add_subplot(121,projection='polar')
    ax2=fig.add_subplot(122,projection='polar')
    
    ax1.grid(linewidth=3)
    
    plt.show()
    

    enter image description here

    EDIT

    To change only the concentric circles, you can set linewidth just for ax.yaxis.grid:

    import matplotlib.pyplot as plt
    
    fig=plt.figure(figsize=(8,4))
    ax1=fig.add_subplot(121,projection='polar')
    ax2=fig.add_subplot(122,projection='polar')
    
    ax1.yaxis.grid(linewidth=3)
    
    plt.show()
    

    enter image description here