# Y-axis scale in histogram

**URL:** https://discourse.julialang.org/t/y-axis-scale-in-histogram/76819
**Category:** Visualization
**Tags:** plots, gr, statsplots, histogram
**Created:** [February 20, 2022, 8:27pm UTC](https://discourse.julialang.org/t/y-axis-scale-in-histogram/76819 "2022-02-20T20:27:46Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![met-j](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/met-j/32/21919_2.png) [@met-j](https://discourse.julialang.org/u/met-j)
#### Post date: [February 20, 2022, 8:27pm UTC](https://discourse.julialang.org/t/y-axis-scale-in-histogram/76819/1 "2022-02-20T20:27:46Z")

</div>

How can I scale the y axis ticks in a histogram?

Is there a way to access the counts in a histogram from dispatching the `plot` function with `st=:hist`?

In my case I have counts in between 1 000 and a few 10 000s.  
I would like to divide the y ticks by a fixed factor and a factor of the order of magnitude of the maximum of the counts.  
And print this factor _a_ in the y guide as `Counts (10^a)`

Similar but different:  
(y axis scale)[[Yaxis scale](https://discourse.julialang.org/t/yaxis-scale/69960)]

---

<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 20, 2022, 9:05pm UTC](https://discourse.julialang.org/t/y-axis-scale-in-histogram/76819/2 "2022-02-20T21:05:59Z")

</div>

> [@met-j](#):
>
> Is there a way to access the counts in a histogram from dispatching the `plot` function with `st=:hist` ?

Try this and add some labor:

```julia
p = plot(rand(1000), st=:hist)
p[1][1][:y] 

```

---

<div class="post-metadata">

### Author: ![met-j](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/met-j/32/21919_2.png) [@met-j](https://discourse.julialang.org/u/met-j)
#### Post date: [February 20, 2022, 9:40pm UTC](https://discourse.julialang.org/t/y-axis-scale-in-histogram/76819/3 "2022-02-20T21:40:14Z")

</div>

> [@rafael.guerra](#):
>
> ```julia
> p = plot(rand(1000), st=:hist)
> p[1][1][:y] 
> 
> ```

Thanks, that’s the starting point I was searching for.

---

<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 20, 2022, 9:44pm UTC](https://discourse.julialang.org/t/y-axis-scale-in-histogram/76819/4 "2022-02-20T21:44:13Z")

</div>

In this case:

```julia
p = plot(rand(1000), st=:hist)
yn = p[1][1][:y]
counts = maximum.(yn[1:6:length(yn)]) 

```
