How to remove colorbar and heatmap black borders?

276 Ansichten (letzte 30 Tage)
Zeynab Mousavikhamene
Zeynab Mousavikhamene am 1 Dez. 2020
Beantwortet: Sophia Snipes am 3 Aug. 2022
I need to remove colorabar and heatmap blck borders. Any idea?

Akzeptierte Antwort

Benjamin Kraus
Benjamin Kraus am 2 Dez. 2020
Bearbeitet: Benjamin Kraus am 2 Mär. 2022
If you want to remove the colorbar, you can set the ColorbarVisible property to 'off':
h = heatmap(magic(5));
h.ColorbarVisible = 'off';
Alternatively, use the colorbar command:
heatmap(magic(5))
colorbar off
To turn off the grid lines, you can either set the GridVisible property on heatmap:
h = heatmap(magic(5));
h.GridVisible = 'off';
or use the grid command:
heatmap(magic(5))
grid off
Heatmap does not provide any control over the outer border around the outside of the heatmap, or the color or thickness of the line, so if you want to change those things you will have to switch to a lower-level function like image or surface.
  3 Kommentare
Benjamin Kraus
Benjamin Kraus am 12 Jul. 2021
Heatmap does not provide any control over the tick labels on the colorbar. If you want control over those labels, you will have to switch to a lower-level function like imagesc or surface.
Koosha
Koosha am 23 Apr. 2022
Thank u

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (2)

Yue
Yue am 2 Mär. 2022
h.GridVisible = 'off';
This will work to remove black borders.
  1 Kommentar
Benjamin Kraus
Benjamin Kraus am 2 Mär. 2022
Thank you for reminding me about that. I've updated my answer above to reflect that you can set the GridVisible property. You can also use the grid command:
grid off

Melden Sie sich an, um zu kommentieren.


Sophia Snipes
Sophia Snipes am 3 Aug. 2022
For removing the black border of the colobar:
set(colorbar, 'Color', 'none')

Kategorien

Mehr zu Data Distribution Plots finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by