You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I'm trying to use Plots with GR in Gtk4, the example provided works well but I'd like to be able to take any plot and display it on the canvas. Is there a way to do that ? I couldn't figure it out. Calling display do show the plot initially but it doesn't redraw when the size change. Thanks!
using Gtk4, Serialization
using Plots
using Printf
c = GtkCanvas()
p = scatter(rand(100))
function _plot(ctx, w, h)
ENV["GKS_WSTYPE"] = "142"
ENV["GKSconid"] = @sprintf("%lu", UInt64(ctx.ptr))
#plot(p, size=(w, h))
display(p)
end
@guarded draw(c) do widget
ctx = getgc(c)
w = width(c)
h = height(c)
@show w, h
rectangle(ctx, 0, 0, w, h)
set_source_rgb(ctx, 1, 1, 1)
fill(ctx)
_plot(ctx, w, h)
end
win = GtkWindow("Gtk4 example", 600, 450)
win[] = c
e = GtkEventControllerMotion(c)
function on_motion(controller, x, y)
win.title = @sprintf("(%g, %g)", x, y)
reveal(c) # triggers a redraw
end
signal_connect(on_motion, e, "motion")
The text was updated successfully, but these errors were encountered:
Thanks for the quick answer. What I'm trying to do is to have a Canvas opened and then display a plot on it, then plot another one, etc. but I your example the plot is "hardcoded" in the _plot function and redone at each update.
Something like that but this doesn't redraw when resizing :
p = plot(randn(10, 3))
function _plot(ctx, w, h)
ENV["GKS_WSTYPE"] = "142"
ENV["GKSconid"] = @sprintf("%lu", UInt64(ctx.ptr))
gr(show=true)
display(p)
end
Hi, I'm trying to use Plots with GR in Gtk4, the example provided works well but I'd like to be able to take any plot and display it on the canvas. Is there a way to do that ? I couldn't figure it out. Calling display do show the plot initially but it doesn't redraw when the size change. Thanks!
The text was updated successfully, but these errors were encountered: