w3resource

Matplotlib Basic: Create multiple plots

Matplotlib Basic: Exercise-15 with Solution

Write a Python program to create multiple plots

Sample Solution:

Python Code:

import matplotlib.pyplot as plt
fig = plt.figure()
fig.subplots_adjust(bottom=0.020, left=0.020, top = 0.900, right=0.800)

plt.subplot(2, 1, 1)
plt.xticks(()), plt.yticks(())

plt.subplot(2, 3, 4)
plt.xticks(())
plt.yticks(())

plt.subplot(2, 3, 5)
plt.xticks(())
plt.yticks(())

plt.subplot(2, 3, 6)
plt.xticks(())
plt.yticks(())

plt.show()

Sample Output:

Matplotlib Basic: Create multiple plots

Python Code Editor:

Contribute your code and comments through Disqus.

Previous: Write a Python program to display the grid and draw line charts of the closing value of Alphabet Inc. between October 3, 2016 to October 7, 2016. Customized the grid lines with rendering with a larger grid (major grid) and a smaller grid (minor grid).Turn on the grid but turn off ticks.
Next: Matplotlib Barchart Exercises

What is the difficulty level of this exercise?



Follow us on Facebook and Twitter for latest update.