Style Plots using Matplotlib Last Updated : 23 Jul, 2025 Comments Improve Suggest changes Like Article Like Report By using style function in Matplotlib we can apply predefined themes or create custom styles which helps in making our plots interactive. We can reuse these templates to maintain consistency across multiple plots. In this article we will see how to use Matplotlib’s built-in styles and efficiently apply them to your plots.Syntax: plt.style.use('style_name")style_name is the name of the style which we want to use.If we want to explore all the available styles we can print it like this: Python from matplotlib import style import matplotlib.pyplot as plt print(plt.style.available) Output:['Solarize_Light2', '_classic_test_patch', 'bmh', ----------------seaborn-whitegrid','tableau-colorblind10']Example 1: Applying Solarize_Light2 Styledata = np.random.randn(50): Create an array of 50 random values using numpy's randn() function which generates random values from a standard normal distribution.plt.style.use('Solarize_Light2'): Apply Solarize_Light2 style to the plot which helps in making the plot visually consistent with the chosen theme. Python import numpy as np import matplotlib.pyplot as plt from matplotlib import style data = np.random.randn(50) plt.style.use('Solarize_Light2') plt.plot(data) plt.show() Output:Solarize_Light2Example 2: Applying dark_background Styleplt.style.use('dark_background'): Uses dark_background style which changes plot's background color to dark and adjusts other visual elements accordingly. Python import numpy as np import matplotlib.pyplot as plt from matplotlib import style data = np.random.randn(50) plt.style.use('dark_background') plt.plot(data) plt.show() Output:dark_backgroundExample 3: Applying ggplot Styleplt.style.use('ggplot'): Apply ggplot style which helps in giving it a clean and polished look similar to the popular ggplot2 library.plt.plot(data, linestyle=":", linewidth=2): Plot data with a dotted line style as specified by linestyle=":" and a line width of 2. Python import numpy as np import matplotlib.pyplot as plt from matplotlib import style data = np.random.randn(50) plt.style.use('ggplot') plt.plot(data, linestyle=":", linewidth=2) plt.show() Output:ggplotExample 4: Temporarily apply dark_background StyleNote: If we only want to use a style for a particular plot but don't want to change the global styling for all the plots, for that it provides a context manager for limiting the area of styling for a particular plot.with plt.style.context('dark_background'): Use a context manager to temporarily apply the dark_backgroundstyle to the plot within the block which ensures that only this plot is affected not others. Python import numpy as np import matplotlib.pyplot as plt from matplotlib import style with plt.style.context('dark_background'): plt.plot(np.sin(np.linspace(0, 2 * np.pi)), 'r-o') plt.show() Output:dark_background (temporary)By using Matplotlib's styling features we can easily create visually appealing and consistent plots which helps in enhancing overall presentation of our data. Comment N neelutiwari Follow Improve N neelutiwari Follow Improve Article Tags : Technical Scripter Python Technical Scripter 2020 Python-matplotlib Explore Python FundamentalsPython Introduction 2 min read Input and Output in Python 4 min read Python Variables 5 min read Python Operators 4 min read Python Keywords 2 min read Python Data Types 7 min read Conditional Statements in Python 3 min read Loops in Python - For, While and Nested Loops 5 min read Python Functions 5 min read Recursion in Python 4 min read Python Lambda Functions 5 min read Python Data StructuresPython String 5 min read Python Lists 4 min read Python Tuples 4 min read Python Dictionary 3 min read Python Sets 6 min read Python Arrays 7 min read List Comprehension in Python 4 min read Advanced PythonPython OOP Concepts 11 min read Python Exception Handling 5 min read File Handling in Python 4 min read Python Database Tutorial 4 min read Python MongoDB Tutorial 2 min read Python MySQL 9 min read Python Packages 10 min read Python Modules 7 min read Python DSA Libraries 15 min read List of Python GUI Library and Packages 3 min read Data Science with PythonNumPy Tutorial - Python Library 3 min read Pandas Tutorial 6 min read Matplotlib Tutorial 5 min read Python Seaborn Tutorial 15+ min read StatsModel Library- Tutorial 4 min read Learning Model Building in Scikit-learn 8 min read TensorFlow Tutorial 2 min read PyTorch Tutorial 6 min read Web Development with PythonFlask Tutorial 8 min read Django Tutorial | Learn Django Framework 7 min read Django ORM - Inserting, Updating & Deleting Data 4 min read Templating With Jinja2 in Flask 6 min read Django Templates 7 min read Python | Build a REST API using Flask 3 min read How to Create a basic API using Django Rest Framework ? 4 min read Python PracticePython Quiz 3 min read Python Coding Practice 1 min read Python Interview Questions and Answers 15+ min read Like