MATPLOTLIB code code example

Example 1: import matplotlib.pyplot as plt

from matplotlib import pyplot as plt

import matplotlib.pyplot as plt

Example 2: python 2d graph

names = ['group_a', 'group_b', 'group_c']
values = [1, 10, 100]

plt.figure(figsize=(9, 3))

plt.subplot(131)
plt.bar(names, values)
plt.subplot(132)
plt.scatter(names, values)
plt.subplot(133)
plt.plot(names, values)
plt.suptitle('Categorical Plotting')
plt.show()

Example 3: how to import matplotlib.pyplo in python

import matplotlib.pylot as plt

Example 4: import pyplot python

import matplotlib.pyplot as plt

Example 5: pyplot x vs y

plt.plot([1, 2, 3, 4], [1, 4, 9, 16])