Better resolution in plots

Hi there,

I have searched the forum for quite some time but only found in my opionion outdatet posts. Are there any changes for improving the image resolution in plots in a easy and convenient way? I.E. I would like to set an option when saving the canvas DPI=400 or something like that.

with best regards,
Nikita


Please read tips for efficient and successful posting and posting code

ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided


If you want “raster graphics”, in “batch mode”, you can directly create a canvas with any size (in pixels). Otherwise, your canvas’s windows size is basically limited to the size of your display (in pixels), but you can use the TCanvas::SetCanvasSize method to set any size (scroll bars may be added to the canvas’s window).

If you want “vector graphics”, you may want to play with the “PostScript output” (you can “cheat” in ROOT and increase the “paper size”, then “shrink” it outside of ROOT):

The last part is not correct. Even outside batch mode, you are not limited to the pixels of your display.
Both the window containing the canvas, and the canvas itself (inside that window), can be larger than the screen size. If the canvas is larger than the window, ROOT will just add scroll bars; if the canvas is larger than the screen, not all of it will be visible, just like any other window, but it can be resized just as well.

{
   auto c = new TCanvas("c","c");
   c->SetCanvasSize(1500, 1500);  // even if your screen has smaller width/height
   c->SetWindowSize(500, 500);  // smaller than the canvas, so ROOT will add scroll bars
}

@dastudillo You’re right (I corrected my previous post). I forgot that the “raster graphics” (file) output was fixed (quite a long time ago actually).

Whithout chaninging you code you can use: SetImageScaling.

Hi,
sorry that I didn’t reply for so long. You are absolutly right. Do you know how i can make a line like f(x) = x look not “pixelated” with eddges but smooth if you know what i mean. Increasing the resolution doesn’t seem to work for me here.
with best regards,
Nikita

On screen, the same line may look “smooth” or ragged, depending on several factors, like the size of the canvas, angle of the line (aspect ratio), and thickness of the line. That’s because it is drawn as a raster image; to make it always smooth it has to be a vector. If you save it as a ps, eps or pdf, it will look smooth; if you save it as gif, png or jpg, it won’t. Compare the png and PDF versions of this:

root [0] TCanvas *c=new TCanvas("c","c",400,400)
root [1] TF1 *f = new TF1("f","x",0,5)
root [2] f->SetLineWidth(3)
root [3] f->Draw()

c
c.pdf (14.0 KB)

1 Like

Maybe you want something like: your_function->SetNpx(1000);

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.