Subplots in Matplotlib Presentation-1
Subplots in Matplotlib Presentation-1
• Example Code:
• import matplotlib.pyplot as plt
• import numpy as np
Creating Basic Subplots with Axes
• Standard Axes:
• ax1 = plt.axes() # Creates main axes
• ax2 = plt.axes([0.65, 0.65, 0.2, 0.2]) # Inset subplot
• Example Code:
• for i in range(1, 7):
• plt.subplot(2, 3, i)
• plt.text(0.5, 0.5, str((2, 3, i)), fontsize=18,
ha='center')
• Example Code:
• grid = plt.GridSpec(2, 3, wspace=0.4, hspace=0.3)
• plt.subplot(grid[0, 0]) # First row, first column
• plt.subplot(grid[0, 1:]) # First row, spans columns 2
and 3
• plt.subplot(grid[1, 2]) # Second row, third column