Reputation: 468
I have the following two dummy dfs:
# First df
columns_One = ['count']
data_One = [[1],
[100],
[100],
[100],
[120],
[500],
[540],
[590]]
dummy_One = pd.DataFrame(columns=columns_One, data=data_One)
# Second df
columns_Two = ['count']
data_Two = [[1],
[100],
[102],
[300],
[490],
[400],
[400],
[290]]
dummy_Two = pd.DataFrame(columns=columns_Two, data=data_Two)
I want to plot them as a histogram. It currently looks like this:
How I plot it:
fig, axes = pyplot.subplots(1,2)
dummy_One.hist('count', ax=axes[0])
dummy_Two.hist('count', ax=axes[1])
pyplot.show()
I am struggling with the following:
Upvotes: 0
Views: 594
Reputation: 94
I assume that you simply want to rotate the plot, add orientation="horizontal"
.
You can share the axis of subplots by setting sharex=True
or sharey=True
.
To share the range simply specify the limits of either axis: plt.xlim(0,4)
and plt.ylim(-100,700)
import matplotlib.pyplot as plt
fig, axes = plt.subplots(1,2, sharex=True, sharey=True)
dummy_One.hist(ax=axes[0], orientation="horizontal")
dummy_Two.hist(ax=axes[1], orientation="horizontal")
plt.ylim(-100,700)
plt.xlim(0,4)
plt.show()
Upvotes: 2