I try to use TCanvas and TWebCanvas to draw TGraph2D, and it can be drawn normally. However, when I save the pdf with TCanvas, the pdf generated is just a picture inserted into the pdf file. What I want is an object-editable pdf file. Is there any solution?
How are you trying to edit the pdf? For me, with the same ROOT version (6.300/04, but on linux), I can edit the pdf with Inkscape, for instance (I moved the titles and parts of the graph):
If you try to edit in code, Emacs shows the code, but I’m not sure if all is editable (I don’t know if the “stream” parts are images or code).
Another option: save to .ps instead of .pdf (you can always convert ps to pdf later); the ps file also shows the code.
void webc() {
TCanvas *c = new TCanvas("c");
Double_t x, y, z, P = 6.;
Int_t np = 200;
auto dt = new TGraph2D();
dt->SetTitle("Graph title; X axis title; Y axis title; Z axis title");
auto r = new TRandom();
for (Int_t N=0; N<np; N++) {
x = 2*P*(r->Rndm(N))-P;
y = 2*P*(r->Rndm(N))-P;
z = (sin(x)/x)*(sin(y)/y)+0.2;
dt->SetPoint(N,x,y,z);
}
gStyle->SetPalette(1);
dt->Draw("surf1");
TWebCanvas *wc = new TWebCanvas(c,"wc",10,10,500,500);
wc->Show();
}
The code above, displaying on Firefox, results in these files: Canvas.pdf (109.7 KB) Canvas.ps (383.6 KB)
Also to use web canvas in normal ROOT scripts I recommend to use --web=chrome option.
Direct creation and configuring of TWebCanvas only needed for special applications like qtweb.