0

I have two DataFrames that have time-series data of BTC. I want to display the graphs side by side to analyze them.

display(data_df.plot(figsize=(15,20)))

display(model_df.plot(figsize=(15,20)))

When I plot them like this they stack on top of each-other vertically. I want them side-by-side so they look like this.

enter image description here

  • Does this answer your question? [How to plot multiple dataframes in subplots](https://stackoverflow.com/questions/22483588/how-to-plot-multiple-dataframes-in-subplots) – BigBen Oct 04 '22 at 20:28

2 Answers2

0

Heres one way that might work using subplots (Im guessing you want a total figsize=30x20):

import pylab as plt
fig,(ax0,ax1) = plt.subplots(nrows=1,ncols=2, figsize=(30,20))
data_df.plot(ax=ax0)
model_df.plot(ax=ax1)
dermen
  • 5,252
  • 4
  • 23
  • 34
0

You can use matplotlib.pyplot.subplots :

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

data_df = pd.DataFrame(np.random.randint(0,100,size=(15, 2)), columns=list('AB'))
model_df = pd.DataFrame(np.random.randint(0,100,size=(15, 2)), columns=list('AB'))

fig, axes = plt.subplots(nrows=1, ncols=2, figsize=(12,4))

for col, ax in zip(data_df, axes):
    data_df[col].plot(ax=ax, label=f"data_df ({col})")
    model_df[col].plot(ax=ax, label=f"model_df ({col})")
    ax.legend()

# Output :

enter image description here

Timeless
  • 22,580
  • 4
  • 12
  • 30