Data Visualisation using Python - Revision Notes

 CBSE Class 12 Computer Science (Python)

Data Visualization using Python
Revision Notes


  • Some important Points in Data Visualization are:
  • Data visualization basically refers to the graphical or visual representation of information and data using visual elements like charts, graphs, and maps etc.
  • The matplotlib is a Python library that provides many interfaces and functionality for 2D-graphics similar to MATLAB's in various forms.
  • Pyplot is a collection of methods within matplotlib which allow user to construct 2D plots easily and interactively. PyPlot essentially reproduces plotting functions and behavior of MATLAB.
  • In order to use pyplot on your computers for data visualization, you need to first import it in your Python environment by issuing import command for matplotlib.pyplot.
  • NumPy is a Python library that offer many functions for creating and manipulating arrays, which come handy while plotting.
  • You need to import 'numpy' before using any of its functions.
  • Numpy arrays are also called 'ndarrays'.
  • Some commonly used chart types are line chart, bar chart, pie chart, scatter chart etc.
  • 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 segments.
  • You can create line charts by using pyplot's plot() function.
  • You can change line color, width, line-style, marker-type, marker-color, marker-size in plot() function.
  • Possible line styles are: solid for solid line, dashed for dashed line, dotted for dotted line and dashdot for dashdotted line.
  • Bar Graph/Chart is a graphical display of data using bars of different heights.
  • You can create bar chart using pyplot's bar() function.
  • You can change colors of the bars, widths of the bars in bar() function.
  • Use barh() function to create a horizontal bar chart.
  • The pie chart is a type of graph in which a circle is divided into sectors that each represent a proportion of the whole.
  • You can create a pie chart using pie( ) function. The pie( ) chart plots a single data range.
  • By default, the pie chart is oval in shape but you can change to circular shape by giving command <matplotlib.pyplot>.axis("equal”).
  • The plot area is known as figure and every other element of chart is contained in it.
  • The axes can be labelled using xlabel() and ylabel() functions.
  • The limits of axes can be defined using xlim() and ylim() functions.
  • The tick marks for axes values can be defined using xticks() and yticks() functions.
  • The title() function adds title to the plot.
  • Using legend() function, one can add legends to a plot where multiple data ranges have been plotted, but before that the data ranges must have their label argument defined in plot() or bar() function.
  • The loc argument of legend() provides the location for legend, which by default is 1 or upper right.