
Data visualization refers to the exploration of data through visual representation, which is closely related to data mining. Data mining refers to the use of code to explore the patterns and correlations of a dataset, which can be a small list of numbers represented by a single line of code or several bytes of data. One of the most popular tools in Python currently is matplotlib, which is a mathematical drawing library. We also use the Pygal package, which focuses on generating charts suitable for display on digital devices.
1. Install matplotlib and the necessary numpy libraries to run it .
NumPy (Numerical Python) is an extension library of the Python language that supports a large number of dimensional arrays and matrix operations. In addition, it also provides a large number of mathematical function libraries for array operations.
pip install matplotlib
pip install numpy
Note: Using the pip command on Linux:
yum install epel-release
yum install python-pip
Using pip (installed) under Windows:
my computer- > system properties- > advanced- > environmental variables- >PATH write it down later pip path of
2. Usage: .
To view various charts that can be created using matplotlib, please visit https://matplotlib.org/ For example galleries, you can view the code used to generate charts in a standalone gallery.
2-1. Example: .
Draw a simple line chart with only four lines of code:
import matplotlib.pyplot as plt
squares = [1, 4, 9, 16, 25]
plt.plot(squares)
plt.show()
Result:

2-2. Example: .
Import and register 3D projection:
import matplotlib.pyplot as plt
from matplotlib import cm
from matplotlib.ticker import LinearLocator, FormatStrFormatter
import numpy as np
from mpl_toolkits.mplot3d import Axes3D
fig = plt.figure()
ax = fig.gca(projection='3d')
#create data
X = np.arange(-5, 5, 0.25)
Y = np.arange(-5, 5, 0.25)
X, Y = np.meshgrid(X, Y)
R = np.sqrt(X ** 2 + Y ** 2)
Z = np.sin(R)
#draw table
surf = ax.plot_surface(X, Y, Z, cmap=cm.coolwarm,
linewidth=0, antialiased=False)
#custom z axis
ax.set_zlim(-1.01, 1.01)
ax.zaxis.set_major_locator(LinearLocator(10))
ax.zaxis.set_major_formatter(FormatStrFormatter('%.02f'))
#add a color bar that maps values to colors
fig.colorbar(surf, shrink=0.5, aspect=5)
plt.show()
Result:

For more examples, please refer to: https://matplotlib.org/.