Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

ValueError exception added to handle mix of {} and % string in colorbar format#27015

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
rcomer merged 1 commit intomatplotlib:mainfromborgesaugusto:iss_27007
Oct 8, 2023
Merged
Show file tree
Hide file tree
Changes fromall 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
2 changes: 1 addition & 1 deletionlib/matplotlib/colorbar.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -404,7 +404,7 @@ def __init__(self, ax, mappable=None, *, cmap=None,
try:
self._formatter = ticker.FormatStrFormatter(format)
_ = self._formatter(0)
except TypeError:
except(TypeError, ValueError):
self._formatter = ticker.StrMethodFormatter(format)
else:
self._formatter = format # Assume it is a Formatter or None
Expand Down
8 changes: 7 additions & 1 deletionlib/matplotlib/tests/test_colorbar.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,7 +15,7 @@
BoundaryNorm, LogNorm, PowerNorm, Normalize, NoNorm
)
from matplotlib.colorbar import Colorbar
from matplotlib.ticker import FixedLocator, LogFormatter
from matplotlib.ticker import FixedLocator, LogFormatter, StrMethodFormatter
from matplotlib.testing.decorators import check_figures_equal


Expand DownExpand Up@@ -1230,3 +1230,9 @@ def test_colorbar_wrong_figure():
fig_tl.colorbar(im)
fig_tl.draw_without_rendering()
fig_cl.draw_without_rendering()


def test_colorbar_format_string_and_old():
plt.imshow([[0, 1]])
cb = plt.colorbar(format="{x}%")
assert isinstance(cb._formatter, StrMethodFormatter)

[8]ページ先頭

©2009-2025 Movatter.jp