Plots and truncating numbers?

I’m plotting tiny subplots in a 4x4 matrix. Some of the subplots contain a large number of digits… making the plot really ugly:

I’m trying to map the trunc() function on the plots, e.g.,

x = ...
Y = ...
fg = []
for i in 1:15
    push!(fg,plot(x,trunc.(Y[i];digits=2)))
end
plot(fg...)

But it seems arbitrary whether the values on the ordinate axes are displayed with 2 digits or 1 digit or a large number of digits, etc.

Is there a way around this?

Please make an MWE which includes, among other things, the backend.

I’ll try to construct an MWE… not trivial – I plot results from the loss function of fitting various parameters to experimental data. If I use “nice” functions, the problem doesn’t appear, I think.

I suspect this is coming from an axes where numbers vary little. Also, the backend info may be useful, since it is not clear from your post.

I think this problem is solved. It was related to Showoff.jl

https://github.com/JuliaGraphics/Showoff.jl/commit/8502c2ec11f93c4f50c609ff4168aab31154b39d

Ok? I ran a Pkg.update() just before I took the screen shots today. Maybe the fix hasn’t been pushed out yet.

I thought I used PyPlot… I then discovered that the statement was pyplot instead of pyplot() resulting in a defaulting to GR.

You can specify a function to format your ticks

f(x)= exp(x)
using Plots,Formatting
gr()
plot(f,0.0:0.01:1.5,yscale=:log10,xscale=:identity,
    xformatter=x->format( x, precision=2 ),
    yformatter=x->format( log(x), precision=2 ))
1 Like

This is a bug that has been fixed - it may not have been released yet.

Superb! Looks beautiful!!