Data
Visualization: Data visualization basically refers to the
graphical or visual representation of information and data using visual
elements like charts, graphs, and maps etc. Data visualization is immensely
useful in decision making.
Data
visualization unveils pattern, trends, outlines, correlations etc. in the data,
and thereby helps decision makers understand the meaning of data to drive
business decision.
Using Pyplot
of Matplotlib Library: For data visualization in Python,
the Matplotlib library’s Pyplot interface is used.
The
matplotlib is a Python library that provides many interfaces and functionality
for 2D-graphics similar to MATLAB’s in various forms. You can call matplotlib as a high-quality
plotting library of Python. It provides both a very quick way to visualize data
from Python and publication-quality figure in many formats. The matplotlib
library offers many different named collections of methods; Pyplot is one such
interface.
Note: MATLAB is a high-performance language for
technical computing. It integrates computation, visualization, and programming
in an easy-to-use environment where problems and solutions are expressed in
familiar mathematical notation.
If you have installed Python using standard official
distribution, you may need to install matplotlib separately.
First you will need to download wheel package of
matplotlib as per Python’s version installed.
Next you need to install it by giving following
commands on the command prompt.
python -m pip install -U pip
python -m pip install -U matplotlib OR
Importing Pyplot: In order to
use Pyplot on your computers for data visualization, you need to first import
it in your Python environment by issuing one of the following commands:
import matplotlib.pyplotèThis would require you to refer to every command
of pyplot as matplotlib.pyplot.<command>
import matplotlib.pyplot as pltè with this,
you can refer to every command of pyplot as plt.<command> as you have
given an alias name to matplotlib.pyplot as plt
Note: You can
choose any legal identifier in place of plt.
Example
import numpy as np
import matplotlib.pyplot as plt
x=np.linspace(1,5,6)
y=np.log(x)
plt.plot(x,y)
plt.title('Plot Chart')
plt.show()
OUTPUT
Basics of Simple Plotting:
You can create many different types of graphs and chart using PyPlot.
Line Chart: A line chart
or line graph is a type of chart which displays information as a series of data
points called ‘markers’ connected by straight line segment.
Bar Chart: A bar chart
or bar graph is a chart or graph that presents categorical data with
rectangular bars with heights or lengths proportional to the values that they
represent. The bars can be plotted vertically as well as horizontally.
Scatter Plot: The scatter
plot is similar to line chart, the major difference is that while line graph
connects the data points with a line, scatter chart simply plots the data
points to show the trend in the data.
Example of Line Chart:
import numpy as np
import matplotlib.pyplot as plt
a = [1,2,3,4]
b = [2,4,6,8]
c = [1,4,9,16]
plt.xlabel("Some Values")
plt.ylabel("Double Values")
plt.plot(a,b)
plt.show()
OUTPUT
NOTE: This is the notes of chapter 3rd first part, soon I will upload the second part and who will complete the notes they will write their name in comment box.
very nice
ReplyDeleteExcellent .. Amazing .. I’ll bookmark your blog and take the feeds also…I’m happy to find so many useful info here in the post, we need work out more techniques in this regard, thanks for sharing. Villas
ReplyDelete