question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

seaborn heatmap's colorbar is generating random ticks

See original GitHub issue

I am trying to make a heatmap with logarithmic colorbar. But it keeps generating it’s own ticks and ticklabels.

import numpy as np
import seaborn as sns
from matplotlib.colors import LogNorm
import matplotlib.ticker as tkr

matrix = np.random.rand(10, 10)/0.4
vmax=2
vmin=0.5

cbar_ticks = [0.5, 0.75, 1, 1.33, 2]
formatter = tkr.ScalarFormatter(useMathText=True)
formatter.set_scientific(False)

log_norm = LogNorm(vmin=vmin, vmax=vmax)
ax = sns.heatmap(matrix, square=True, vmax=vmax, vmin=vmin, norm=log_norm, cbar_kws={"ticks": cbar_ticks, "format": formatter})

image

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
mwaskomcommented, Jan 12, 2021

That ax.collections[0].colorbar.ax object is the same as the cax object in my code, fyi.

1reaction
rikdharcommented, Jan 12, 2021

The following completely removes the ticks and the label.

ax.collections[0].colorbar.ax.yaxis.set_ticks([], minor=True)
Read more comments on GitHub >

github_iconTop Results From Across the Web

Seaborn heatmap is generating additional ticks on colorbar ...
python - Seaborn heatmap is generating additional ticks on colorbar when using log scale - Stack Overflow. Stack Overflow for Teams – Start ......
Read more >
seaborn.heatmap — seaborn 0.12.1 documentation
Part of this Axes space will be taken and used to plot a colormap, unless cbar is False or a separate Axes is...
Read more >
How to manually define color bar scale in seaborn heatmap
I want to define color bar, how to define manually. The automatic color bar ticks getting here are 0.2,0.4,0.6,0.8, but I want to...
Read more >
How to remove the axis tick marks on a Seaborn heatmap?
Create random data points with 4×4 dimension. Plot the rectangular data as a color-encoded matrix. Use tick_params() for changing the ...
Read more >
How to include labels in sns heatmap
I got your problem like this way: You want to show labels on the x and y-axis on the seaborn heatmap. So for...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found