# How to get rid of scientific format numbers with Plots+pgfplots

**URL:** <https://discourse.julialang.org/t/how-to-get-rid-of-scientific-format-numbers-with-plots-pgfplots/4240>\
**Category:** Visualization\
**Tags:** question, pgfplot\
**Created:** [June 13, 2017, 10:42am UTC](https://discourse.julialang.org/t/how-to-get-rid-of-scientific-format-numbers-with-plots-pgfplots/4240 "2017-06-13T10:42:56Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [June 13, 2017, 10:42am UTC](https://discourse.julialang.org/t/how-to-get-rid-of-scientific-format-numbers-with-plots-pgfplots/4240/1 "2017-06-13T10:42:56Z")

</div>

MWE:

```julia
using Plots
pgfplots()
x = collect(linspace(0.01,0.5,100))
p = plot(histogram(x))
savefig(p, "/tmp/x.pdf")

```

The `0.05` label on the `x` axis shows up as `5⋅10⁻²`, which messes up the alignment. This is a more serious problem with grids, where things end up in the adjacent plot, etc, the above is just an MWE. If possible, I would like to have all numbers in plain decimal form.

---

<div class="post-metadata">

**Author:** ![anon61610682](https://avatars.discourse-cdn.com/v4/letter/a/ad7895/32.png) [@anon61610682](https://discourse.julialang.org/u/anon61610682)\
**Post date:** [June 13, 2017, 1:26pm UTC](https://discourse.julialang.org/t/how-to-get-rid-of-scientific-format-numbers-with-plots-pgfplots/4240/2 "2017-06-13T13:26:26Z")

</div>

I could not run MWE using `PGFPlots` on my system, but the below trick might solve your problem (which works on `GR` and `PyPlot`):

```julia
using Plots
pyplot()

x = linspace(0.01,0.5,100)
p = histogram(x, xticks = (0.1:0.1:0.5, 1:5), xlabel = "\$x \\cdot 10\$")

```

Above, I have used the `xticks` [attribute](https://juliaplots.github.io/attributes/) from `Plots`. Normally you solve this type of problem by [disabling the scientific notation](https://tex.stackexchange.com/questions/69978/disable-scientific-notation-for-y-axis-and-data-in-pgfplots#69981) in `PGFPlots`.

I hope this helps.

---

<div class="post-metadata">

**Author:** ![mkborregaard](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkborregaard/32/556_2.png) [@mkborregaard](https://discourse.julialang.org/u/mkborregaard)\
**Post date:** [June 13, 2017, 1:39pm UTC](https://discourse.julialang.org/t/how-to-get-rid-of-scientific-format-numbers-with-plots-pgfplots/4240/3 "2017-06-13T13:39:29Z")

</div>

`histogram(linspace(0.01, 0.5, 100), formatter = identity)` should work too.

---

<div class="post-metadata">

**Author:** ![anon61610682](https://avatars.discourse-cdn.com/v4/letter/a/ad7895/32.png) [@anon61610682](https://discourse.julialang.org/u/anon61610682)\
**Post date:** [June 13, 2017, 1:48pm UTC](https://discourse.julialang.org/t/how-to-get-rid-of-scientific-format-numbers-with-plots-pgfplots/4240/4 "2017-06-13T13:48:54Z")

</div>

Argh! I was stupid enough not to check this one ☹

I mean, apparently, I have not read the docs carefully 😠

Thanks for the neat answer! 👍

---

<div class="post-metadata">

**Author:** ![mkborregaard](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkborregaard/32/556_2.png) [@mkborregaard](https://discourse.julialang.org/u/mkborregaard)\
**Post date:** [June 13, 2017, 2:08pm UTC](https://discourse.julialang.org/t/how-to-get-rid-of-scientific-format-numbers-with-plots-pgfplots/4240/5 "2017-06-13T14:08:56Z")

</div>

Argh! I was stupid enough not to actually check with PGFPlots first 😃  
In fact, the formatter does not work here (!), so the best solution is your `xticks = (1:5)/10` 👍

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [June 13, 2017, 2:47pm UTC](https://discourse.julialang.org/t/how-to-get-rid-of-scientific-format-numbers-with-plots-pgfplots/4240/6 "2017-06-13T14:47:07Z")

</div>

Thanks for the replies. Apparently the issue came up before (see below), and there is a solution for using `PGFPlots.jl` directly, but how can I pass through a `style` argument via `Plots.jl`?

[https://github.com/sisl/PGFPlots.jl/issues/12](https://github.com/sisl/PGFPlots.jl/issues/12)

---

<div class="post-metadata">

**Author:** ![mkborregaard](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkborregaard/32/556_2.png) [@mkborregaard](https://discourse.julialang.org/u/mkborregaard)\
**Post date:** [June 13, 2017, 3:08pm UTC](https://discourse.julialang.org/t/how-to-get-rid-of-scientific-format-numbers-with-plots-pgfplots/4240/7 "2017-06-13T15:08:16Z")

</div>

You can’t shunt code through directly to the backends. In principle it should be possible to create a Plots attributes `backendcmd` that would allow passing an `Expr` to be evaluated in the backend call, but there isn’t presently one.

A better solution could perhaps involve a PR to Plots that fixed the `formatter` attribute for pgfplots()? It could also extend the general formatter arg to take the symbol `:numeric` (or whatever) for when you really don’t care for scientific notation.

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [June 14, 2017, 6:04am UTC](https://discourse.julialang.org/t/how-to-get-rid-of-scientific-format-numbers-with-plots-pgfplots/4240/8 "2017-06-14T06:04:40Z")

</div>

> [@mkborregaard](#):
>
> A better solution could perhaps involve a PR to Plots that fixed the formatter attribute for pgfplots()?

I would be very happy to make a stab at that, but I need some help to get started (which function to extend, an example of another backend I could use).
