how to create multiple plots in python code example

Example 1: show multiple plots python

#One way to plot two figure at once
f = plt.figure(1)
plt.plot([1,2],[2,3])
f.show()

g = plt.figure(2)
plt.plot([2,7,3],[5,1,9])
g.show()

Example 2: create plots with multiple dataframes python

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt

scenarios = ['scen-1', 'scen-2']

fig, ax = plt.subplots()

for index, item in enumerate(scenarios):
    df = pd.DataFrame({'A' : np.random.randn(4)})
    print df
    df.plot(ax=ax)

plt.ylabel('y-label')
plt.xlabel('x-label')
plt.title('Title')
plt.show()

Tags:

Misc Example