jmquintana79
7/13/2016 - 8:47 AM

plot multiple charts

Multiple charts in same figure

import matplotlib.pyplot as plt

# create object
fig= plt.figure(figsize=(15,10))

# grid 4x4
# this chart start in position (0,0) of grid
# this chart is expanded 4 columns of the grid (first row in this case)
# this chart is expanded 4 rows of the grid (two first rows in this case)
ax1 = plt.subplot2grid((4,4),(0,0),colspan=4,rowspan=2) 


## SET SEPARATION BETWEEN CHARTS
"""
Example:
  left  = 0.125  # the left side of the subplots of the figure
  right = 0.9    # the right side of the subplots of the figure
  bottom = 0.1   # the bottom of the subplots of the figure
  top = 0.9      # the top of the subplots of the figure
  wspace = 0.2   # the amount of width reserved for blank space between subplots
  hspace = 0.2   # the amount of height reserved for white space between subplots
"""
plt.subplots_adjust(hspace = 0.4)


# grid 4x4
# this chart start in position (3,0) of grid
# this chart is expanded 2 columns of the grid
# this chart is not expanded for more than 1 row
ax2 = plt.subplot2grid((4,4),(3,0),colspan=2)
import matplotlib.pyplot as plt

# Make subplots that are next to each other
fig, (ax1, ax2) = plt.subplots(nrows=1, ncols=2, figsize=(12, 8))