Search code examples
pythonmatplotlibplotangle

How to draw few angles to compare them?


I have a csv database with number of angles (all of them from 0 to 360). I want kind of matplotlib diagram which show me distribution of all angles (for every row in csv).

Maybe you know how to realize that with any python library? Or please show me how to draw at least two angles as vectors?

I was find only polar plot in matplotlib, that have degrees and its a circle. And I need something like this image (three angles shown and understandable for comparing) (draw lines by hand).

https://i.sstatic.net/Ls5zI.png


Solution

  • The polar plot is a bit strange, I managed to create the plot using a scatter plot set to polar. I haven't included any code to read in the angles from a csv, just note that should be converted to radians before plotting.

    import numpy as np
    import matplotlib.pyplot as plt
    
    
    theta = np.radians(np.array([10, 20, 40]))
    radius = np.ones(theta.size) # make a radius for each point of length 1
    
    fig = plt.figure() 
    ax = plt.subplot(111, polar=True)  # Create subplot in polar format
    
    for t, r in zip(theta, radius):
        ax.plot((0, t), (0, r))
    
    fig.show()
    

    polar plot