Here's a not-quite-minimal example:
DOCUMENT(); loadMacros("PGstandard.pl", "MathObjects.pl", "RserveClient.pl", "PGML.pl"); Context("Numeric"); # indicate the Context (this is MathObjects) #--------------------------------------- # problem set-up section #--------------------------------------- $shape = random(3,7,1); $rate = random (6,10,2); rserve_eval("library(ggformula)"); $img = rserve_start_plot('png'); # use white background, larger fonts rserve_eval("theme_set(theme_bw(base_size = 30))"); # note use of print() here rserve_eval("print(gf_dist('gamma', shape = $shape, rate = $rate))"); $image_path = rserve_finish_plot($img); #---------------------------------------- # text section #--------------------------------------- TEXT(beginproblem()); BEGIN_PGML >> [@ image($image_path, width=>400, height=>200) @]* << END_PGML ENDDOCUMENT();