- 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 can I format a float using matplotlib's LaTeX formatter?
To format a float using matplotlib's LaTeX formatter, we can take the following steps −
Steps
Set the figure size and adjust the padding between and around the subplots.
Create x and y data points using numpy.
Plot the x and y data points using plot() method.
Fill the area between the curve.
Set the title of the figure with LaTeX representation.
To display the figure, use show() method.
Example
import numpy as np from matplotlib import pyplot as plt # Set the figures size plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True # x and y data points x = np.linspace(-5, 5, 100) y = x**3/3 # Plot the data points plt.plot(x, y) # Fill the area between the curve plt.fill_between(x, y) # LaTex representation plt.title("$area=\int_a^b{x^2dx}$=83.3") # Display the plot plt.show()
Output
It will produce the following output −
- Related Articles
- How do I redraw an image using Python's Matplotlib?
- How can I get a file's permission mask using Python?
- How do I change the axis tick font in a Matplotlib plot when rendering using LaTeX?
- How can I convert 'HH:MM:SS ' format to seconds in JavaScript
- How do I write a Latex formula in the legend of a plot using Matplotlib inside a .py file?
- How can I set the 'backend' in matplotlib in Python?
- How can I get a file's size in C++?
- How can I vary a shape's alpha with Tkinter?
- Format Output with Formatter in Java
- How can I draw a scatter trend line using Matplotlib?
- How do I change matplotlib's subplot projection of an existing axis?
- How can I get all element's immediate children with css selectors using selenium?
- How to format a float in JavaScript?
- Adding a line to a scatter plot using Python's Matplotlib
- How to understand Seaborn's heatmap annotation format?

Advertisements