jheinen / GR.jl

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

Feature request : Zoom, pan #40

Open grero opened 8 years ago

grero commented 8 years ago

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!

ufechner7 commented 5 years ago

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 commented 5 years ago

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

FlorianRhiem commented 5 years ago

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

otobrzo commented 4 years ago

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

mauro3 commented 1 year ago

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"))
ufechner7 commented 1 year ago

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...

jheinen commented 1 year ago

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"?

ufechner7 commented 1 year ago

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

ufechner7 commented 1 year ago
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...

jheinen commented 1 year ago

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

ufechner7 commented 1 year ago

Yes, on in the REPL...

jheinen commented 1 year ago

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"))
ufechner7 commented 1 year ago

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)
jheinen commented 1 year ago

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 commented 1 year ago

The problem should be fixed with 0.72.6

ufechner7 commented 1 year ago

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?

jheinen commented 1 year ago

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 commented 1 year ago

@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.

ufechner7 commented 1 year ago

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

ufechner7 commented 1 year ago

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.

jheinen commented 1 year ago

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.

ufechner7 commented 1 year ago

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

jheinen commented 1 year ago

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.

ufechner7 commented 1 year ago

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 commented 1 year ago

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.