Plot polar graph in Matplotlib
Plot polar graph:
import matplotlib.pyplot as plt import numpy as np employee = ["Sam", "Rony", "Albert", "Chris", "Jahrum"] actual = [45, 53, 55, 61, 57, 45] expected = [50, 55, 60, 65, 55, 50] # Initialise the spider plot by setting figure size and polar projection plt.figure(figsize=(10, 6)) plt.subplot(polar=True) theta = np.linspace(0, 2 * np.pi, len(actual)) # Arrange the grid into number of sales equal parts in degrees lines, labels = plt.thetagrids(range(0, 360, int(360/len(employee))), (employee)) # Plot actual sales graph plt.plot(theta, actual) plt.fill(theta, actual, 'b', alpha=0.1) # Plot expected sales graph plt.plot(theta, expected) # Add legend and title for the plot plt.legend(labels=('Actual', 'Expected'), loc=1) plt.title("Actual vs Expected sales by Employee") # Dsiplay the plot on the screen plt.show()
The following is the output that will be obtained:
2018-11-23T02:16:48+05:30
2018-11-23T02:16:48+05:30
Amit Arora
Amit Arora
Python Programming Tutorial
Python
Practical Solution