Тёмный

Python 3D Plotting using matplotlib - Scatter Diagram for Data visualization and Data analysis 

Techlearners By Neeraj Saxena
Подписаться 15 тыс.
Просмотров 130
50% 1

#techlearners
Analysis of Run scoring Performance of a Cricket Batsman
based on Cricket ball speed and swing
Python Data Visualization using matplotlib
Scatter 3D Plotting
Prerequisites
1 python setup
2 installed numpy
pip install numpy
3 installed matplotlib
pip install matplotlib
Step 1 Create a python file scat3d.py
Step 2 import necessary libraries
import numpy as np
import matplotlib.pyplot as plt
Step 3 Create dataset
runs = np.array([6, 6, 4, 2, 1, 4, 6, 4, 2, 1, 6, 6, 4, 2, 1, 4, 6, 4, 2, 1, 6, 6, 4, 2, 1, 4, 6, 4, 2, 1, 6, 6, 4, 2, 1, 4, 6, 4, 2, 1])
speed = np.array([130, 132, 140, 150, 152, 142, 135, 132, 153, 140, 135, 134, 144, 156, 158, 146, 138, 139, 157, 146, 133, 134, 143, 152, 154, 140, 136, 131, 151, 144, 139, 133, 140, 150, 152, 142, 135, 130, 150, 145])
swing = np.array([1, 1, 3, 4, 5, 2, 1, 2, 3, 5, 2, 2, 4, 3, 4, 5, 2, 1, 2, 4, 1, 1, 3, 4, 5, 2, 1, 2, 3, 5, 2, 2, 4, 3, 4, 5, 1, 2, 1, 5])
Step 4 Create figure
fig = plt.figure(figsize = (12, 6))
Step 5 Set projection
ax = plt.axes(projection ="3d")
Step 6 Create grid
ax.grid(b = True, color ='black',
linestyle ='-.', linewidth = 0.5,
alpha = 0.2)
Step 7 Create colormap
my_cmap = plt.get_cmap('hsv')
Step 8 Create Scatter 3D Plot
sctt = ax.scatter3D(speed, swing, runs,
alpha = 0.9,
c = (runs + speed + swing),
cmap = my_cmap,
marker ='^',
)
Step 9 Set title and Labels of plot
plt.title("Analysis of run scoring performance in Cricket Match based on ball speed and swing")
ax.set_xlabel('Speed of Cricket Ball in KMPH', fontweight ='bold')
ax.set_ylabel('Swing of Cricket Ball', fontweight ='bold')
ax.set_zlabel('Runs Scored by batsman', fontweight ='bold')
Step 10 Set colorbar
fig.colorbar(sctt, ax = ax)
Step 11 Show plot
plt.show()
TECHLEARNERS BY NEERAJ SAXENA
www.techlearners.co.in

Опубликовано:

 

1 май 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии    
Далее
install python on windows
0:41
Просмотров 127
7 Python Data Visualization Libraries in 15 minutes
15:03
УРА! Я КУПИЛ МЕЧТУ 😃
00:11
Просмотров 739 тыс.
Seaborn Is The Easier Matplotlib
22:39
Просмотров 165 тыс.
The moment we stopped understanding AI [AlexNet]
17:38
Просмотров 785 тыс.
Is Plotly The Better Matplotlib?
22:58
Просмотров 95 тыс.
Three Best AI tools for Data Analysis
15:39
Просмотров 26 тыс.