I’m exploring the Gtk.jl package to create simple GUIs to visualize data and I wanted to ask if it is it possible to draw a plot created with some backend of Plots.jl (say GR for example) into a Gtk window. I seem to remember that this feature was available at some point, but I couldn’t find any relevant documentation.
I haven’t actually embedded GR in gtk but I have seen this file over in the GR package examples folder. Maybe it will help point you in the right direction: https://github.com/jheinen/GR.jl/blob/master/examples/gtk_ex.jl
Immerse.jl does that via Gadfly.
It would be nice if it could support other plotting backends. I thought a bit about it at some point, but last time I tried GR I ran into some issues.
If the backend cannot draw on a GtkCanvas directly, you could also just copy an image on it.
The example GR file gives a segmentation fault, but maybe some variation of it can work, thanks for the link.
I was thinking about that option as well, is there a simple way to convert a plot to an image?
InspectDR.jl is a pure-Julia plotting solution that leverages the Cairo.jl & Gtk.jl packages to draw plots & build multi-plot GUIs respectively:
I have not really published an API for integrating the InspectDR plot widget into external applications, but it is designed with the following layers:
- Cairo layer: Generates plots as images.
- GTK widget layer: Defines a GTK widget that can be integrated in a Gtk.jl applications.
- GTK application layer: What I assume most users would use.
To integrate a GTK widget in your own application, you could look at how
PlotWidget objects are created/used in the following file:
Note that the GTK widget is not a simple plot image. It provides interactivity allowing one to pan/zoom, add “delta” markers, etc through mouse/key bindings.
Feel free to integrate with your own application - but please note that I have not put tons of effort defining how one manipulates the
PlotWidget object. Its interface might need to change to allow for future improvements.
I am using Winston.jl but InspectDR.jl seems to look quite good as well.