Build multiple lines on subtitles with pandas df.plot

Is there a way to build multiple columns of data on the same graph with multiple subheadings for the data frame?

eg. If df has 12 columns of data, by subtitle 1, build columns 1-3, subtitle 2, columns 4-6, etc.

I understand how to use df.plot to have one subtask for each column, but I'm not sure how to group as above.

Thanks!

+3
source share
1 answer

This is an example of how I do this:

import pandas as pd import numpy as np import matplotlib.pyplot as plt fig, axes = plt.subplots(1, 2) np.random.seed([3,1415]) df = pd.DataFrame(np.random.randn(100, 6), columns=list('ABCDEF')) df = df.div(100).add(1.01).cumprod() df.iloc[:, :3].plot(ax=axes[0]) df.iloc[:, 3:].plot(ax=axes[1]) 

enter image description here

+2
source

All Articles