How to add axis break when plotting two data frames inside same axis

Viewed 24

I am new for coding and would appreciate any help on the following issue. I have plotted two data frames inside the same axis. Now I am trying to break axis at two places. X axis at (500-750,100-1250) and y axis at (1500-2000, 3000-3500). I have seen examples on how to do this for a single data frame (https://matplotlib.org/3.1.0/gallery/subplots_axes_and_figures/broken_axis.html) but I want to know how to do this when plotting two data frames on the same axis.

my code;

from matplotlib import pyplot as plt
import seaborn as sns
import numpy as np
import pandas as pd
import plotly.express as px

df1 =pd.read_csv('path_to/WT.csv')
df2 =pd.read_csv('path_to/WTKD.csv')
ax=df1['sum'].plot(legend=False, grid=True, figsize=(12,10), kind='line', color='green')
df2['sum'].plot(legend=False, grid=False,ax=ax, color='orange')

how data frame looks like. I am plotting the sum column

    1_1         1_2         2_1         2_2         sum
0   0.877666    2.323487    0.125786    0.751880    4.078818
1   2.305221    28.387401   96.747408   37.238366   164.678396
2   20.166748   47.587124   103.465928  48.781475   220.001274
3   20.434662   48.751884   103.662778  49.175176   222.024500
4   21.186542   49.503763   103.662778  49.175176   223.528260
... ... ... ... ... ...
1900    18.162730   0.367454    0.104987    0.000000    18.635171
1901    18.162730   0.367454    0.104987    0.000000    18.635171
1902    18.162730   0.367454    0.104987    0.000000    18.635171
1903    18.162730   0.367454    0.104987    0.000000    18.635171
1904    18.162730   0.367454    0.104987    0.000000    18.635171
1905 rows × 5 columns

How my plot looks like

0 Answers
Related