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 several graphs in one plot Ferdiss 1 179 Apr-11-2024, 08:37 PM
Last Post: deanhystad
  Plot function Sedos101 3 773 Aug-23-2023, 02:53 PM
Last Post: deanhystad
  Likert survey data plot error Andrzej_Andrzej 6 1,399 Jul-16-2023, 10:11 PM
Last Post: deanhystad
  Error when animating 3D plot Tee 4 930 Jul-03-2023, 08:49 PM
Last Post: Tee
  Plot multiple 2D Curves in 3D stc 5 945 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 842 May-29-2023, 02:42 PM
Last Post: Nietzsche
  first time use plot - I get empty graph korenron 6 2,074 Feb-04-2023, 02:14 PM
Last Post: deanhystad
  Create simple live plot of stock data dram 2 2,913 Jan-27-2023, 04:34 AM
Last Post: CucumberNox
Thumbs Up Python 3 Jupyter notebook ternary plot data nicholas 0 930 Jan-21-2023, 05:01 PM
Last Post: nicholas
  For Loop: To see plot for different columns JaneTan 0 960 Dec-14-2022, 05:55 AM
Last Post: JaneTan

Forum Jump:

User Panel Messages

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