Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Minor fixes in ticker docs #28743

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 18 additions & 18 deletions lib/matplotlib/ticker.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,10 +435,10 @@ class ScalarFormatter(Formatter):
lim = (1_000_000, 1_000_010)

fig, (ax1, ax2, ax3) = plt.subplots(3, 1, gridspec_kw={'hspace': 2})
ax1.set(title='offset_notation', xlim=lim)
ax1.set(title='offset notation', xlim=lim)
ax2.set(title='scientific notation', xlim=lim)
ax2.xaxis.get_major_formatter().set_useOffset(False)
ax3.set(title='floating point notation', xlim=lim)
ax3.set(title='floating-point notation', xlim=lim)
ax3.xaxis.get_major_formatter().set_useOffset(False)
ax3.xaxis.get_major_formatter().set_scientific(False)

Expand Down Expand Up @@ -1146,10 +1146,10 @@ def __init__(
Parameters
----------
use_overline : bool, default: False
If x > 1/2, with x = 1-v, indicate if x should be displayed as
$\overline{v}$. The default is to display $1-v$.
If x > 1/2, with x = 1 - v, indicate if x should be displayed as
$\overline{v}$. The default is to display $1 - v$.

one_half : str, default: r"\frac{1}{2}"
one_half : str, default: r"\\frac{1}{2}"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The backslash was missing from the rendered version, so will have to check it this gets it back...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to render correctly. (One may question if the r should be there, but if it is one can copy-and-paste it...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe make the whole docstring raw. Then you don't need backslash doubling here (but can keep the r prefix for copying).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is raw, which is why I had to test to see what happened. I do not really understand why I need to escape it, but that seems to do the trick...

r"""
Parameters
----------
use_overline : bool, default: False
If x > 1/2, with x = 1-v, indicate if x should be displayed as
$\overline{v}$. The default is to display $1-v$.
one_half : str, default: r"\frac{1}{2}"
The string used to represent 1/2.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I'm confused. This feels like a bug in sphinx. But I question that it's worth tracking down.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, not obvious why it is required.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's just not bother.

The string used to represent 1/2.

minor : bool, default: False
Expand Down Expand Up @@ -1179,17 +1179,17 @@ def use_overline(self, use_overline):

Parameters
----------
use_overline : bool, default: False
If x > 1/2, with x = 1-v, indicate if x should be displayed as
$\overline{v}$. The default is to display $1-v$.
use_overline : bool
If x > 1/2, with x = 1 - v, indicate if x should be displayed as
$\overline{v}$. The default is to display $1 - v$.
"""
self._use_overline = use_overline

def set_one_half(self, one_half):
r"""
Set the way one half is displayed.

one_half : str, default: r"\frac{1}{2}"
one_half : str
The string used to represent 1/2.
"""
self._one_half = one_half
Expand Down Expand Up @@ -1707,14 +1707,14 @@ def tick_values(self, vmin, vmax):


class FixedLocator(Locator):
"""
r"""
Place ticks at a set of fixed values.

If *nbins* is None ticks are placed at all values. Otherwise, the *locs* array of
possible positions will be subsampled to keep the number of ticks <=
:math:`nbins* +1`. The subsampling will be done to include the smallest absolute
value; for example, if zero is included in the array of possibilities, then it of
the chosen ticks.
possible positions will be subsampled to keep the number of ticks
:math:`\leq nbins + 1`. The subsampling will be done to include the smallest
absolute value; for example, if zero is included in the array of possibilities, then
it will be included in the chosen ticks.
"""

def __init__(self, locs, nbins=None):
Expand Down Expand Up @@ -1861,9 +1861,9 @@ def __init__(self, base=1.0, offset=0.0):
"""
Parameters
----------
base : float > 0
base : float > 0, default: 1.0
Interval between ticks.
offset : float
offset : float, default: 0.0
Value added to each multiple of *base*.

.. versionadded:: 3.8
Expand All @@ -1877,9 +1877,9 @@ def set_params(self, base=None, offset=None):

Parameters
----------
base : float > 0
base : float > 0, optional
Interval between ticks.
offset : float
offset : float, optional
Value added to each multiple of *base*.

.. versionadded:: 3.8
Expand Down
Loading