TGViewer
Data Science & Machine Learning Data Science & Machine Learning @datasciencefun · 77.8K subscribers
Post #3837 6.68K
✅ Python for Data Science – Part 3: Matplotlib & Seaborn Interview Q&A 📈🎨

1. What is Matplotlib?
A 2D plotting library for creating static, animated, and interactive visualizations in Python. It's the foundation for most data viz in Python, with full customization control.

2. How to create a basic line plot in Matplotlib?
import matplotlib.pyplot as plt  
plt.plot([1, 2, 3], [4, 5, 6])
plt.show()


3. What is Seaborn and how is it different?
Seaborn is built on top of Matplotlib and makes complex plots simpler with better aesthetics. It integrates well with Pandas DataFrames, offering high-level functions for statistical viz like heatmaps or violin plots—less code, prettier defaults than raw Matplotlib.

4. How to create a bar plot with Seaborn?
import seaborn as sns  
sns.barplot(x='category', y='value', data=df)


5. How to customize plot titles, labels, legends?
plt.title('Sales Over Time')  
plt.xlabel('Month')
plt.ylabel('Sales')
plt.legend()


6. What is a heatmap and when do you use it?
A heatmap visualizes matrix-like data using colors. Often used for correlation matrices.
sns.heatmap(df.corr(), annot=True)


7. How to plot multiple plots in one figure?
plt.subplot(1, 2, 1)  # 1 row, 2 cols, plot 1  
plt.plot(data1)
plt.subplot(1, 2, 2)
plt.plot(data2)
plt.show()


8. How to save a plot as an image file?
plt.savefig('plot.png')

9. When to use boxplot vs violinplot?
⦁ Boxplot: Summary of distribution (median, IQR) for quick outliers.
⦁ Violinplot: Adds distribution shape (kernel density) for richer insights into data spread.

10. How to set plot style in Seaborn?
sns.set_style("whitegrid")

Double Tap ❤️ For More!
  • ❤ 6
  • 👏 1
More from @datasciencefun
  1. Oct 17, 2026𝗜𝗕𝗠 𝗙𝗥𝗘𝗘 𝗧𝗘𝗖𝗛 𝗖𝗢𝗨𝗥𝗦𝗘𝗦 𝟮𝟬𝟮𝟲! 🎓 Explore IBM Cognitive Class and build…
  2. Oct 16, 2026𝗗𝗮𝘁𝗮 𝘀𝗰𝗶𝗲𝗻𝗰𝗲 𝗖𝗲𝗿𝘁𝗶𝗳𝗶𝗰𝗮𝘁𝗶𝗼𝗻 𝗪𝗶𝘁𝗵 𝗔𝗜😍 Future Ready Data Scien…
  3. Oct 15, 2026Post #4665
  4. Oct 15, 2026Post #4664
  5. Oct 15, 2026Post #4663
  6. Oct 15, 2026Post #4662
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →