TCanvas resolution&quality changes if diving to pads

Hello

I’m trying to add a legend to one of my figures that doesn’t fit on the figure itself. So I’d like to add it next to it, and I thought I’d do that by doubling the size of the canvas, and making two pads, one for the figure, one for the legend.
Here is the figure with the image quality I get when plotting just the figure, this is made with a 600x800 TCanvas:

canvas = ROOT.TCanvas('c', 'Title', 600, 800)

ComparisonROCplot_sparseNoLegend_pt3.5.pdf (19.2 KB)

However, when trying to add the legend on a new pad, I get something different. So I tried using a 1200x800 TCanvas:

canvas = ROOT.TCanvas('c', 'Title', 1200, 800)

And then I tried dividing it into two pads. At later points I may want to divide them asymmetrically, so I’m not using TPad::Divide(), instead I’m explicitly making two pads. The pad for the figure is created on the right for x in (0.5,1.0):

figurepad = ROOT.TPad("figurepad", "figurepad",0.5,0.0,1.0,1.0)

and after Drawing the frame and content for the figure, the pad for the legend is created in (0.0,0.5) with:

legendpad = ROOT.TPad("legendpad", "legendpad",0.0,0.0,0.5,1.0)

After that the legend is Drawn and the image is saved. This is the result:
ComparisonROCplot_sparse_pt3.5.pdf (20.1 KB)

As you can see, the pdf is much, much smaller in size (resolution): it’s just 787x508 pixels, a number that I don’t understand how it computes, but even the styles on the figure itself are changed a bit. The lines are relatively thicker, and the dashed lines have longer lines and shorter spaces. I did not touch anything regarding the cosmetic code of the figure. How does this happen?
I tried varying the TCanvas size in its constructor, but it does not seem to matter. Even if I increase it to 2400x1600, I get this same output - a small, 787x508 sized pdf with different styles.
Why does this happen, what should I do differently?

Thank you for your time


ROOT Version: 6.14/04
Platform: linuxx8664gcc
Using pyroot


Can it be that your screen resolution is “small”?

It’s 1920x1080p, but they can be compared regardless of screen resolution - if you download the pdfs, and set them in a pdf viewer to 100% zoom, you can see that the second one which is supposed to be twice the size in x, is actually much much smaller instead. I got the exact resolution value by importing the pdf to gimp (at 100% res) and checking the size: 787x508 pixels.

I guess @couet would need to say how the user can set specific x and y sizes (and the aspect ratio) for “.pdf” (and “.ps”) files.

You can see in the PDF document properties that the width is 7.88 inches, or 20 cm, for both files. See also

What you could do is change the paper size to obtain the width that you need; as long as the width is what you want, the height you specify here doesn’t seem to matter, as it will be adjusted to the aspect ratio of your canvas, as you can see from your PDFs, which both have a width of 20 cm but different heights in spite of the default of 26.
So, if you want the dimensions to change in a consistent way when you change the pixel sizes, you will have to do some simple calculation to pass the corresponding cm to SetPaperSize.

@dastudillo explanations are correct. Let me know if you need more help. May be also a reproducer.

Thanks for the suggestions, and sorry for the belated reply from my part.

Setting the PaperSize does seem to bring back the quality, however, now I’m facing what’s exactly described here: PDF PaperSize
I don’t seem to be able to increase the pdf size above a limit, and the figure just gets cropped.
ComparisonROCplot_sparse_pt3.5.pdf (20.0 KB)

In the link they say that it seems to work if using .ps, and the size also seem to change correctly with ps for me. But it’s so much easier to work with pdf though especially when I have to send the figures to colleagues. Is there no way to make this work with a pdf?

Thanks

1 - It’s better if you provide the code you used to get that result
2 - If ps looks fine you can simply convert it to pdf outside ROOT, e.g. with ps2pdf