GR.jl
GR.jl copied to clipboard
Cropped image
Hi, I'm unable to fix a cropping issue. When I plot, the picture is cropped from left and bottom, making it impossible to see xlabel, ylabel and full y ticks number.
Numbers on the y axis should be 0.98 etc. Trying to fix it with margin
attribute doesn't work. Any suggestions?
I tried this and get the following result:
using Plots
y = 0.98 .+ rand(10) .* 0.01
plot(y)
Could you please provide your example?
Still the same even with this example. I'm on Linux Lustre and the gksqt is not working properly - but I don't have the rights to install additional dependencies. Therefore I'm saving it directly do pdfs. I guess I'll be using PlotlyJS, which is working properly.
I also experience this issue. It occurs when generating the plots in a headless environment. Generating them in an environment with a head works fine.
In a headless environment, pls try
% env GKSwstype=100 julia
julia> using Plots
julia> y = 0.98 .+ rand(10) .* 0.01
julia> plot(y)
and use savefig(...)
to generate output.
I get this image:
Which Plots and GR version are you using - I can't reproduce this.
] st Plots
] st GR
import GR
GR.version()
versioninfo()
For me, it's
julia> Plots.GR.version()
"0.50.0.post27"
(@v1.4) pkg> st Plots
Status `/usr/local/lib/julia/environments/v1.4/Project.toml`
[91a5bcdd] Plots v1.5.0
(@v1.4) pkg> st GR
Status `/usr/local/lib/julia/environments/v1.4/Project.toml`
[28b8d3ca] GR v0.50.1 #master (https://github.com/jheinen/GR.jl.git)
and the PNG (or whatever output) is ok:
Plots version 1.5.0
. I don't have GR installed directly but it is in the manifest at version 0.50.1
.
I bet you can't reproduce it because you are opening a terminal on a machine with a head. That image you posted definitely looks like it is running in an environment with a head. Try SSH'ing into a machine and running Julia over the SSH connection.
I did that:
% ssh ifflinux
Last login: Tue Jun 30 18:20:41 2020 from 93.205.94.18
jheinen@iff1702:~% env GKSwstype=100 julia
_
_ _ _(_)_ | Documentation: https://docs.julialang.org
(_) | (_) (_) |
_ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 1.4.2 (2020-05-23)
_/ |\__'_|_|_|\__'_| | Official https://julialang.org/ release
|__/ |
julia> using Plots; y = 0.98 .+ rand(10) .* 0.01; plot(y); savefig("t.pdf")
julia>
jheinen@iff1702:~% logout
Connection to ifflinux closed.
jheinen@mb-pro ~ % scp -p ifflinux:t.pdf .
t.pdf 100% 7394 299.8KB/s 00:00
jheinen@mb-pro ~ % open t.pdf
Did you download a recent run-time: ENV["GRDIR"] = ""; ] build GR"
, or, are you probably using an old GR version? What's the value of GRDIR
after importing GR? (ENV["GRDIR"]
)
The version of GR in the Manifest.toml
file is 0.50.1
. For some reason, the version of Plots.GR
is 0.50.0
.
julia> ENV["GRDIR"]
"/home/salmon/.julia/packages/GR/Atztx/src/../deps/gr"
Hi, I am having a related issue. I realized that when I adjust the size of the plotting area using ``gr(size=...)'' , it does not leave space for the axis labels. It seems like there is one good size/proportion and that any deviation from it will crop the axis labels. For example, when I do
using Plots
gr(size=(400,200))
y = 0.98 .+ rand(10) .* 0.01
plot(y)
xaxis!("X axis"); yaxis!("Y axis")
I get
But when I do
using Plots
gr(size=(600,100))
y = 0.98 .+ rand(10) .* 0.01
plot(y)
xaxis!("X axis"); yaxis!("Y axis")
I get
Does anyone have an idea what this could be due to? Thanks for the help,
This problem can't be fixed in GR
. Plots
should use the gr_inqtext
function to obtain the exact bounding box of the text to be drawn and reserve enough space for the labels and annotations.