Line attributes in lego1 & lego2

Hi there,

Attached is a patch so that line attributes can be used in lego plots (git diff).
SetLineColor is taken into account for lego{,1,2}, SetLineStyle & SetLineWidth for lego only (see below).

{ TH2D * histo = new TH2D ("histo","histo", 3,-3.,3., 3,-3.,3.) ; histo->SetBinContent(2,2,1.) ; histo->SetFillColor(kRed) ; histo->SetLineColor(kOrange) ; histo->SetLineStyle(3) ; histo->SetLineWidth(5) ; histo->SetStats(kFALSE) ; TCanvas * canvas = new TCanvas ("canvas") ; canvas->Divide(3,2) ; canvas->cd(1) ; histo->Draw("lego , fb") ; canvas->cd(4) ; histo->Draw("lego ,0,fb") ; canvas->cd(2) ; histo->Draw("lego1, fb") ; canvas->cd(5) ; histo->Draw("lego1,0,fb") ; canvas->cd(3) ; histo->Draw("lego2, fb") ; canvas->cd(6) ; histo->Draw("lego2,0,fb") ; }
Could this (or any better version) be committed to the trunk?

Cheers,
Z
lego12_attline.tgz (1.65 KB)


I will look …

I do not see for what you need that … but why not …

[quote]I do not see for what you need that… [/quote]As an intermediary beween LEGO1 and LEGO3.
This way the user can choose the color of bin edges (typically something more discreet than black (LEGO1) but not nothing (LEGO3)).
While implementing color, I added style and width for consistency.
Cheers,
Z

Ok. makes sense.

now in the trunk

Thx Olivier :slight_smile:
See you around :wink:
Z

Actually this does not work for THStack.
The patch below fixes this.
Attached’s also the program I used to make sure everything went fine.
All the pictures generated (png & pdf) lie in the “before & after patch” archives.
Below’s an example:


Could you please commit this to the trunk?

Please note the “Draw bottom face” part of TPainter3dAlgorithms::LegoCartesian() should be further upgraded when THStack will correctly handle TH2 with negative data (see THStack & TH2 with negative values)

Cheers,
Z
lego_attline_patch.gitdiff.tgz (3.25 KB)
zztest.cpp (8.77 KB)
canvases.afterpatch.tgz (374 KB)
canvases.beforepatch.tgz (418 KB)

[quote]Please note the “Draw bottom face” part of TPainter3dAlgorithms::LegoCartesian() should be further upgraded when THStack will correctly handle TH2 with negative data (see viewtopic.php?f=3&t=16569)[/quote]To make myself clear, the patch above perfectly works with negative valued TH2 (see below).
The problem is with THStack only (THStack & TH2 with negative values).
So the patch above deserves to be commited on its own (see the fixes it allows in the “before & after patch” archives in the previous post).

[code]{
gStyle->SetHistMinimumZero(kTRUE) ;
gStyle->SetTitleFontSize(0.10) ;

TH2D * histo = new TH2D (“histo”,“histo”,3,-3.,3.,3,-3.,3.) ;
histo->SetBinContent(1,1, 1.) ;
histo->SetBinContent(1,2, 3.) ;
histo->SetBinContent(1,3, 4.) ;
histo->SetBinContent(2,1,-6.) ;
histo->SetBinContent(2,2, 0.) ;
histo->SetBinContent(2,3, 9.) ;
histo->SetBinContent(3,1,-8.) ;
histo->SetBinContent(3,2, 2.) ;
histo->SetBinContent(3,3,-5.) ;
histo->SetMinimum(-10.) ;
histo->SetMaximum( 10.) ;
histo->SetStats(kFALSE) ;
histo->SetFillColor(kRed) ;
histo->SetLineColor(kAzure+1) ;
histo->SetLineStyle(2) ;
histo->SetLineWidth(2) ;

THStack * hstack = new THStack (“hstack”,“hstack”) ;
hstack->Add(histo) ;
hstack->SetMinimum(-10.) ;
hstack->SetMaximum( 10.) ;

TCanvas * canvas = new TCanvas (“canvas”) ;
canvas->Divide(2,3) ;
canvas->cd(1) ; gPad->SetTheta( 30.) ; gPad->SetPhi( 30.) ; histo->SetTitle(“lego, topview” ) ; histo->DrawClone(“lego ,fb”) ;
canvas->cd(3) ; gPad->SetTheta( 30.) ; gPad->SetPhi( 30.) ; histo->SetTitle(“lego1, topview” ) ; histo->DrawClone(“lego1,fb”) ;
canvas->cd(5) ; gPad->SetTheta( 30.) ; gPad->SetPhi( 30.) ; histo->SetTitle(“lego2, topview” ) ; histo->DrawClone(“lego2,fb”) ;
canvas->cd(2) ; gPad->SetTheta(-30.) ; gPad->SetPhi(-30.) ; histo->SetTitle(“lego, bottomview” ) ; histo->DrawClone(“lego ,fb”) ;
canvas->cd(4) ; gPad->SetTheta(-30.) ; gPad->SetPhi(-30.) ; histo->SetTitle(“lego1, bottomview”) ; histo->DrawClone(“lego1,fb”) ;
canvas->cd(6) ; gPad->SetTheta(-30.) ; gPad->SetPhi(-30.) ; histo->SetTitle(“lego2, bottomview”) ; histo->DrawClone(“lego2,fb”) ;
}
[/code]
Cheers,
Z


