Skip to content

Commit 2fc3394

Browse files
jklymaktimhoffm
andauthored
Apply suggestions from code review
Co-authored-by: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com>
1 parent f49ca61 commit 2fc3394

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

doc/users/faq/howto_faq.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ How-to
1515
Why do I have so many ticks, and/or why are they out of order?
1616
--------------------------------------------------------------
1717

18-
One common cause for unexpected tick behavior is passing a list of strings
19-
instead of numbers or datetime objects. This can easily happen without notice
18+
One common cause for unexpected tick behavior is passing a *list of strings
19+
instead of numbers or datetime objects*. This can easily happen without notice
2020
when reading in a comma-delimited text file. Matplotlib treats lists of strings
21-
as "categorical" variables
21+
as *categorical* variables
2222
(:doc:`/gallery/lines_bars_and_markers/categorical_variables`), and by default
23-
puts one tick per "category", and plots them in the order in which they are
23+
puts one tick per category, and plots them in the order in which they are
2424
supplied.
2525

2626
.. plot::

examples/ticks/ticks_too_many.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,18 @@
66
One common cause for unexpected tick behavior is passing a list of strings
77
instead of numbers or datetime objects. This can easily happen without notice
88
when reading in a comma-delimited text file. Matplotlib treats lists of strings
9-
as "categorical" variables
9+
as *categorical* variables
1010
(:doc:`/gallery/lines_bars_and_markers/categorical_variables`), and by default
11-
puts one tick per "category", and plots them in the order in which they are
11+
puts one tick per category, and plots them in the order in which they are
1212
supplied. If this is not desired, the solution is to convert the strings to
1313
a numeric type as in the following examples.
1414
1515
"""
1616

17+
############################################################################
18+
# Example 1: Strings can lead to an unexpected order of number ticks
19+
# ------------------------------------------------------------------
20+
1721
import matplotlib.pyplot as plt
1822
import numpy as np
1923

@@ -32,6 +36,8 @@
3236
ax[1].set_title('Ticks as expected')
3337

3438
############################################################################
39+
# Example 2: Strings can lead to very many ticks
40+
# ----------------------------------------------
3541
# If *x* has 100 elements, all strings, then we would have 100 (unreadable)
3642
# ticks, and again the solution is to convert the strings to floats:
3743

@@ -48,6 +54,8 @@
4854
ax[1].set_xlabel('Floats')
4955

5056
############################################################################
57+
# Example 3: Strings can lead to an unexpected order of datetime ticks
58+
# --------------------------------------------------------------------
5159
# A common case is when dates are read from a CSV file, they need to be
5260
# converted from strings to datetime objects to get the proper date locators
5361
# and formatters.

0 commit comments

Comments
 (0)