jheinen / GR.jl

Plotting for Julia based on GR, a framework for visualisation applications
Other
357 stars 76 forks source link

Cropped image #318

Open masenka31 opened 4 years ago

masenka31 commented 4 years ago

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.

image

Numbers on the y axis should be 0.98 etc. Trying to fix it with margin attribute doesn't work. Any suggestions?

jheinen commented 4 years ago

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?

Screen Shot 2020-06-08 at 11 41 40
masenka31 commented 4 years ago

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.

Octogonapus commented 4 years ago

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.

jheinen commented 4 years ago

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.

Octogonapus commented 4 years ago

I get this image: test

jheinen commented 4 years ago

Which Plots and GR version are you using - I can't reproduce this.

] st Plots
] st GR
import GR
GR.version()
versioninfo()
jheinen commented 4 years ago

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:

Screen Shot 2020-06-30 at 18 13 30
Octogonapus commented 4 years ago

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.

jheinen commented 4 years ago

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

t.pdf

jheinen commented 4 years ago

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"])

Octogonapus commented 4 years ago

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"
jeanpauphilet commented 2 years ago

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 good

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 cropped

Does anyone have an idea what this could be due to? Thanks for the help,

jheinen commented 2 years ago

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.