# Heatmap wrong colorbar number resolution limits

**URL:** https://discourse.julialang.org/t/heatmap-wrong-colorbar-number-resolution-limits/110209
**Category:** Visualization
**Tags:** question, plots
**Created:** [February 14, 2024, 2:47pm UTC](https://discourse.julialang.org/t/heatmap-wrong-colorbar-number-resolution-limits/110209 "2024-02-14T14:47:07Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![jcbritobr](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jcbritobr/32/219275_2.png) [@jcbritobr](https://discourse.julialang.org/u/jcbritobr)
#### Post date: [February 14, 2024, 2:47pm UTC](https://discourse.julialang.org/t/heatmap-wrong-colorbar-number-resolution-limits/110209/1 "2024-02-14T14:47:07Z")

</div>

Hello, good morning

I’m having some diffucults plotting a covariance matrix with low values. The colorbar always shows zero, and cant acquire the correct values. There are configurations thats solves this issue?

 ![image](https://global.discourse-cdn.com/julialang/original/3X/2/3/2395a3a9f51d724fc2e519df2a6a2110899bd0cb.png)

```julia
let
	# now for pca
	X = Matrix(df[!, 2:10])
	@info size(X)
	X = X .- mean(X, dims=1)
	@info size(X)

	# these data are observations by features, so we need X'X, not XX'
	covmat = X'*X / (size(X)[1] -1)
	@info covmat
	# visualize it
	heatmap(covmat, yflip=true, clims=(-.0002, .0002))
end

```

 ![image](https://global.discourse-cdn.com/julialang/original/3X/d/0/d0e1504d69e917eb0e3563efdb47b359d5c4f9f4.png)

---

<div class="post-metadata">

### Author: ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)
#### Post date: [February 14, 2024, 3:01pm UTC](https://discourse.julialang.org/t/heatmap-wrong-colorbar-number-resolution-limits/110209/2 "2024-02-14T15:01:17Z")

</div>

It is always good practice to share the plotting library being used. Also, do you expect a solution with this plotting library specifically, or a solution with an alternative library is desirable?

---

<div class="post-metadata">

### Author: ![jcbritobr](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jcbritobr/32/219275_2.png) [@jcbritobr](https://discourse.julialang.org/u/jcbritobr)
#### Post date: [February 14, 2024, 3:03pm UTC](https://discourse.julialang.org/t/heatmap-wrong-colorbar-number-resolution-limits/110209/3 "2024-02-14T15:03:30Z")

</div>

Its the Plots.jl. Solution maybe in any library, but will be better if it was implemented in Plots.jl

---

<div class="post-metadata">

### Author: ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)
#### Post date: [February 14, 2024, 3:25pm UTC](https://discourse.julialang.org/t/heatmap-wrong-colorbar-number-resolution-limits/110209/4 "2024-02-14T15:25:22Z")

</div>

The problem seems to be that the colorbar got truncated by a narrow figure margin. Increase it with `Measures`:

```julia
using Measures(), Plots; gr()
M = (rand(9,9) .- 0.5)/2000
heatmap(M, clims=(-0.0002, 0.0002), margins=10mm)

```

---

<div class="post-metadata">

### Author: ![jcbritobr](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jcbritobr/32/219275_2.png) [@jcbritobr](https://discourse.julialang.org/u/jcbritobr)
#### Post date: [February 14, 2024, 3:33pm UTC](https://discourse.julialang.org/t/heatmap-wrong-colorbar-number-resolution-limits/110209/5 "2024-02-14T15:33:14Z")

</div>

@rafael.guerra thank you. It worked

 ![image](https://global.discourse-cdn.com/julialang/original/3X/4/3/4389fa8150dd176644b2330056a073a39dce02b9.png)
