Tuesday, August 1, 2017

Python Creating subplots

Let's assume that we want to create the following subplots using matplotlib. This is how we can initiate the plot.

import matplotlib.pyplot as plt    
    
fig = plt.figure(figsize=(10,7), dpi=200)    
ax = fig.add_subplot(2,1,1)    
ax.annotate("This is 2X1 [2 rows and 1 column] and we want to have this plot is 1st position.", 
            (0.5,0.5), horizontalalignment='center')    
ax = fig.add_subplot(2,2,3)    
ax.annotate("This is 2X2 [2 rows and 2 columns].\nWe want to have this plot at 3rd position.",
            (0.5,0.5), horizontalalignment='center')    
ax = fig.add_subplot(2,2,4)    
ax.annotate("This is 2X2 [2 rows and 2 columns].\nWe want to have this plot at 4th position.",
            (0.5,0.5), horizontalalignment='center') 

No comments:

Post a Comment