GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Installation
  • Documentation
  • Examples
  • Tutorials
  • Contributing

This view

  • Original page
  • New address

GeezerVison is showing matplotlib.org — matplotlib.pyplot.xticks — Matplotlib 3.1.2 documentation

You are reading an old version of the documentation (v3.1.1). For the latest version see https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.xticks.html
Version 3.1.2
matplotlib
Fork me on GitHub

Navigation

  • index
  • modules |
  • next |
  • previous |
  • home| 
  • contents »
  • API Overview »
  • matplotlib.pyplot »
  • matplotlib.pyplot »

Quick search

Table of Contents

  • matplotlib.pyplot.xticks
    • Examples using matplotlib.pyplot.xticks

Related Topics

  • Documentation overview
    • API Overview
      • matplotlib.pyplot
        • matplotlib.pyplot
          • Previous: matplotlib.pyplot.xscale
          • Next: matplotlib.pyplot.ylabel
Show Page Source

matplotlib.pyplot.xticks¶

matplotlib.pyplot.xticks(ticks=None, labels=None, **kwargs)[source]¶

Get or set the current tick locations and labels of the x-axis.

Call signatures:

locs, labels = xticks()            # Get locations and labels
xticks(ticks, [labels], **kwargs)  # Set locations and labels
Parameters:
ticks : array_like

A list of positions at which ticks should be placed. You can pass an empty list to disable xticks.

labels : array_like, optional

A list of explicit labels to place at the given locs.

**kwargs

Text properties can be used to control the appearance of the labels.

Returns:
locs

An array of label locations.

labels

A list of Text objects.

Notes

Calling this function with no arguments (e.g. xticks()) is the pyplot equivalent of calling get_xticks and get_xticklabels on the current axes. Calling this function with arguments is the pyplot equivalent of calling set_xticks and set_xticklabels on the current axes.

Examples

Get the current locations and labels:

>>> locs, labels = xticks()

Set label locations:

>>> xticks(np.arange(0, 1, step=0.2))

Set text labels:

>>> xticks(np.arange(5), ('Tom', 'Dick', 'Harry', 'Sally', 'Sue'))

Set text labels and properties:

>>> xticks(np.arange(12), calendar.month_name[1:13], rotation=20)

Disable xticks:

>>> xticks([])

Examples using matplotlib.pyplot.xticks¶

../../_images/sphx_glr_bar_stacked_thumb.png

Stacked Bar Graph

../../_images/sphx_glr_secondary_axis_thumb.png

Secondary Axis

../../_images/sphx_glr_arrow_demo_thumb.png

Arrow Demo

../../_images/sphx_glr_multiline_thumb.png

Multiline

../../_images/sphx_glr_usetex_demo_thumb.png

Usetex Demo

../../_images/sphx_glr_demo_colorbar_of_inset_axes_thumb.png

Demo Colorbar of Inset Axes

../../_images/sphx_glr_table_demo_thumb.png

Table Demo

../../_images/sphx_glr_custom_ticker1_thumb.png

Custom Ticker1

../../_images/sphx_glr_ticklabels_rotation_thumb.png

Rotating custom tick labels

© Copyright 2002 - 2012 John Hunter, Darren Dale, Eric Firing, Michael Droettboom and the Matplotlib development team; 2012 - 2018 The Matplotlib development team.
Last updated on Jan 05, 2020. Created using Sphinx 1.8.5. Doc version v3.1.1-79-g90d53b526.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.