- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to use multiple font sizes in one label in Python Matplotlib?
To use multiple font sizes in one label in Python, we can use fontsize in title() method.
Steps
Set the figure size and adjust the padding between and around the subplots.
Create x and y data points using numpy.
Plot x and y using plot() method.
Initialize a variable, fontsize.
Set the title of the plot using title() method with fontsize in the argument.
Turn off the axes.
To display the figure, use show() method.
Example
import numpy as np from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True x = np.linspace(-5, 5, 100) y = np.cos(x) plt.plot(x, y) fontsize = 20 plt.title("$\bf{y=cos(x)}$", fontsize=fontsize) plt.axis('off') plt.show()
Output
- Related Articles
- How to get different font sizes in the same annotation of Matplotlib?
- Bold font weight for LaTeX axes label in Matplotlib
- How to change the font properties of a Matplotlib colorbar label?
- How to label a line in Matplotlib (Python)?
- How to use Font Awesome symbol as marker in matplotlib?
- How to use multiple conditions in one if statement in Python?
- How to show multiple images in one figure in Matplotlib?
- How to display multiple images in one figure correctly in matplotlib?
- How to label a patch in matplotlib?
- How to plot multiple horizontal bars in one chart with matplotlib?
- Fractional font sizes for HTML5 Canvas?
- How to access axis label object in Matplotlib?
- How to display all label values in Matplotlib?
- Saving multiple figures to one PDF file in matplotlib
- How to get XKCD font working in Matplotlib?

Advertisements