[PYTHON] Draw multiple graphs using Pandas

Draw multiple graphs using Pandas

How to draw multiple graphs in one area. For example, this article imports matplotlib in addition to pandas and draws. However, this time I will write about how to draw using only the pandas library.

As shown below, it seems that it can be realized by substituting the drawing information of the first graph into ax1 and substituting ax1 which is the first graph information into ax of the plot argument of the second graph. By doing this, it can be written concisely without using matplotlib.


import pandas as pd
import numpy as np

#Creating a data frame.
df = pd.DataFrame(np.arange(12).reshape(4, 3),
                  columns=["colA", "colB", "colC"],
                  index=["row1", "row2", "row3", "row4"])

#First graph.
ax1 = df.plot(x="colA", y="colB")
#Second graph.
df.plot(x="colA", y="colC", ax = ax1)

And the output result is as follows.

screenshot.png

References

https://stackoverflow.com/questions/42128467/matplotlib-plot-multiple-columns-of-pandas-data-frame-on-the-bar-chart/42131286

Recommended Posts

Draw multiple graphs using Pandas
Draw multiple graphs using matplotlib figures and axes
[Python] How to draw multiple graphs with Matplotlib
Cross tabulation using Pandas
Combine multiple Excel files loaded using pandas into one
Animate multiple graphs with matplotlib
Data analysis using python pandas
Data visualization method using matplotlib (+ pandas) (5)
Analyze JMeter jtl files using pandas
Precautions when using codecs and pandas
Data visualization method using matplotlib (+ pandas) (3)
Extract specific multiple columns with pandas
100 Language Processing Knock-31 (using pandas): Verb
Draw a graph with pandas + XlsxWriter
Easy to draw graphs with matplotlib
Cases using pandas plot, cases using (pure) matplotlib plot
Data visualization method using matplotlib (+ pandas) (4)
Coexist multiple versions using Node.js n
100 Language Processing Knock-38 (using pandas): Histogram