I am a bit lost with your patch… it pretend to be only a change in the line attributes for stacks, and when I am looking at the “before” and “after” pictures you sent the line attributes are changed in both but the geometry of the plot is completely different … I am lost…

Ok, let me recap.
The goal of this patch is that line attributes (color, style, width) appear in lego mode.
The first patch proposed was only tested on TH2 without fb (see the very first pic above).
It appeared that it was not enough for TH2 with fb and for THStack.
The second patch fixes this.

This is demonstrated in the “before and after patch” pics attached above:

[code]

  • canvas_zero1_topview.*.png : differences = fb for each plot + thstack (last column)
  • canvas_zero0_topview.*.png : differences = fb for each plot + thstack (last column)
  • canvas_zero1_bottomview.*.png : differences = fb for each plot + thstack (last column)
  • canvas_zero0_bottomview.*.png : differences = fb for each plot + thstack (last column)[/code]
    Clearer?
    Cheers,
    Z

Yes clearer thanks… I compared the pictures more closely and see what you mean.

I have applied your patch.

I tried this macro:

   TH2D * histo = new TH2D ("histo","histo", 3,-3.,3., 3,-3.,3.) ; 
   histo->SetBinContent(2,2,1.) ;
   histo->SetFillColor(kRed) ; 
   histo->SetLineColor(kOrange) ; 
   histo->SetLineStyle(3) ; 
   histo->SetLineWidth(5) ; 
   histo->SetStats(kFALSE) ; 
   histo->Draw("lego1");

and I get the attached picture.
Line color is fine … but what about the other attributes ? On the pictures you sent me they are also changed.


[quote]Line color is fine … but what about the other attributes ? [/quote]As said in the very first post : “SetLineColor is taken into account for lego*, SetLineStyle & SetLineWidth for lego only” (you cannot play on linestyle and linewidth for TPad::PaintFillArea()).

[quote]On the pictures you sent me they are also changed. [/quote]That cannot be.

Reconsidering this, here’s a patch that does the job :smiley:

{ TH2D * histo = new TH2D ("histo","histo", 3,-3.,3., 3,-3.,3.) ; histo->SetBinContent(2,2,1.) ; histo->SetFillColor(kRed) ; histo->SetLineColor(kOrange) ; histo->SetLineStyle(3) ; histo->SetLineWidth(5) ; histo->SetStats(kFALSE) ; TCanvas * canvas = new TCanvas ("canvas") ; canvas->Divide(2,1) ; canvas->cd(1) ; histo->Draw("lego1"); canvas->cd(2) ; histo->Draw("lego2"); }
Thx for having insisted :wink:
Z
lego_attline_patch.gitdiff2.tgz (3.25 KB)


oups … sorry … I think you are right it does not make sense when you have hidden surface.

Sorry I am on several things at the same time and I missed your point about hidden surface …

Let me commit you previous change. They are ok.

Cheers,

Olivier

Ok, committed.
I am now looking at your other post about negative stacks… tricky …

[quote]oups … sorry … I think you are right it does not make sense when you have hidden surface.[/quote]Nope, it does! Don’t rely on the crap png file above. Run the example, it perfectly works.
The patch to be applied was lego_attline_patch.gitdiff2.tgz.
So now just apply that one
TPainter3dAlgorithms.cxx.2.diff (1.27 KB)and everything will be ok :smiley:
Thx,
Z

[quote]Don’t rely on the crap png file above[/quote]The output is exactly the same in gif (just as bad).
Here’s the corresponding “correct” pdf file (canvas->SaveAs(“canvas.pdf”)).canvas_pal53_contour99.pdf (20.3 KB)The transparency artefact decreases with the number of contours used. canvas_pal53_contour20.pdf (16.7 KB)Any ideas on how to avoid this? (I’ve tried several pdf readers and convert tools in vain).

Cheers,
Z

Now in the trunk.

How did you get this transparency ? you what it or it is something which showed up suddenly ?

The is a new parameter is SetPalette:

root.cern.ch/root/html534/TStyle … SetPalette

void SetPalette(Int_t ncolors = 0, Int_t* colors = 0, Float_t alpha = 1.)

The default value is 1. which means “opaque”. Unless you change this value to something smaller than 1.
I do not see how you could get the transparency.

Not to mix up everything, I propose we carry on this discussion in a new post.


Cheers,
Z

[quote]it does not make sense when you have hidden surface.[/quote]I now understand what you meant.
Here’s what’s displayed with the current patch :frowning:


canvas_s1w1_patch2.pdf (79.2 KB)
This is not acceptable.

Again I’ve been mislead by a too simple example (your c1.png above (no offense)) :angry:
[color=#FF0000]So here’s a new patch (hopefully the last one) fixing this[/color] (git diff against trunk rev 2fa236059378392c87f53e4821adb7593ad3955e).TPainter3dAlgorithms.cxx.3.diff (1.12 KB)
It keeps using TPad::PaintFillArea() not to be annoyed with the hidden surface algorithm
and superimposes a TPad::PaintPolyLine().
Of course if the line style is >1, the line width should be >1 for the style to be visible.


canvas_s2w2_patch3.pdf (96.3 KB)
This is the best we can do for now without deep changes I reckon.
Thx for commiting this change.

Cheers,
Z

PS: Further attachment (patch3.tgz): macro used + outputs for different (style,width) couples, before (patch2) and after (patch3) applying this last patch
patch3.tgz (1.35 MB)