MSK Institute LogoMSK.Institute
HomeCourses
Book Free Demo➔Sign In
Free Demo➔
MSK Institute LogoMSK.Institute

Leading computer training academy in Shikohabad for software engineering, Python, web development, and digital literacy.

ISO 9001:2015 Certified Center
Follow & Connect
4.9

Programs & Admissions

  • All CoursesCatalog
  • Learning PathsRoadmaps
  • Student ProjectsShowcase
  • Live Classes & ScheduleLive
  • Upcoming Batches
  • Campuses & LocationsHub
  • Verify Certificates
  • Book Free Demo Class

Resources & Tools

  • Free Online Mock TestsAll Tests
  • NIELIT CCC Mock TestFree
  • Course & Career FinderQuiz
  • Study Material Hub
  • All MSK ToolsHub
  • Keyboard ShortcutsNew
  • TypeQuest Speed LabTyping
  • MSK Code PlaygroundCode
  • Interactive Tutorials
  • Quick Cheatsheets

Institute & Contact

  • About MSK Institute
  • Careers & InternshipsHiring
  • Publications & Blogs
  • Gali No. 3, Near Gyan Jyoti Public School,
    Adarsh Nagar, Shikohabad, Uttar Pradesh 283135
  • +91 83930 42166
  • mskshikohabad@gmail.com
  • Hours:Mon – Sat: 8:00 AM – 7:00 PM | Sun: 10:00 AM – 2:00 PM
  • 4.9 ★(38 Google Reviews)
© 2026 MSK Institute. All rights reserved.•Privacy Policy•Terms of Service•Disclaimer•Contact Us

Shikohabad's Leading Computer & Coding Academy

Home
Courses
Live
Material
Setting Up Python Plotting: Jupyter Inline, figsize, DPI & Themes0%
Study MaterialsCheatsheet
Data Visualization & Applied StatisticsProgress 0%
1.1Why Data Visualization Matters in Decision Making1.2Python Visualization Landscape: Matplotlib vs Seaborn vs Plotly1.3Setting Up Jupyter, Inline Plotting & Figure Sizing
HomeTutorialsData Visualization & Applied StatisticsSetting Up Python Plotting: Jupyter Inline, figsize, DPI & Themes
Matplotlib Anatomy: Figure, Axes, Subplots & Ticks

Setting Up Python Plotting: Jupyter Inline, figsize, DPI & Themes

Intermediate9 min read•Updated: 2026-11-18•By Er. Sumit Kumar (MSK Institute)
Study MaterialsCheatsheet

A professional Python visualization setup configures inline notebook rendering (%matplotlib inline), clean global themes (sns.set_theme()), explicit figure dimensions in inches (figsize=(width, height)), high resolution (dpi=300), and automatic margin spacing (plt.tight_layout()).

Leaving Matplotlib at its tiny default 6.4 × 4.8 inch canvas at 100 DPI produces blurry charts with overlapping axis labels. Setting a reusable styling header at the top of every notebook makes your visual analysis look presentation-ready from the very first plot.


1. Standard Visualization Boilerplate (Jupyter & VS Code)

1import matplotlib.pyplot as plt
2import seaborn as sns
3import pandas as pd
4import numpy as np
5 
6# Render charts directly below code cells in Jupyter Notebooks
7%matplotlib inline
8 
9# Crisp high-DPI rendering on modern displays
10%config InlineBackend.figure_format = 'retina'
11 
12# Apply clean global styling across Seaborn and Matplotlib
13sns.set_theme(style='whitegrid', context='notebook')
14plt.rcParams['font.sans-serif'] = 'DejaVu Sans'
15plt.rcParams['axes.titlesize'] = 14
16plt.rcParams['axes.labelsize'] = 11

Popular sns.set_theme(style=...) Presets

  • whitegrid → Best for numerical comparisons and bar/line charts with light reference gridlines.
  • ticks → Clean minimalist look ideal for scatter plots and academic publications.
  • darkgrid → Subtle shaded canvas useful for multi-series trend comparisons.

2. Controlling figsize, DPI & Preventing Clipped Labels

In Matplotlib, figsize=(width, height) is always measured in inches (not pixels). Total pixel resolution equals inches × dpi (for example, figsize=(10, 6) at dpi=300 exports a razor-sharp 3000 × 1800 pixel graphic).

1months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun']
2revenue = [120, 145, 160, 152, 188, 210]
3 
4fig, ax = plt.subplots(figsize=(10, 6), dpi=150)
5ax.plot(months, revenue, marker='o', linewidth=2.5, color='#0A2540')
6ax.set_title('Monthly Revenue Growth (₹ Thousands)')
7ax.set_xlabel('Month (2026)')
8ax.set_ylabel('Revenue (₹K)')
9 
10# Automatically adjust margins so titles and tick labels never overlap or clip
11plt.tight_layout()
12 
13# Save publication-ready 300 DPI PNG for reports & GitHub READMEs
14fig.savefig('monthly_revenue.png', dpi=300, bbox_inches='tight')
15plt.show()
Note
Pro Tip: Always call fig.savefig(..., dpi=300, bbox_inches='tight') before plt.show(), because plt.show() clears the active figure buffer in many notebook environments!

Interactive Quiz• Knowledge Check

Practice Quiz

Question 1
In Jupyter Notebooks, what magic command ensures that generated plots are displayed directly beneath the code cell?
Question 2
In plt.subplots(figsize=(12, 6)), what units do the numbers 12 and 6 represent?
Question 3
What does setting dpi=300 achieve when creating or saving a figure?
Question 4
Which function sets the global visual aesthetic theme across all Seaborn and Matplotlib plots?
Question 5
What does plt.tight_layout() do?
Next Lesson

Matplotlib Anatomy: Figure, Axes, Subplots & Ticks

Continue learning with hands-on practice, examples, and exercises in the upcoming topic.

Related Lessons

Previous LessonNext Lesson
Python Visualization Landscape: Matplotlib vs Seaborn vs PlotlyMatplotlib Anatomy: Figure, Axes, Subplots & Ticks

Practice Quiz

Test your understanding of this lesson with 5 questions. Each question has one correct answer.

12-Month Data Analysis Mastery Program

Master Full-Stack Data Analytics (Excel, SQL, Python, Power BI & Tableau)

Combine 15 complete courses, 150 chapters, 541 topics, live SQL/Power BI/Tableau dashboards, and Scikit-Learn capstones at MSK Institute Shikohabad or Live Online.

View Full CourseBook Free Demo
PreviousNext
PreviousPrevNext