This is my dataframe looks like : click on line to download dataframe
I have tried following code :
plt.plot(LessDF['DeptAvg'] == 'COA111', LessDF['week1'])
plt.plot(LessDF['DeptAvg'] == 'COA111', LessDF['week2'])
plt.plot(LessDF['DeptAvg'] == 'COA111', LessDF['week3'])
I got output with my code :
I want output like this :
how can i get this output with matplotlib or seaborn??
CodePudding user response:
All your values in the DeptAvg column are 67 for the filter you applied.
Also, you are providing a boolean as your x: LessDF['DeptAvg'] == 'COA111'
.
Also, you are applying the condition on the wrong column DeptAvg
instead of classes
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
df = pd.read_csv('../../../Desktop/LessDF.csv')
df_filtered = df[df['classes'] == 'COA111' ]
plt.plot(df_filtered['week1'],df_filtered['DeptAvg'],alpha=.5,)
plt.plot(df_filtered['week2'],df_filtered['DeptAvg'],alpha=.5)
plt.plot(df_filtered['week3'],df_filtered['DeptAvg'],alpha=.5)
plt.legend(['week1','week2','week3'])
plt.show()
more info here
CodePudding user response:
# I done this using seaborn you can use matplotlib in between to code
plt.figure(figsize=(16, 16))
plt.subplot(no_of_rows, no_of_columns, plot_num)
plt.title('Any title 1')
sns.boxplot(df['column_name'])
Example :- we want 2 rows with columns of plots then we use
plt.subplot(2, 2, 1)
plt.title('Any title 1')
sns.distplot(df['column_name'], bins=20)
plt.subplot(2, 2, 2)
plt.title('Any title 2')
sns.distplot(df['column_name'], bins=20)
plt.subplot(2, 2, 3)
plt.title('Any title 3')
sns.distplot(df['column_name'], bins=20)
plt.subplot(2, 2, 4)
plt.title('Any title 4')
sns.distplot(df['column_name'], bins=20)
plt.show()