Home > database >  How to fix the plot using iteration through the subplots?
How to fix the plot using iteration through the subplots?

Time:05-03

import pandas as pd
import matplotlib.pyplot as plt

df = pd.read_csv("population.csv")

fig, axs = plt.subplots(nrows=2, ncols=2)

for col, ax in zip(df.columns, axs.flatten()):
  ax.plot(x,y)
  ax.set_title(col)
  plt.subplots_adjust(wspace=.5, hspace=.5)

fig.tight_layout()
plt.show()

The code above results to this: enter image description here

  • Related