- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- 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
Showing points coordinates in a plot in Python using Matplotlib
To show points coordinate in a plot in Python, we can take the following steps −
- Set the figure size and adjust the padding between and around the subplots.
- Create lists of x and y data points.
- Plot x and y data points with red color and starred marker
- Set some axis properties.
- Iterate x and y to show the coordinates on the plot.
Example
import matplotlib.pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True x = [3, 1, 2, 5] y = [5, 2, 4, 7] plt.plot(x, y, 'r*') plt.axis([0, 6, 0, 20]) for i, j in zip(x, y): plt.text(i, j+0.5, '({}, {})'.format(i, j)) plt.show()
Output
Advertisements
To Continue Learning Please Login
Login with Google