johnson
johnson

Reputation: 429

how to plot graphs for dataframe side by side?

I want to plot multiple graphs for Dataframes and box plots side by side instead of top to bottom. For example, If i plot these 3 graphs in will appear top to bottom.I want to display it sides by side(left to right)

df.plot(x="Date", y=["Temp.PM", "Temp.AM"],subplots=True )
df.plot(x="Date", y=["pH_AM", "pH_PM"])
df.plot(x="Date", y=["WindSpeed_AM", "WindSpeed_PM"])

enter image description here Rather than appearing this way.

Upvotes: 0

Views: 1568

Answers (1)

Ruthger Righart
Ruthger Righart

Reputation: 4921

The following serves as an example. There are of course many parameters that can be set and changed:

import numpy as np
import matplotlib.pyplot as plt

Some example data:

x1 = np.random.rand(10) * 10
x2 = np.random.rand(10) * 20
x3 = np.random.rand(10) * 30

Creating the subplots:

fig, axes = plt.subplots(1, 3)
axes[0].boxplot(x1)
axes[1].boxplot(x2)
axes[2].boxplot(x3)
fig.tight_layout()
plt.show()

enter image description here

Of course, different type of plots (boxplots, lineplots etc) can be combined.

Upvotes: 1

Related Questions