1. LPU MCA Semester 1
  2. CAB107
  3. Unit 3

CAB107 · Unit 3: Data collection, preprocessing and visualization

Visualization with Matplotlib, Seaborn and interactive dashboards with Plotly

10 practice questions · in the MTE and ETE syllabus

Key points

  • Plotly gives interactive charts; Dash uses callbacks
  • Box plots show median, quartiles and outliers
  • Heatmap of df.corr() shows pairwise correlations
  • Truncated bar-chart axes mislead readers

Matplotlib is the base plotting library for static charts. Seaborn builds statistical plots on top of it with nicer defaults. Plotly produces interactive charts with hover, zoom and pan, and Dash is the Python framework for dashboards in which a callback runs a Python function when an input component changes and updates an output component.

QuestionChart
Change over timeLine chart
Distribution of one variableHistogram or box plot
Relationship of two variablesScatter plot
Correlation between many variablesHeatmap
Compare categoriesBar chart

A box plot summarises the median, quartiles and potential outliers; points beyond 1.5 IQR from the box are drawn individually.

import seaborn as sns
import matplotlib.pyplot as plt
sns.heatmap(df.corr(), annot=True)
plt.show()

This draws a colour-coded matrix of pairwise correlations with the values written in the cells.

A scatter plot of a million points can look like a solid blob; reduce marker opacity or use a hexbin or density plot instead.

Exam trap: a bar chart whose y-axis does not start at zero exaggerates differences, because bar length no longer represents the full value.

Try two questions

Question 1 · Tier 2, Understand

Which chart is the best choice for showing the relationship between two numeric variables?

  1. A scatter plot
  2. A pie chart
  3. A word cloud
  4. A stacked bar of categories
Show the answer

A. A scatter plot shows one point per pair and reveals trend and spread.

Why not B: A pie chart shows shares of a whole.

Why not C: A word cloud shows word frequency.

Why not D: Stacked bars summarise categories, not point pairs.

Question 2 · Tier 4, Analyse

A bar chart compares sales of 97 and 99 units but the y-axis starts at 96. What is the effect?

  1. The difference looks far larger than it is, which misleads the reader
  2. The chart becomes more accurate because it zooms in on the differences
  3. The chart shows the median of each category instead of the total number of units
  4. The chart permanently changes the sales data that is stored in the file
Show the answer

A. Bar charts should start at zero because length encodes the value.

Why not B: Bar length no longer represents the full value, so the zoom distorts perception.

Why not C: The axis choice does not change what is plotted.

Why not D: Plot settings do not alter the stored data.