- 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
Automatically position text box in Matplotlib
To position a textbox automatically in matplotlib, we can take the following Steps −
Create xpoints from 1 to 2 and 100 samples.
Create y1points and y2points using xpoints (Step 1) and numpy.
Plot xpoints, y1points and y2points using the plot() method.
To set the label, use the legend() method. It will help to position the text box.
To display the figure, use the 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 xpoints = np.linspace(1, 2, 100) y1points = np.log(xpoints) y2points = np.exp(xpoints) plt.plot(xpoints, y1points, label="Log") plt.plot(xpoints, y2points, label="Exp") plt.legend() plt.show()
Output
- Related Articles
- Text box with line wrapping in Matplotlib
- Automatically Rescale ylim and xlim in Matplotlib
- Automatically run %matplotlib inline in IPython Notebook
- Text in Transparent Box using CSS3
- Preventing validation on HTML5 text box
- How to refresh text in Matplotlib?
- Adjusting Text background transparency in Matplotlib
- Text alignment in a Matplotlib legend
- How to animate text in Matplotlib?
- How to insert text at the beginning of the text box in Tkinter?
- How to put xtick labels in a box matplotlib?
- Automatically setting Y-axis limits for a bar graph using Matplotlib
- Adjust the width of box in boxplot in Python Matplotlib
- How to input text in the text box without calling the sendKeys() using Selenium?
- Place text inside a circle in Matplotlib

Advertisements