पर प्रस्तुत करें क्या यह एक कैनवास पर सीधे गढ़्लाई प्लॉट प्रस्तुत करना संभव है? मैं gtk का उपयोग कर जूलिया जीयूआई विकसित करना चाहता हूं जो Gadfly भूखंडों को प्रस्तुत करता है।सीधे ग्वाफ्लाई प्लॉट को एक जीटीके कैनवास
मैं की तर्ज पर कुछ के लिए उम्मीद कर रहा हूँ:
some_plot = plot(x=[1,2,3],y=[4,5,6])
draw(ctx::CairoContext, some_plot)
या
draw(c::GtkCanvas, some_plot)
मेरे वर्तमान दृष्टिकोण एक png की बचत होती है और उसके बाद छवि लोड करता है। जाहिर है नहीं इष्टतम:
ctx = getgc(canvas)
canvas_w = width(canvas)
canvas_h = height(canvas)
save(ctx)
set_source_rgb(ctx,1,1,1)
rectangle(ctx,0,0,canvas_w,canvas_h)
fill(ctx)
restore(ctx)
some_plot = plot(x=[1,2,3],y=[4,5,6])
draw(PNG("myplot.png", 8inch, 4inch), some_plot)
save(ctx)
image = read_from_png("myplot.png")
w = image.width
h = image.height
translate(ctx, canvas_w/2, canvas_h/2)
scale(ctx, canvas_w/w, canvas_h/h)
translate(ctx, -0.5*w, -0.5*h)
set_source_surface(ctx, image, 0, 0)
paint(ctx)
restore(ctx)
धन्यवाद
अच्छा सवाल! – hdante