matplotlib.axes.Axes.set_xticks#
- Axes.set_xticks(ticks,labels=None,*,minor=False,**kwargs)[source]#
Set the xaxis' tick locations and optionally tick labels.
If necessary, the view limits of the Axis are expanded so that allgiven ticks are visible.
- Parameters:
- ticks1D array-like
Array of tick locations (either floats or in axis units). The axis
Locatoris replaced by aFixedLocator.Pass an empty list (
set_xticks([])) to remove all ticks.Some tick formatters will not label arbitrary tick positions;e.g. log formatters only label decade ticks by default. Insuch a case you can set a formatter explicitly on the axisusing
Axis.set_major_formatteror provide formattedlabels yourself.- labelslist of str, optional
Tick labels for each location inticks; must have the same length asticks. If set, the labels are used as is, via a
FixedFormatter.If not set, the labels are generated using the axis tickFormatter.- minorbool, default: False
If
False, set only the major ticks; ifTrue, only the minor ticks.- **kwargs
Textproperties for the labels. Using these is only allowed ifyou passlabels. In other cases, please usetick_params.
Notes
The mandatory expansion of the view limits is an intentional designchoice to prevent the surprise of a non-visible tick. If you needother limits, you should set the limits explicitly after setting theticks.
Examples usingmatplotlib.axes.Axes.set_xticks#
Align histogram to scatter plot using locatable Axes