Python Forum
How to plot vertically stacked plot with same x-axis and
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to plot vertically stacked plot with same x-axis and
#1
Hi,

I have below data:

Inputdata.csv:

Name   Date      y1   y2  y3
VAB    20190601  1    0   0
VAB    20190603  1    1   0
VLKA   20190604  0    0   1
MAKY   20190604  1    1   1
VAB    20190605  1    0   0
VAB    20190606  1    1   1
MAKY   20190609  0    1   1
I want group by name and plot Date Vs. y1,y2,y2 (y1, y2, y3 are in vertically stacked)

import pandas as pd
input=r'D:\PythonCodes\Inputdata.csv'

df=pd.read_csv(input)
x=df['Date']
y1=df['y1']
y2=df['y2']
y3=df['y3']

fig, axs = plt.subplots(3, sharex=True, sharey=True)
fig.suptitle('Sharing both axes')
axs[0].plot(x, y1)
axs[1].plot(x, y2, 'o')
axs[2].plot(x, y3, '+')
But I want to group the chart automatically based on "Name", and plot in vertically stacked plots.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Plot function Sedos101 3 726 Aug-23-2023, 02:53 PM
Last Post: deanhystad
  Likert survey data plot error Andrzej_Andrzej 6 1,303 Jul-16-2023, 10:11 PM
Last Post: deanhystad
  Error when animating 3D plot Tee 4 861 Jul-03-2023, 08:49 PM
Last Post: Tee
  Plot multiple 2D Curves in 3D stc 5 892 Jun-11-2023, 05:48 PM
Last Post: snippsat
  Plot a pandas data fram via pyqtgraph with an modul import and qt designer widget Nietzsche 0 801 May-29-2023, 02:42 PM
Last Post: Nietzsche
  first time use plot - I get empty graph korenron 6 1,958 Feb-04-2023, 02:14 PM
Last Post: deanhystad
  Create simple live plot of stock data dram 2 2,856 Jan-27-2023, 04:34 AM
Last Post: CucumberNox
Thumbs Up Python 3 Jupyter notebook ternary plot data nicholas 0 894 Jan-21-2023, 05:01 PM
Last Post: nicholas
  For Loop: To see plot for different columns JaneTan 0 937 Dec-14-2022, 05:55 AM
Last Post: JaneTan
  Trying to loop through code to plot seaborn line plots across multiple subplots eyavuz21 0 1,573 Dec-05-2022, 10:46 AM
Last Post: eyavuz21

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020