← جميع الاختبارات العامة
ابدأ الاختبار (كضيف أو بحساب)
Python — Data visualization (Matplotlib, Seaborn, Plotly)
بواسطة Jude · 23/05/2026 · 116 مشاهدة · مشاركة
Figure anatomy, choosing the right chart, scales, palettes, Pandas integration. 20 questions.
20
الأسئلة
🇬🇧 English
اللغة
متوسط
الصعوبة
أسئلة الاختبار
-
1. Difference between
FigureandAxesin Matplotlib?- None
Figureis the container;Axesis an individual plotting area with its own scales/ticksAxescontains theFigureFigureis deprecated
-
2. Recommended way to create two side-by-side subplots?
fig, (ax1, ax2) = plt.subplots(1, 2)plt.figure(); plt.figure()plt.subplot()twice with no argsplt.draw(2)
-
3. Best chart to compare the distribution of a continuous variable across groups?
- Pie chart
- Boxplot or violin plot
- Stacked bar chart
- 3D histogram
-
4. Which chart is generally discouraged for comparing proportions across >4–5 categories?
- Bar chart
- Lollipop chart
- Pie chart
- Treemap
-
5. Best chart to visualize the correlation between two continuous variables?
- Scatter plot
- Bar chart
- Pie chart
- Frequency heatmap
-
6. How do you display a Matplotlib figure in a regular script?
plt.show()plt.render()plt.display()- It auto-displays
-
7. What does this do?
import matplotlib.pyplot as plt fig, ax = plt.subplots() ax.plot([1, 2, 3], [1, 4, 9]) ax.set_yscale('log')- Logarithmic Y axis
- Error
- Logarithmic X axis
- Bar chart
-
8. Why save as
.svgor.pdfinstead of.png?- Smaller files
- Vector format: stays crisp at any zoom (print, high-DPI screens)
- No benefit
- PNG lacks color support
-
9. What does
plt.tight_layout()do?- Toggles fullscreen
- Auto-adjusts margins to prevent label/title overlap
- Removes axes
- Forces a square figure
-
10. Which library produces interactive, web-ready charts (D3/WebGL-based)?
- Matplotlib
- Seaborn
- Plotly
- Pandas plotting
-
11. Main advantage of Seaborn over raw Matplotlib?
- Faster
- High-level API for statistical plots + native Pandas integration + polished defaults
- Replaces Matplotlib
- Generates interactive PDFs
-
12. Which palette family suits unordered categories?
- Sequential (viridis, plasma)
- Diverging (coolwarm)
- Qualitative (tab10, Set2)
- Cyclic
-
13. Which palette fits continuous data with a meaningful midpoint (e.g., anomalies ±)?
- Sequential (viridis)
- Diverging (RdBu, coolwarm)
- Qualitative (tab20)
- Grayscale
-
14. Why prefer
viridisoverjet?- Personal taste
viridisis perceptually uniform and colorblind-friendly;jetintroduces artifacts and false bandingjetis more colorfulviridisdoes not exist
-
15. How do you plot a Pandas Series directly?
s.plot()plot(s)pd.show(s)- Not possible without Matplotlib
-
16. What does this produce?
import seaborn as sns import pandas as pd df = pd.DataFrame({'x': [1,2,3,4], 'y': [2,4,1,8], 'g': ['a','a','b','b']}) sns.scatterplot(data=df, x='x', y='y', hue='g')- Scatter plot colored by group
g - Histogram
- Error:
huemust be numeric - Boxplot
- Scatter plot colored by group
-
17. Why are titles, axis labels (with units), and legends essential?
- Decoration only
- They provide context, units, and meaning of colors/markers — required for readability
- They slow rendering
- Paper-only
-
18. How do you avoid chartjunk?
- Add more colors and 3D effects
- Maximize the data-to-ink ratio: remove frames, backgrounds, and unnecessary effects (Tufte)
- Use background images
- Animate every element
-
19. What's the issue with a bar chart whose Y axis doesn't start at 0?
- Nothing
- It visually exaggerates differences and can mislead readers — avoid for bars (acceptable for line charts with clear annotation)
- Improves precision
- Breaks PNG export
-
20. Which Python library implements the grammar of graphics (ggplot-style)?
- Plotnine
- Seaborn only
- Matplotlib low-level
- Pandas