Histogram Plot in Seaborn

Machine Learning courses with 100+ Real-time projects Start Now!!

Program 1

import seaborn as sns
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np

# Example DataFrame
df = pd.DataFrame({"marks": np.random.randint(40, 100, size=200)})
#print(df['marks'])
sns.histplot(df['marks'], bins=10, kde=True, color='orange')
plt.title("Student Marks Distribution")
plt.xlabel("Marks")
plt.ylabel("Number of Students")
plt.show()

Program 2

import seaborn as sns
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
# Sample data
df = sns.load_dataset('tips')  # Built-in dataset

# print(df.head())

# print(df.isnull().sum())
# print(df.shape)
#print(df.info())

#Create histogram
# sns.histplot(df['total_bill'], bins=10, kde=True, color='skyblue')
sns.histplot(df['tip'], bins=10, kde=True, color='skyblue')
# # Add title and labels
# plt.title('Distribution of Total Bill')
# plt.xlabel('Total Bill')
# plt.ylabel('Frequency')

# # Show plot
plt.show()


#df_tips=pd.read_csv("D://scikit_data/Billing/tips.csv")

 

 

If you are Happy with DataFlair, do not forget to make us happy with your positive feedback on Google

courses

DataFlair Team

DataFlair Team provides high-impact content on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. We make complex concepts easy to grasp, helping learners of all levels succeed in their tech careers.

Leave a Reply

Your email address will not be published. Required fields are marked *