

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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 Questions & Answers
- Text box with line wrapping in Matplotlib
- Automatically run %matplotlib inline in IPython Notebook
- Automatically Rescale ylim and xlim in Matplotlib
- Text in Transparent Box using CSS3
- Preventing validation on HTML5 text box
- Automatically setting Y-axis limits for a bar graph using Matplotlib
- How to insert text at the beginning of the text box in Tkinter?
- How to set justification on Tkinter Text box?
- Adjusting Text background transparency in Matplotlib
- Text alignment in a Matplotlib legend
- How to refresh text in Matplotlib?
- How to animate text in Matplotlib?
- How to put xtick labels in a box matplotlib?
- How to input text in the text box without calling the sendKeys() using Selenium?
- How to position text to top right position on an image with CSS
Advertisements