Group scatter plots - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Group scatter plots (/thread-28546.html) |
Group scatter plots - Mekala - Jul-23-2020 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 20my 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() |