Matplotlib.axes.Axes.format_xdata() in Python Last Updated : 19 Apr, 2020 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_xdata() Function The Axes.format_xdata() function in axes module of matplotlib library is used to return x formatted as an x-value. Syntax: Axes.format_xdata(self, x) Below examples illustrate the matplotlib.axes.Axes.format_xdata() function in matplotlib.axes: Example 1: Python3 # Implementation of matplotlib function import numpy as np import matplotlib.pyplot as plt import matplotlib.dates as mdates import matplotlib.cbook as cbook years = mdates.YearLocator() months = mdates.MonthLocator() years_fmt = mdates.DateFormatter('% Y') with cbook.get_sample_data('goog.npz') as datafile: data = np.load(datafile)['price_data'].view(np.recarray) fig, ax = plt.subplots() ax.plot('date', 'adj_close', data = data, color ="green") ax.xaxis.set_major_locator(years) ax.set_ylim((100, 300)) ax.format_xdata = mdates.DateFormatter('% m') ax.grid(True) fig.suptitle('matplotlib.axes.Axes.format_xdata() function\ Example', fontweight ="bold") plt.show() Output: Example 2: Python3 # Implementation of matplotlib function import numpy as np import matplotlib.pyplot as plt import matplotlib.dates as mdates import matplotlib.cbook as cbook years = mdates.YearLocator() months = mdates.MonthLocator() years_fmt = mdates.DateFormatter('% Y') with cbook.get_sample_data('goog.npz') as datafile: data = np.load(datafile)['price_data'] fig, ax = plt.subplots() ax.plot('date', 'adj_close', data = data) ax.xaxis.set_major_locator(years) ax.xaxis.set_major_formatter(years_fmt) ax.xaxis.set_minor_locator(months) ax.format_xdata = mdates.DateFormatter('% Y') ax.grid(True) fig.autofmt_xdate() fig.suptitle('matplotlib.axes.Axes.format_xdata() 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_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.format_coord() 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.text() 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.update() 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.table() 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. 3 min read Like