Skip to content

Commit 7c5e705

Browse files
committed
Mention use of Axes.tick_params in docs.
This shortcut should be preferred over manually changing every Tick's properties.
1 parent 641ab73 commit 7c5e705

File tree

1 file changed

+22
-9
lines changed

1 file changed

+22
-9
lines changed

doc/faq/howto_faq.rst

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -241,21 +241,34 @@ over so that the tick labels fit in the figure:
241241

242242
.. _howto-ticks:
243243

244-
Configure the tick linewidths
245-
-----------------------------
244+
Configure the tick widths
245+
-------------------------
246246

247-
In Matplotlib, the ticks are *markers*. All
248-
:class:`~matplotlib.lines.Line2D` objects support a line (solid,
249-
dashed, etc) and a marker (circle, square, tick). The tick linewidth
250-
is controlled by the "markeredgewidth" property::
247+
Wherever possible, it is recommended to use the :meth:`~Axes.tick_params` or
248+
:meth:`~Axis.set_tick_params` methods to modify tick properties::
251249

252250
import matplotlib.pyplot as plt
253-
fig = plt.figure()
254-
ax = fig.add_subplot(111)
251+
252+
fig, ax = plt.subplots()
253+
ax.plot(range(10))
254+
255+
ax.tick_params(width=10)
256+
257+
plt.show()
258+
259+
For more control of tick properties that are not provided by the above methods,
260+
it is important to know that in Matplotlib, the ticks are *markers*. All
261+
:class:`~matplotlib.lines.Line2D` objects support a line (solid, dashed, etc)
262+
and a marker (circle, square, tick). The tick width is controlled by the
263+
``"markeredgewidth"`` property, so the above effect can also be achieved by::
264+
265+
import matplotlib.pyplot as plt
266+
267+
fig, ax = plt.subplots()
255268
ax.plot(range(10))
256269

257270
for line in ax.get_xticklines() + ax.get_yticklines():
258-
line.set_markersize(10)
271+
line.set_markeredgewidth(10)
259272

260273
plt.show()
261274

0 commit comments

Comments
 (0)