Skip to content

Commit 087ffde

Browse files
committed
DOC: Remove Tick object details from artist tutorial
Closes matplotlib#31682. Don't explain the object structure and accessor methods to Tick objects and their constituent artists. Users should rarely use them as they are dynamically created and modified. - Remove the complete section on "Tick containers". Users really should access the individual parts through a Tick instance. The technical API still remains accessible in https://matplotlib.org/stable/api/axis_api.html#matplotlib.axis.Tick - Remove all the tick parts getter functions and instead point users to formatters, locators and tick_params.
1 parent c6377d0 commit 087ffde

1 file changed

Lines changed: 10 additions & 100 deletions

File tree

galleries/tutorials/artists.py

Lines changed: 10 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -596,40 +596,16 @@ class in the Matplotlib API, and the one you will be working with most
596596
# the ticks are placed and how they are represented as strings.
597597
#
598598
# Each ``Axis`` object contains a :attr:`~matplotlib.axis.Axis.label` attribute
599-
# (this is what :mod:`.pyplot` modifies in calls to `~.pyplot.xlabel` and
600-
# `~.pyplot.ylabel`) as well as a list of major and minor ticks. The ticks are
599+
# (this is what `~.Axes.set_xlabel` / `~.Axes.set_ylabel` modifies internally)
600+
# as well as a list of major and minor ticks. The ticks are
601601
# `.axis.XTick` and `.axis.YTick` instances, which contain the actual line and
602602
# text primitives that render the ticks and ticklabels. Because the ticks are
603-
# dynamically created as needed (e.g., when panning and zooming), you should
604-
# access the lists of major and minor ticks through their accessor methods
605-
# `.axis.Axis.get_major_ticks` and `.axis.Axis.get_minor_ticks`. Although
606-
# the ticks contain all the primitives and will be covered below, ``Axis``
607-
# instances have accessor methods that return the tick lines, tick labels, tick
608-
# locations etc.:
609-
610-
fig, ax = plt.subplots()
611-
axis = ax.xaxis
612-
axis.get_ticklocs()
613-
614-
# %%
615-
616-
axis.get_ticklabels()
617-
618-
# %%
619-
# note there are twice as many ticklines as labels because by default there are
620-
# tick lines at the top and bottom but only tick labels below the xaxis;
621-
# however, this can be customized.
622-
623-
axis.get_ticklines()
624-
625-
# %%
626-
# And with the above methods, you only get lists of major ticks back by
627-
# default, but you can also ask for the minor ticks:
628-
629-
axis.get_ticklabels(minor=True)
630-
axis.get_ticklines(minor=True)
631-
632-
# %%
603+
# dynamically created and modified as needed (e.g., when panning and zooming),
604+
# directly working on the ticks and their parts (tick lines, tick labels, grid lines)
605+
# is discouraged. Instead, the high-level concepts tick locators, tick formatters
606+
# and style configuration via `~.Axes.tick_params` should be used. See
607+
# :ref:'user_axes_ticks` for details.
608+
#
633609
# Here is a summary of some of the useful accessor methods of the ``Axis``
634610
# (these have corresponding setters where useful, such as
635611
# :meth:`~matplotlib.axis.Axis.set_major_formatter`.)
@@ -640,82 +616,16 @@ class in the Matplotlib API, and the one you will be working with most
640616
# `~.Axis.get_scale` The scale of the Axis, e.g., 'log' or 'linear'
641617
# `~.Axis.get_view_interval` The interval instance of the Axis view limits
642618
# `~.Axis.get_data_interval` The interval instance of the Axis data limits
643-
# `~.Axis.get_gridlines` A list of grid lines for the Axis
644619
# `~.Axis.get_label` The Axis label - a `.Text` instance
645-
# `~.Axis.get_offset_text` The Axis offset text - a `.Text` instance
646-
# `~.Axis.get_ticklabels` A list of `.Text` instances -
647-
# keyword minor=True|False
648-
# `~.Axis.get_ticklines` A list of `.Line2D` instances -
649-
# keyword minor=True|False
650-
# `~.Axis.get_ticklocs` A list of Tick locations -
651-
# keyword minor=True|False
652620
# `~.Axis.get_major_locator` The `.ticker.Locator` instance for major ticks
653621
# `~.Axis.get_major_formatter` The `.ticker.Formatter` instance for major
654622
# ticks
655623
# `~.Axis.get_minor_locator` The `.ticker.Locator` instance for minor ticks
656624
# `~.Axis.get_minor_formatter` The `.ticker.Formatter` instance for minor
657625
# ticks
658-
# `~.axis.Axis.get_major_ticks` A list of `.Tick` instances for major ticks
659-
# `~.axis.Axis.get_minor_ticks` A list of `.Tick` instances for minor ticks
626+
# `~.Axis.get_tick_params` Styling of ticks, ticklabels and gridlines
660627
# `~.Axis.grid` Turn the grid on or off for the major or minor
661628
# ticks
662629
# ============================= ==============================================
663630
#
664-
# Here is an example, not recommended for its beauty, which customizes
665-
# the Axes and Tick properties.
666-
667-
# plt.figure creates a matplotlib.figure.Figure instance
668-
fig = plt.figure()
669-
rect = fig.patch # a rectangle instance
670-
rect.set_facecolor('lightgoldenrodyellow')
671-
672-
ax1 = fig.add_axes((0.1, 0.3, 0.4, 0.4))
673-
rect = ax1.patch
674-
rect.set_facecolor('lightslategray')
675-
676-
677-
for label in ax1.xaxis.get_ticklabels():
678-
# label is a Text instance
679-
label.set_color('red')
680-
label.set_rotation(45)
681-
label.set_fontsize(16)
682-
683-
for line in ax1.yaxis.get_ticklines():
684-
# line is a Line2D instance
685-
line.set_color('green')
686-
line.set_markersize(25)
687-
line.set_markeredgewidth(3)
688-
689-
plt.show()
690-
691-
# %%
692-
# .. _tick-container:
693-
#
694-
# Tick containers
695-
# ---------------
696-
#
697-
# The :class:`matplotlib.axis.Tick` is the final container object in our
698-
# descent from the :class:`~matplotlib.figure.Figure` to the
699-
# :class:`~matplotlib.axes.Axes` to the :class:`~matplotlib.axis.Axis`
700-
# to the :class:`~matplotlib.axis.Tick`. The ``Tick`` contains the tick
701-
# and grid line instances, as well as the label instances for the upper
702-
# and lower ticks. Each of these is accessible directly as an attribute
703-
# of the ``Tick``.
704-
#
705-
# ============== ==========================================================
706-
# Tick attribute Description
707-
# ============== ==========================================================
708-
# tick1line A `.Line2D` instance
709-
# tick2line A `.Line2D` instance
710-
# gridline A `.Line2D` instance
711-
# label1 A `.Text` instance
712-
# label2 A `.Text` instance
713-
# ============== ==========================================================
714-
#
715-
# Here is an example which sets the formatter for the right side ticks with
716-
# dollar signs and colors them green on the right side of the yaxis.
717-
#
718-
#
719-
# .. include:: ../gallery/ticks/dollar_ticks.rst
720-
# :start-after: .. redirect-from:: /gallery/pyplots/dollar_ticks
721-
# :end-before: .. admonition:: References
631+
# The full Axis API can be found at :doc:`/api/axis_api`.

0 commit comments

Comments
 (0)