# Specify digits in contour plot scale

**URL:** https://discourse.julialang.org/t/specify-digits-in-contour-plot-scale/71384
**Category:** General Usage
**Tags:** plotting, plots
**Created:** [November 12, 2021, 2:31pm UTC](https://discourse.julialang.org/t/specify-digits-in-contour-plot-scale/71384 "2021-11-12T14:31:15Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Christopher\_Fisher](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/christopher_fisher/32/26132_2.png) [@Christopher\_Fisher](https://discourse.julialang.org/u/Christopher_Fisher)
#### Post date: [November 12, 2021, 2:31pm UTC](https://discourse.julialang.org/t/specify-digits-in-contour-plot-scale/71384/1 "2021-11-12T14:31:15Z")

</div>

I have a grid of contour plots. Depending on input, some subplots only have a single value on the z dimension. The problem is that the scale displays multiple digits, which decreases the size of all subplots in the grid. How can I control the number of digits displayed? I tried zticks, but that did not work. Thank you.

MWE:

```julia
using Plots 
x = .1:0.05:2

y = .1:0.05:1

X = repeat(reshape(x, 1, :), length(y), 1)

Y = repeat(y, 1, length(x))

Z = fill(.655848484848, size(X))

p1 = contour(x, y, Z, fill = true, zticks=[.65])

```

---

<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: [November 12, 2021, 3:19pm UTC](https://discourse.julialang.org/t/specify-digits-in-contour-plot-scale/71384/2 "2021-11-12T15:19:30Z")

</div>

The folllowing works with Plots’ pyplot() backend (and also with `pgfplotsx()`):

```julia
using Plots; pyplot()
x = y = .1:0.05:4
Z = sqrt.(x' .* y)
num = round(π, digits=2)
contourf(x, y, Z, colorbar_ticks=[num])

```

But not sure if that will solve your ultimate problem of spacing between subplots.

---

<div class="post-metadata">

### Author: ![Christopher\_Fisher](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/christopher_fisher/32/26132_2.png) [@Christopher\_Fisher](https://discourse.julialang.org/u/Christopher_Fisher)
#### Post date: [November 12, 2021, 3:29pm UTC](https://discourse.julialang.org/t/specify-digits-in-contour-plot-scale/71384/3 "2021-11-12T15:29:14Z")

</div>

> [@rafael.guerra](#):
>
> ```julia
> using Plots; pyplot()
> x = y = .1:0.05:4
> Z = sqrt.(x' .* y)
> num = round(π, digits=2)
> contourf(x, y, Z, colorbar_ticks=[num])
> 
> ```

Hi Rafael. Thanks for your response. Strangely, this solution does not work when the Z dimension only has a single unique value. Here is an example:

```julia
using Plots

pyplot()

x = .1:0.05:2

y = .1:0.05:1

X = repeat(reshape(x, 1, :), length(y), 1)

Y = repeat(y, 1, length(x))

Z = fill(.655848484848, size(X))

p1 = contour(x, y, Z, fill = true, colorbar_ticks=[.65])

```

It is certainly an improvement because it does not have a long number, but is there a way to still show it somehow?

---

<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: [November 12, 2021, 3:45pm UTC](https://discourse.julialang.org/t/specify-digits-in-contour-plot-scale/71384/4 "2021-11-12T15:45:25Z")

</div>

Please check if this could be OK:

```julia
num = 0.655848484848
num = round(num, digits=3)
contourf(x, y, Z, colorbar_ticks=[], colorbar_title=string(num))

```

---

<div class="post-metadata">

### Author: ![Christopher\_Fisher](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/christopher_fisher/32/26132_2.png) [@Christopher\_Fisher](https://discourse.julialang.org/u/Christopher_Fisher)
#### Post date: [November 12, 2021, 4:14pm UTC](https://discourse.julialang.org/t/specify-digits-in-contour-plot-scale/71384/5 "2021-11-12T16:14:31Z")

</div>

> [@rafael.guerra](#):
>
> `colorbar_ticks=[], colorbar_title=string(num)`

Thanks Rafael! I think this is close enough. If someone else has an idea about rotating the colorbar title, I would be interested in that. I tried `zguidefontrotation = 90`, but to no avail.
