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.
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.
1 Like
histogram(linspace(0.01, 0.5, 100), formatter = identity)
should work too.
2 Likes
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!
1 Like
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
1 Like
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
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.
1 Like
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).
1 Like