How to Set X-Axis Values in Matplotlib in Python? Last Updated : 13 Sep, 2022 Comments Improve Suggest changes Like Article Like Report In this article, we will be looking at the approach to set x-axis values in matplotlib in a python programming language. The xticks() function in pyplot module of the Matplotlib library is used to set x-axis values. Syntax: matplotlib.pyplot.xticks(ticks=None, labels=None, **kwargs) xticks() function accepts the following parameters: ParametersDescriptionticksList of xticks locations.OptionalPassing an empty list will remove all the xticks.labelsList of labels to place at given ticks location.Optional**kwargsText properties used to control the appearance of labels. Returns: xticks() function returns following values: locs: List of xticks location.labels: List of xlabel text location. Example #1 : In this example, we will be setting up the X-Axis Values in Matplotlib using the xtick() function in the python programming language. Python3 # Python program to set x-axis values in matplotlib import matplotlib.pyplot as plt # x-axis and y-axis values for plotting x = [1, 2, 3, 4, 5, 6] y = [3, 1, 4, 5, 3, 6] # labels for x-asix labels = ['A', 'B', 'C', 'D', 'E', 'F'] # Plotting x-axis and y-axis plt.plot(x, y) # naming of x-axis and y-axis plt.xlabel("X-Axis") plt.ylabel("Y-Axis") # naming the title of the plot plt.title("Set X-Axis Values in Matplotlib") # setting x-axis values plt.xticks(x, labels) plt.show() Output: Example #2: In this example, we will use the rotation argument to accept rotation value in degree and it will rotate labels in the clockwise direction by specified degree. Python3 # Python program to set x-axis values in matplotlib import matplotlib.pyplot as plt # x-axis and y-axis values for plotting x = [1, 2, 3, 4, 5, 6] y = [3, 1, 4, 5, 3, 6] # labels for x-asix labels = ['Label1', 'Label2', 'Label3', 'Label4', 'Label5', 'Label6'] # Plotting x-axis and y-axis plt.plot(x, y) # naming of x-axis and y-axis plt.xlabel("X-Axis") plt.ylabel("Y-Axis") # naming the title of the plot plt.title("Set X-Axis Values in Matplotlib") # setting x-axis values and specifying rotation # for the labels in degrees plt.xticks(x, labels, rotation=45) plt.show() Output: Comment More infoAdvertise with us Next Article How to Set X-Axis Values in Matplotlib in Python? S sainimansi Follow Improve Article Tags : Python Python-matplotlib Practice Tags : python Similar Reads Matplotlib.axis.Axis.set_ticklabels() function in Python Matplotlib is a library in Python and it is numerical â mathematical extension for NumPy library. It is an amazing visualization library in Python for 2D plots of arrays and used for working with the broader SciPy stack. Matplotlib.axis.Axis.set_ticklabels() Function The Axis.set_ticklabels() functi 2 min read Matplotlib.axis.Tick.set() function in Python Matplotlib is a library in Python and it is numerical â mathematical extension for NumPy library. It is an amazing visualization library in Python for 2D plots of arrays and used for working with the broader SciPy stack. matplotlib.axis.Tick.set() Function The Tick.set() function in axis module of m 2 min read How to Set Axis Ranges in Matplotlib? Matplotlib sets the default range of the axis by finding extreme values (i.e. minimum and maximum) on that axis. However, to get a better view of data sometimes the Pyplot module is used to set axis ranges of the graphs according to the requirements in Matplotlib. Letâs create a basic sine wave plot 3 min read Matplotlib.axes.Axes.set_xscale() 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.axis.Axis.set_ticks() function in Python Matplotlib is a library in Python and it is numerical â mathematical extension for NumPy library. It is an amazing visualization library in Python for 2D plots of arrays and used for working with the broader SciPy stack. Matplotlib.axis.Axis.set_ticks() Function The Axis.set_ticks() function in axis 2 min read Matplotlib.axis.Axis.set_units() function in Python Matplotlib is a library in Python and it is numerical â mathematical extension for NumPy library. It is an amazing visualization library in Python for 2D plots of arrays and used for working with the broader SciPy stack. Matplotlib.axis.Axis.set_units() Function The Axis.set_units() function in axis 2 min read Matplotlib.axes.Axes.set_yscale() 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.axis.Axis.set() function in Python Matplotlib is a library in Python and it is numerical â mathematical extension for NumPy library. It is an amazing visualization library in Python for 2D plots of arrays and used for working with the broader SciPy stack. Matplotlib.axis.Axis.set() Function The Axis.set() function in axis module of m 2 min read Matplotlib.axis.Axis.set_label_text() function in Python Matplotlib is a library in Python and it is numerical â mathematical extension for NumPy library. It is an amazing visualization library in Python for 2D plots of arrays and used for working with the broader SciPy stack. Matplotlib.axis.Axis.set_label_text() Function The Axis.set_label_text() functi 2 min read Matplotlib.axis.Axis.reset_ticks() function in Python Matplotlib is a library in Python and it is numerical â mathematical extension for NumPy library. It is an amazing visualization library in Python for 2D plots of arrays and used for working with the broader SciPy stack. Matplotlib.axis.Axis.reset_ticks() Function The Axis.reset_ticks() function in 2 min read Like