Python Matplotlib

Veröffentlicht am: 21 Juli 2024
auf dem Kanal: Tech - Jroshan
878
like

#Python #Matplotlib For #DataVisualization

Plot Types Matplotlib supports various plot types:-✈️

❌ Line plots: plt.plot()

❌ Scatter plots: plt.scatter()

❌ Bar plots: plt.bar()

❌ Histograms: plt.hist()

❌ Box plots: plt.boxplot()

❌ Pie charts: plt.pie()

Here I have Share My experience to explain the different plot types supported by Matplotlib.

~~ Line plots (plt.plot())
Line plots are used to display data points connected by straight lines. They're ideal for showing trends over time or continuous data.

import matplotlib.pyplot as plt
x = [1, 2, 3, 4, 5]
y = [2, 4, 6, 8, 10]
plt.plot(x, y)
plt.show()

~~ Scatter plots (plt.scatter())
Scatter plots display individual data points as markers on a 2D plane. They're useful for showing the relationship between two variables.
x = [1, 2, 3, 4, 5]
y = [2, 4, 6, 8, 10]
plt.scatter(x, y)
plt.show()

~~Bar plots (plt.bar())
Bar plots use rectangular bars to represent data. They're commonly used to compare quantities across different categories.
categories = ['A', 'B', 'C', 'D']
values = [3, 7, 2, 5]
plt.bar(categories, values)
plt.show()

~~ Histograms (plt.hist())
Histograms represent the distribution of numerical data. They divide the data into bins and show the frequency of data points in each bin.
import numpy as np
data = np.random.randn(1000)
plt.hist(data, bins=30)
plt.show()

~~ Box plots (plt.boxplot())
Box plots, also known as box-and-whisker plots, display the distribution of data based on five summary statistics: minimum, first quartile, median, third quartile, and maximum.

data = [np.random.normal(0, std, 100) for std in range(1, 4)]
plt.boxplot(data)
plt.show()

~~ Pie charts (plt.pie()):
Pie charts represent data as slices of a circular graph, where each slice's size corresponds to its proportion of the whole.
sizes = [35, 30, 20, 15]
labels = ['A', 'B', 'C', 'D']
plt.pie(sizes, labels=labels)
plt.show()


Auf dieser Seite können Sie das Online-Video Python Matplotlib mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer Tech - Jroshan 21 Juli 2024 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 878 Mal angesehen und es wurde von like den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!