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

#1

MWE:

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.

#2

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

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 from Plots. Normally you solve this type of problem by disabling the scientific notation in PGFPlots.

I hope this helps.

#3

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

#4

Argh! I was stupid enough not to check this one

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

#5

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

#6

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?

#7

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.

#8

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).