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

FIX: make sure all ticks show up for colorbar minor tick#12099

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
tacaswell merged 2 commits intomatplotlib:masterfromjklymak:fix-all-cbar-ticks
Sep 15, 2018
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
3 changes: 2 additions & 1 deletionlib/matplotlib/colorbar.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -267,7 +267,8 @@ def __call__(self):
vmin = self._colorbar.norm.vmin
vmax = self._colorbar.norm.vmax
ticks = ticker.AutoMinorLocator.__call__(self)
return ticks[(ticks >= vmin) & (ticks <= vmax)]
rtol = (vmax - vmin) * 1e-10
return ticks[(ticks >= vmin - rtol) & (ticks <= vmax + rtol)]
Copy link
Member

Choose a reason for hiding this comment

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

Just as a thought: Can it happen, that vmin > vmax? If so, neither the original nor the fixed code would work in that case.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Yes but that gets checked and swapped inside the method before this code

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Confirmed that vmax and vmin get flipped if they are specified out of order. Which maybe is bad behaviour? But its what colorbar does...



class _ColorbarLogLocator(ticker.LogLocator):
Expand Down
9 changes: 9 additions & 0 deletionslib/matplotlib/tests/test_colorbar.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -294,6 +294,15 @@ def test_colorbar_minorticks_on_off():
np.testing.assert_almost_equal(cbar.ax.yaxis.get_minorticklocs(),
np.array([]))

im.set_clim(vmin=-1.2, vmax=1.2)
cbar.minorticks_on()
correct_minorticklocs = np.array([-1.2, -1.1, -0.9, -0.8, -0.7, -0.6,
-0.4, -0.3, -0.2, -0.1, 0.1, 0.2,
0.3, 0.4, 0.6, 0.7, 0.8, 0.9,
1.1, 1.2])
np.testing.assert_almost_equal(cbar.ax.yaxis.get_minorticklocs(),
correct_minorticklocs)


def test_colorbar_autoticks():
# Test new autotick modes. Needs to be classic because
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp