Colored 2D histograms in pdf output

Yes, that’s a good idea ! painting the stroke around the box makes it ok. I will think where is the best place to put it. Not that the palette needs also this extra line painting. May be something to be put at the pdf level only.
Anyway it seems the right direction.
Plus the size increase is not too big … 31kb vs 35kb

This problem is now fixed in both PDF and PostScript outputs. Your idea to make the stroke around the box was the right approach. But I did it in the better way in the PDF and PS drivers themselves. It is more general, fixes all the boxes and doesn’t change the file size. So all the tricks to bypass this issue are not needed anymore.

The PDF and PS outputs now work with buggy previewers… finally !! :slight_smile:

Great, Oliver!
I would like to know what did you change there.
Maybe plotting colored rectangles always in this way is not the best idea.
At least, it should be possible to select/deselect this option.
I have done some more tests with the “strk” option enabled/disabled.

Take a look to this plot with normal root behavior (no stroke):
Snapshot1-rake-v10kA.G.SR2.RI.3D_20.pdf (320 KB)

The buggy previewers show the white lines like always, but it also provides some kind of transparency.
This is cool, and one can see the orange histogram (electrons) behind the gray histogram (plasma).

With the new option “strk” that is what happens:
Snapshot1-rake-v10kA.G.SR2.RI.3D_20.strk.pdf (562 KB)

No white lines, no transparency …

At the end i don’t know which one I like the most #-o

Would be possible to have transparency and no white lines?
This would be great!

Oh, this is interesting.
Playing with the option “strk”, I can make one of the histograms (grey) transparent (with white lines) and the other two opaque (with no lines):
Snapshot1-rake-v10kA.G.SR2.RI.3D_20.hybrid.pdf (355 KB)

This a feature only for buggy previewers! funny, but it is the option that a like the most so far…
It would be then convenient to activate the stroke as an option when drawing the histogram and not in general for every ps or pdf.
Cheers!

We do not need the strk option. I did the change at the very low level in ps and pdf classes. The changes are minors. I just told ps and pdf to always stroke filled boxes.

Thanks couet for your modifications, that’s great news. I will be now able to export my TH2 to pdf instead of png :smiley:

Concerning delaossa, I think that what one should ask for is to have the possibility of filled 1D or 2D transparent histograms also in the pdf output, rather than profiting from an anti-aliasing bug for mimicking transparency. There is this post:
[Transparent histogram fill style

But it seems that the exported pdf does not contain the transparency for solid areas, and the densely dotted fill style mimicks it but is ugly for pdf. In my case, I use full solid areas, that are not transparent in the exported pdf, and then edit by hand the pdf with inkscape and add the transparency to these fill areas (now fill areas and strokes :smiley: ). Then I export back to pdf and it renders perfectly.

If inkscape can do it, then ROOT may also be able to include this in the future. But I think we need to create another post for this “new” request :wink:

Transparency now works for pdf and i have implemented transparent palettes. I will check monday what Alberto means

That’s nice, I did not realize that before! Thanks for the info.

By using h->SetFillColorAlpha it works for 1D solid filled areas (no need for fill styles). Alberto, then you should define your gray 2D histogram with a high-transparent palette for seeing the orange one behind, I guess.

SetPalette has the Alpha parameter too:

root.cern.ch/root/htmldoc/TColo … SetPalette

Hello Oliver,
This is great that transparency works now in pdf.
I have just 2 fast questions:

  1. Which version of ROOT do I have to download to test it?
    I downloaded and installed from source tha latest ROOT 6 pro version.
    Can I update from there somehow to get the latest changes?
  2. Does not the stroke line that you added around the colored bins to “fix” buggy previewers kill transparency?
    Cheers,
    Alberto

Yes this one is fine.

What do you mean by “kill transparency” ?.. they are 2 different issues. I hope you do not really on the buggy behaviour to make you plots. You should not. This behaviour is now gone. Now you should use the transparency properly as explained in the doc.

Sorry Oliver I couldn’t try yet the new transparency feature as I have a problem with my rootlogon.C script in ROOT 6:
[root.cern.ch/phpBB3/viewtopic.p … 107#p82905](Problem loading customized style while launching ROOT

What I meant with kill transparency is the following:
Now ROOT 6 draws a stroke around the bins in the PDF PS output, isn’t?
Then although colored areas have transparency through the Alpha parameter, it will not affect the stroke lines, which will remain opaque.
This is only a guess since I haven’t tried yet…

I am not doing the line myself… PDF does it … but nevertheless there is an issue with transparency and and stoke line…
Looking at it now.

You had a good point. The "b* PDF operator does fill and stoke, but in case of transparent colors, because there is a double pass on the stroke width, the border appears darker than the inside of the box.
In case of transparency the operator “f*” should be used instead (like before). Luckily, with transparent colors, the preview bug in smoothing does not show. The fix is in now.

Very well! I still get the white lines with root-6.02.05.
LotovRadius.pdf (30.6 KB)
How can I get the new modified files in order to not to re-download and re-compile the whole thing?

It is enough to replace $ROOTSYS/graf2d/postscript/src/TPDF.cxx by the one attached.
TPDF.cxx (77.5 KB)

OK. If one doesn’t set any transparency (alpha = 1) it works nicely :
LotovRadius.pdf (31 KB)
But as soon as one sets the color palette with alpha, the white lines appear again.
This is an example with alpha = 0.7:
LotovRadiusAlpha0.7.pdf (40.4 KB)
Of course if one decreases the alpha so the colors are more transparent, there is a point in which one cannot distinguish the white lines.
Now alpha = 0.2:
LotovRadiusAlpha0.2.pdf (31.2 KB)
Cheers!

Yes, I agree. I see the same too. not that in the case of Alpha = 0.7 it looks better if smoothing is on than of in the previewer. At least you do not have to play anymore with the preview settings.
Now I have now idea yet on how to improve the transparency case.
At least alpha=1 is fine which is 99% of the plots…

Hello! This is how the plot looks now with the latest changes you did in TPDF:
Snapshot1-rake-v10kA.G.SR2.RI.3D_20.new.pdf (292 KB)
Which is not bad already!
However, if you zoom into the section where the gray histogram overlays the orange we see that the line stroke for non-transparent histograms is too thick.
We can directly compare thanks to the white lines in the transparent histogram (the gray).
Is not possible to make this stroke thiner or even to find a solution that doesn’t involve a stroke at all?

I case of transparent color there is no stoke at all right now …
See the if statement in TPDF:DrawBox