Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Group scatter plots
#1
Hi,
I have below data:

ID	    Group	  Time
LK0P1	Group1	  20
LK0P1	Group2	  15
LK0P1	Group3	  53
NA07U	Group1	  45
NA07U	Group2	  16
NA07U	Group3	  42
PM05R	Group1	  36
PM05R	Group2	  19
PM05R	Group3	  20
my x-axis is "ID", y-axis is "Time", I want to group them based on "Group"

sub_plot(0,0) Group1 data (Group1: x-axis ID, y-axis Time)
sub_plot(0,1) Group2 data (Group2: x-axis ID, y-axis Time)
sub_plot(1,0) Group3 data (Group3: x-axis ID, y-axis Time)
sub_plot(1,1) Group4 data (Group1: x-axis ID, y-axis Time)

I use below code but I am unable to group them, kindly some one help,



#%%
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
filepath = r'C:\PythonCodes\subplots.xlsx'
df = pd.read_excel(filepath)


fig, ax = plt.subplots(2, 2)
size_scaler = 300
ax[0,0].scatter(np.arange(len(df['ID'])), df['Time'], marker='o')
ax[0,0].xaxis.set_ticks(np.arange(len(df['ID'])))
ax[0,0].xaxis.set_ticklabels(df['ID'], rotation=90)

fig.text(0.5, -0.02, 'ID', ha='center', va='center')


fig.text(-0.02, 0.5, 'Time', ha='center', va='center', rotation='vertical')

plt.tight_layout()
plt.show()
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Multiple Plots in Spyder PythonAndMe2023 0 822 Feb-03-2023, 07:00 PM
Last Post: PythonAndMe2023
Shocked plt.scatter() errors asja2010 0 1,413 Oct-13-2022, 08:15 AM
Last Post: asja2010
  Subplot - Plotting 4 plots on the same row Menthix 1 1,392 Nov-07-2021, 09:03 PM
Last Post: deanhystad
  How to invert scatter plot axis Mark17 3 2,448 Sep-22-2021, 04:45 PM
Last Post: jefsummers
  Animated scatter plot maximan 0 1,616 Jan-18-2021, 03:53 PM
Last Post: maximan
  Sharing X Axis in Sub plots JoeDainton123 1 2,142 Aug-22-2020, 04:11 AM
Last Post: deanhystad
  Help With Sub Plots JoeDainton123 0 1,676 Aug-20-2020, 10:48 PM
Last Post: JoeDainton123
  how to nest loop for 4*4 scatter plot kassamohammed 0 2,545 Jun-23-2020, 09:47 AM
Last Post: kassamohammed
  How to create Custom Buttons for 3D Scatter plots in Plotly? yourboyjoe 0 2,104 Jun-01-2020, 10:58 PM
Last Post: yourboyjoe
  colorbar for scatter shows no negatives values... gil 0 1,514 Apr-15-2020, 12:45 AM
Last Post: gil

Forum Jump:

User Panel Messages

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