Matplotlib.axes.Axes.format_coord() in Python Last Updated : 12 Jul, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report Matplotlib is a library in Python and it is numerical - mathematical extension for NumPy library. The Axes Class contains most of the figure elements: Axis, Tick, Line2D, Text, Polygon, etc., and sets the coordinate system. And the instances of Axes supports callbacks through a callbacks attribute. Matplotlib.axes.Axes.format_coord() Function The Axes.format_coord() function in axes module of matplotlib library is used to return a format string formatting the x, y coordinates. Syntax: Axes.format_coord(self, x, y) Return value: This method return a format string formatting the x, y coordinates. Below examples illustrate the matplotlib.axes.Axes.format_coord() function in matplotlib.axes: Example-1: Python3 # Implementation of matplotlib function import numpy as np import matplotlib.pyplot as plt import matplotlib.pyplot as plt import numpy as np # make an agg figure fig, ax = plt.subplots() ax.plot([1, 2, 3, 7], [1, 5, 6, 9]) def format_coord(x = 7, y = 9): col = int(x + 0.5) row = int(y + 0.5) if col >= 0 and col < 5 and row >= 0 and row < 5: z = row + col return 'x =% 1.4f, y =% 1.4f, z =% 1.4f' % (x, y, z) else: return 'x =% 1.4f, y =% 1.4f' % (x, y) ax.format_coord = format_coord fig.suptitle('matplotlib.axes.Axes.format_coord()\ function Example', fontweight ="bold") plt.show() Output: Example-2: Python3 # Implementation of matplotlib function import numpy as np import matplotlib.pyplot as plt # Fixing random state for reproducibility np.random.seed(19680801) X = np.random.rand(15, 30) fig, ax = plt.subplots() ax.imshow(X) val1, val2 = X.shape def format_coord(x, y): col = int(x + 2) row = int(y - 2) if col >= 0 and col < val2 and row >= 0 and row < val1: z = X[row, col] return 'x =% 2.0f, y =% 2.0f, z =% 2.0f' % (x, y, z) else: return 'x =% 2.0f, y =% 2.0f' % (x, y) ax.format_coord = format_coord fig.suptitle('matplotlib.axes.Axes.format_coord() \ function Example', fontweight ="bold") plt.show() Output: Comment More infoAdvertise with us Next Article Matplotlib.axes.Axes.draw() in Python S SHUBHAMSINGH10 Follow Improve Article Tags : Python Python-matplotlib Practice Tags : python Similar Reads Matplotlib.axes.Axes.format_cursor_data() in Python Matplotlib is a library in Python and it is numerical â mathematical extension for NumPy library. The Axes Class contains most of the figure elements: Axis, Tick, Line2D, Text, Polygon, etc., and sets the coordinate system. And the instances of Axes supports callbacks through a callbacks attribute. 2 min read Matplotlib.axes.Axes.draw() in Python Matplotlib is a library in Python and it is numerical â mathematical extension for NumPy library. The Axes Class contains most of the figure elements: Axis, Tick, Line2D, Text, Polygon, etc., and sets the coordinate system. And the instances of Axes supports callbacks through a callbacks attribute. 2 min read Matplotlib.axes.Axes.format_xdata() in Python Matplotlib is a library in Python and it is numerical - mathematical extension for NumPy library. The Axes Class contains most of the figure elements: Axis, Tick, Line2D, Text, Polygon, etc., and sets the coordinate system. And the instances of Axes supports callbacks through a callbacks attribute. 2 min read Matplotlib.axes.Axes.format_ydata() in Python Matplotlib is a library in Python and it is numerical - mathematical extension for NumPy library. The Axes Class contains most of the figure elements: Axis, Tick, Line2D, Text, Polygon, etc., and sets the coordinate system. And the instances of Axes supports callbacks through a callbacks attribute. 2 min read Matplotlib.axes.Axes.cla() in Python Matplotlib is a library in Python and it is numerical - mathematical extension for NumPy library. The Axes Class contains most of the figure elements: Axis, Tick, Line2D, Text, Polygon, etc., and sets the coordinate system. And the instances of Axes supports callbacks through a callbacks attribute. 1 min read Matplotlib.axes.Axes.grid() in Python Matplotlib is a library in Python and it is numerical - mathematical extension for NumPy library. The Axes Class contains most of the figure elements: Axis, Tick, Line2D, Text, Polygon, etc., and sets the coordinate system. And the instances of Axes supports callbacks through a callbacks attribute. 2 min read Like