Python Matplotlib

Pubblicato il: 21 luglio 2024
sul canale di: 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()


In questa pagina del sito puoi guardare il video online Python Matplotlib della durata di ore minuti seconda in buona qualità , che l'utente ha caricato Tech - Jroshan 21 luglio 2024, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 878 volte e gli è piaciuto like spettatori. Buona visione!