# Scale.y\_continuous percentage format

**URL:** https://discourse.julialang.org/t/scale-y-continuous-percentage-format/31397
**Category:** General Usage
**Tags:** gadfly
**Created:** [November 22, 2019, 6:57pm UTC](https://discourse.julialang.org/t/scale-y-continuous-percentage-format/31397 "2019-11-22T18:57:35Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Phillip\_Sutton](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/phillip_sutton/32/7603_2.png) [@Phillip\_Sutton](https://discourse.julialang.org/u/Phillip_Sutton)
#### Post date: [November 22, 2019, 6:57pm UTC](https://discourse.julialang.org/t/scale-y-continuous-percentage-format/31397/1 "2019-11-22T18:57:35Z")

</div>

Is there way to format the y axis as percentages in Gadfly?

Something like  
Scale.y\_continuous(format=:percent)

---

<div class="post-metadata">

### Author: ![mthelm85](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mthelm85/32/224164_2.png) [@mthelm85](https://discourse.julialang.org/u/mthelm85)
#### Post date: [November 22, 2019, 7:14pm UTC](https://discourse.julialang.org/t/scale-y-continuous-percentage-format/31397/2 "2019-11-22T19:14:17Z")

</div>

How about this?

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

```julia
using Gadfly

x = collect(1:100)
y = collect(0.01:.01:1.0)

plot(
    x = x,
    y = y,
    Geom.line,
    Scale.y_continuous(labels = n -> "$(n*100)%"),
    Guide.yticks(ticks = collect(0.0:0.1:1.0))
)

```

---

<div class="post-metadata">

### Author: ![Phillip\_Sutton](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/phillip_sutton/32/7603_2.png) [@Phillip\_Sutton](https://discourse.julialang.org/u/Phillip_Sutton)
#### Post date: [November 22, 2019, 7:20pm UTC](https://discourse.julialang.org/t/scale-y-continuous-percentage-format/31397/3 "2019-11-22T19:20:01Z")

</div>

Ah!

Yes, that worked. I initally didnt add the Guide.yticks param, and ran into a fun old rounding error (30.0% was 30.000000000004%. But with ticks, worked perfectly.

Thank you!

---

<div class="post-metadata">

### Author: ![mthelm85](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mthelm85/32/224164_2.png) [@mthelm85](https://discourse.julialang.org/u/mthelm85)
#### Post date: [November 22, 2019, 7:24pm UTC](https://discourse.julialang.org/t/scale-y-continuous-percentage-format/31397/4 "2019-11-22T19:24:53Z")

</div>

You can also round in the `labels` function if need be:

```julia
plot(
    x = x,
    y = y,
    Geom.line,
    Scale.y_continuous(labels = n -> "$(round(Int, 100n))%"),
    Guide.yticks(ticks = collect(0.0:0.1:1.0))
)

```

![image](https://global.discourse-cdn.com/julialang/original/3X/e/b/eb6ed9286abca1ff922339a60c9ca30c4bb3ed61.png)

---

<div class="post-metadata">

### Author: ![Mattriks](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mattriks/32/351_2.png) [@Mattriks](https://discourse.julialang.org/u/Mattriks)
#### Post date: [November 22, 2019, 8:19pm UTC](https://discourse.julialang.org/t/scale-y-continuous-percentage-format/31397/5 "2019-11-22T20:19:41Z")

</div>

Gadfly is also compatible with [Uniful.jl](https://github.com/PainterQubits/Unitful.jl). Example:

```julia
using Gadfly, Unitful

y = 10*rand(10)*1u"percent"
p = plot(x=1:10, y=y, Geom.point)

```
