- LPU MCA Semester 1
- CAB107
- 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.
| Question | Chart |
|---|---|
| Change over time | Line chart |
| Distribution of one variable | Histogram or box plot |
| Relationship of two variables | Scatter plot |
| Correlation between many variables | Heatmap |
| Compare categories | Bar 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
Which chart is the best choice for showing the relationship between two numeric variables?
- A scatter plot
- A pie chart
- A word cloud
- 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.
A bar chart compares sales of 97 and 99 units but the y-axis starts at 96. What is the effect?
- The difference looks far larger than it is, which misleads the reader
- The chart becomes more accurate because it zooms in on the differences
- The chart shows the median of each category instead of the total number of units
- 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.