Pyt
Pyt
plt.plot(xpoints, ypoints)
plt.show()
plt.plot(xpoints, ypoints)
plt.show()
Plotting without x-points:
plt.plot(ypoints)
plt.show()
import matplotlib.pyplot as plt
import numpy as np
plt.plot(ypoints, 'o:r')
plt.show()
import numpy as np
import matplotlib.pyplot as plt
x =
np.array([80, 85, 90, 95, 100, 105, 110, 11
5, 120, 125])
y =
np.array([240, 250, 260, 270, 280, 290, 300
, 310, 320, 330])
plt.plot(x, y)
plt.grid()
plt.show()
Display only grid lines for the x-axis:
import numpy as np
import matplotlib.pyplot as plt
x =
np.array([80, 85, 90, 95, 100, 105, 110, 11
5, 120, 125])
y =
np.array([240, 250, 260, 270, 280, 290, 300
, 310, 320, 330])
plt.plot(x, y)
plt.grid(axis = 'x')
plt.show()
Bar Graph Histogram
No space between two
Equal space between
consecutive bars. They
every two consecutive
should be attached to each
bars.
other.
The x-axis should represent
The x-axis can represent
only continuous data that is
anything.
in terms of numbers.
Draw 4 bars:
plt.bar(x,y)
plt.show()
plt.barh(x, y)
plt.show()
import numpy as np
print(x)
plt.hist(x)
plt.show()
import matplotlib.pyplot as plt
import numpy as np
plt.pie(y)
plt.show()
By default the plotting of the first wedge starts from the x-axis and
moves counterclockwise:
The size of each wedge is determined by comparing the value with all the other values, by using this formula:
The value divided by the sum of all values: x/sum(x)
Labels
Add labels to the pie chart with the label parameter.
The label parameter must be an array with one label for each wedge: