Skip to content

Commit 94e1f11

Browse files
authored
Merge pull request animator#727 from Harshita297/main
Introducing Matplotlib
2 parents 31eaf99 + 358d8b0 commit 94e1f11

File tree

5 files changed

+81
-0
lines changed

5 files changed

+81
-0
lines changed
Loading
Loading
Loading
+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# List of sections
22

33
- [Installing Matplotlib](matplotlib-installation.md)
4+
- [Introducing Matplotlib](matplotlib-introduction.md)
45
- [Bar Plots in Matplotlib](matplotlib-bar-plots.md)
56
- [Pie Charts in Matplotlib](matplotlib-pie-charts.md)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# Introducing MatplotLib
2+
3+
Data visualisation is the analysing and understanding the data via graphical representation of the data by the means of pie charts, histograms, scatterplots and line graphs.
4+
5+
To make this process of data visualization easier and clearer, matplotlib library is used.
6+
7+
## Features of MatplotLib library
8+
- MatplotLib library is one of the most popular python packages for 2D representation of data
9+
- Combination of matplotlib and numpy is used for easier computations and visualization of large arrays and data. Matplotlib along with NumPy can be considered as the open source equivalent of MATLAB.
10+
11+
- Matplotlib has a procedural interface named the Pylab, which is designed to resemble MATLAB. However, it is completely independent of Matlab.
12+
13+
## Starting with Matplotlib
14+
15+
### 1. Install and import the neccasary libraries - mayplotlib.pylplot
16+
17+
```bash
18+
pip install matplotlib
19+
```
20+
21+
```python
22+
import maptplotlib.pyplot as plt
23+
import numpy as np
24+
```
25+
26+
### 2. Scatter plot
27+
Scatter plot is a type of plot that uses the cartesian coordinates between x and y to describe the relation between them. It uses dots to represent relation between the data variables of the data set.
28+
29+
```python
30+
x = [5,4,5,8,9,8,6,7,3,2]
31+
y = [9,1,7,3,5,7,6,1,2,8]
32+
33+
plt.scatter(x,y, color = "red")
34+
35+
plt.title("Scatter plot")
36+
plt.xlabel("X values")
37+
plt.ylabel("Y values")
38+
39+
plt.tight_layout()
40+
plt.show()
41+
```
42+
43+
![scatterplot](images/scatterplot.png)
44+
45+
### 3. Bar plot
46+
Bar plot is a type of plot that plots the frequency distrubution of the categorical variables. Each entity of the categoric variable is represented as a bar. The size of the bar represents its numeric value.
47+
48+
```python
49+
x = np.array(['A','B','C','D'])
50+
y = np.array([42,50,15,35])
51+
52+
plt.bar(x,y,color = "red")
53+
54+
plt.title("Bar plot")
55+
plt.xlabel("X values")
56+
plt.ylabel("Y values")
57+
58+
plt.show()
59+
```
60+
61+
![barplot](images/barplot.png)
62+
63+
### 4. Histogram
64+
Histogram is the representation of frequency distribution of qualitative data. The height of each rectangle defines the amount, or how often that variable appears.
65+
66+
```python
67+
x = [9,1,7,3,5,7,6,1,2,8]
68+
69+
plt.hist(x, color = "red", edgecolor= "white", bins =5)
70+
71+
plt.title("Histogram")
72+
plt.xlabel("X values")
73+
plt.ylabel("Frequency Distribution")
74+
75+
plt.show()
76+
```
77+
78+
![histogram](images/histogram.png)
79+
80+

0 commit comments

Comments
 (0)