GR.jl icon indicating copy to clipboard operation
GR.jl copied to clipboard

Feature request : Zoom, pan

Open grero opened this issue 8 years ago • 25 comments

GR is a great package, especially with respect to plotting speed. In the past I have used Gadly with the GTKInteract package, which allows me to zoom/pan around my plots. I'm sure these features are on the road map for GR as well, so this is just me registering my interest in those features. Keep up the good work!

grero avatar Sep 22 '16 02:09 grero

This is really the main issue stopping me to us GR (with Julia). I also could not find the source code of GKS QtTerm. Is it open source?

ufechner7 avatar Dec 16 '18 14:12 ufechner7

Any update on this? Where is the source code of GKS QtTerm?

ufechner7 avatar Mar 28 '19 12:03 ufechner7

I don't know the current status of the work on QtTerm, but you can find the source code of gksqt in the GR runtime repository: https://github.com/sciapp/gr/tree/master/lib/gks/qt

FlorianRhiem avatar Mar 28 '19 13:03 FlorianRhiem

I have seen an interactivity in Jupyter demonstrated at the Josef Twitter. I am looking forward to see it soon here, christmas are approaching:-)

otobrzo avatar Dec 19 '19 19:12 otobrzo

This is now possible (albeit not yet via the Plots.jl interface): https://forem.julialang.org/jheinen/gr-going-interactive--4dnj

$ GRDISPLAY=plot juliap
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.9.0 (2023-05-07)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia> using GR

julia> plot(randn(20,5), labels=("a", "b", "c", "d", "e"))

mauro3 avatar May 16 '23 15:05 mauro3

Well, it does not work for me, using Julia 1.9.0 on Ubuntu 22.04.

I don't get an error message, but no plot window appears...

ufechner7 avatar May 17 '23 13:05 ufechner7

Well, it does not work for me, using Julia 1.9.0 on Ubuntu 22.04.

I don't get an error message, but no plot window appears...

Are you using GR v0.72.4 and ist the window title "GR Plot"?

jheinen avatar May 17 '23 13:05 jheinen

(GR) pkg> st Status ~/repos/GR/Project.toml [28b8d3ca] GR v0.72.4 https://github.com/jheinen/GR.jl.git#master

ufechner7 avatar May 17 '23 13:05 ufechner7

julia> ENV["GRDISPLAY"]="plot"
"plot"
julia> using GR
julia> plot(randn(20,5), labels=("a", "b", "c", "d", "e"))

(GR) pkg> st
Status `~/repos/GR/Project.toml`
  [28b8d3ca] GR v0.72.4
(GR) pkg> 

And without window not window title...

ufechner7 avatar May 17 '23 13:05 ufechner7

... and you are on the command line without any GKS_WSTYPE settings?

jheinen avatar May 17 '23 13:05 jheinen

Yes, on in the REPL...

ufechner7 avatar May 17 '23 17:05 ufechner7

Could you please update GR.jl (0.72.5) and enable debugging:

JULIA_DEBUG=GR GRDISPLAY=plot julia
using GR
plot(randn(20,5), labels=("a", "b", "c", "d", "e"))

jheinen avatar May 18 '23 07:05 jheinen

With this version zoom and pan worked!

But only a few seconds. Then I got:

julia> using GR

julia> plot(randn(20,5), labels=("a", "b", "c", "d", "e"))
┌ Debug: Found GRDISPLAY in ENV
│   display_name[] = "plot"
└ @ GR ~/.julia/packages/GR/SiORT/src/GR.jl:325
┌ Debug: Default GKS_ENCODING
│   ENV["GKS_ENCODING"] = "utf8"
└ @ GR ~/.julia/packages/GR/SiORT/src/GR.jl:362

julia> Segmentation fault (core dumped)

ufechner7 avatar May 18 '23 19:05 ufechner7

I can't reproduce the problem with the run-time version we provide. The problem seems to occur only with the GR_JLL version - so it is hard for me to debug this. I will have to build my own JLL binaries with debugging enabled.

jheinen avatar May 21 '23 08:05 jheinen

The problem should be fixed with 0.72.6

jheinen avatar May 23 '23 08:05 jheinen

You closed this issue a bit too fast.

It works now fine if I start Julia with:

JULIA_DEBUG=GR GRDISPLAY=plot julia

Thanks a lot for the good work! :)

But it does NOT work if I start Julia with:

GRDISPLAY=plot julia

In this case I get the error message:

julia> include("plot.jl")
cannot connect to host localhost port 8002: 

Content of plot.jl:

using GR
plot(randn(20,5), labels=("a", "b", "c", "d", "e"))

Will you re-open this bug, or shall I create a new bug?

ufechner7 avatar May 23 '23 16:05 ufechner7

It seems to me, that grplot is not stopped correctly when using the GR_JLL version on Linux. This doesn't happen with "our" GR distribution. As a workaround, you might killall grplot. That is not a solution, of course.

I'm trying to find a way to actually exit grplot so that the required socket can be reconnected in a following session.

Maybe it has to do with the overlong LD_LIBRARY_PATH (> 5k characters) - I don't know.

jheinen avatar May 23 '23 19:05 jheinen

@ufechner7 : With GR 0.72.7 this issue should be fixed - it was a timing problem that essentially occurred on Linux systems with more recent kernels. On our test machines the problem did not occur anymore.

Once the version is registered, it would be nice if you could try again.

jheinen avatar May 25 '23 15:05 jheinen

First it was working for me, now it doesn't. I will try to figure out why.

ufechner7 avatar May 25 '23 20:05 ufechner7

What is working:

using GR
sleep(1)
plot(rand(20,5))

This even works if put into a file and executed repeatedly.

But if I close the GR window and include the file above again no new window pops up.

If I quit Julia, restart it with

GRDISPLAY=plot julia --project

and include the file above it works again.

The sleep command is not needed.

Summary: It works the first time, but if you close the GR window it will not pop up again, unless you close the Julia REPL session and restart Julia.

ufechner7 avatar May 25 '23 20:05 ufechner7

It works the first time, but if you close the GR window it will not pop up again, unless you close the Julia REPL session and restart Julia.

This is the expected behaviour. Closing the window (or leaving Julia) will stop the grplot background process - it's only started once.

jheinen avatar May 26 '23 01:05 jheinen

But that makes this feature pretty useless... And it is not the way the normal GR windows behave...

ufechner7 avatar May 26 '23 13:05 ufechner7

I don't quite understand why you should stop the grplot process. Or is it just to minimize the window?

Due to performance reasons it makes sense that the process is started only once and runs during the whole Julia session. Since GR is also used in other environments (C, Python, Ruby), we unfortunately do not have arbitrary design options here.

If it is only about minimizing the window, this should be feasible.

jheinen avatar May 26 '23 14:05 jheinen

Well, my workflow is that I open plot_a, look at it, close it, look at plot_b, close it change some parameters, look at plot_a again... I don't want to restart Julia in between. I just want to be able to close plots I am currently not interested in. I don't stop the grplot process on purpose, I just close the plot window.

Perhaps you could catch the "click on close icon" event end hide the window instead of closing it?

ufechner7 avatar May 26 '23 15:05 ufechner7

And it would be nice to be able to open a new window each time you display a plot. I like the way PythonPlot works, I can have multiple plots on the screen and compare them. Plots.jl has the "reuse=false" option for that. Unluckily this is currently only supported by PythonPlot as far as I know.

ufechner7 avatar May 26 '23 15:05 ufechner7