Matplotlib Tutorial-Part2

Histogram

import random
import matplotlib.pyplot as plt


#Generate 100 random numbers between 0 and 100
population_age = random.sample(range(-1, 101), 100)
print(randomlist)

bins = [0,10,20,30,40,50,60,70,80,90,100]
plt.hist(population_age, bins, histtype='bar', color='skyblue' , rwidth=0.8)
plt.xlabel('Age Groups')
plt.ylabel('Number of people')
plt.title('Histogram')
plt.show()

Scatter Plot

import matplotlib.pyplot as plt
import pandas as pd

df = pd.read_csv('AmesHousing.csv')

fig, ax = plt.subplots(figsize=(10, 6))
ax.scatter(x = df['Gr Liv Area'], y = df['SalePrice'])
plt.xlabel("Living Area Above Ground")
plt.ylabel("House Price")

plt.show()

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Data Acquisition: All High Schools in Belgium

8 Data Science Side Projects for 2022

Data Science Project: Looking for hidden insights in my 2 thousand chess games

Why Use K-Means for Time Series Data? (Part Three)

Big Data in AWS

How to make life easy for a newly hired data scientist

Decoding the Data Science Buzzwords

Supervised Learning — K Nearest Neighbors Algorithm (KNN)

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Htoo Latt

Htoo Latt

More from Medium

6 examples of Python list append method

Things inside JVM…..

Trigonometry Topics

The Compilation Process in the C Language