Hi guys,
I want to use a TPolyLine3D to draw on top of a TF2. Unfortunately, TPolyLine3D seems to ignore the SetLogz() flag of the canvas to draw in.
void testTPolyLine3D(){
TCanvas* canvas = new TCanvas("canvas");
// canvas->SetLogz();
TF2 *f2 = new TF2("myfunc","pow(10, x)",0,5,0,5);
f2->SetMinimum(1E0);
f2->SetMaximum(1E3);
f2->Draw("surf");
TPolyLine3D *l = new TPolyLine3D(2);
l->SetLineWidth(5);
l->SetPoint(0,0,0,1E0);
l->SetPoint(1,1,0,1E1);
l->SetPoint(2,2,0,1E2);
l->SetPoint(3,3,0,1E3);
l->Draw("same");
}
In linear scale, the TPolyLine3D is on top of the TF2:
In log scale it isn’t:
Does anybody know a fix for this?
Cheers,
Falk
couet
September 5, 2017, 3:07pm
2
void testTPolyLine3D(){
TCanvas* canvas = new TCanvas("canvas");
canvas->SetLogz();
TF2 *f2 = new TF2("myfunc","pow(10, x)",0,5,0,5);
f2->SetMinimum(1E0);
f2->SetMaximum(1E3);
f2->Draw("surf");
TGraph2D *g = new TGraph2D();
g->SetLineWidth(5);
g->SetPoint(0,0,0,1E0);
g->SetPoint(1,1,0,1E1);
g->SetPoint(2,2,0,1E2);
g->SetPoint(3,3,0,1E3);
g->Draw("SAME P0 LINE");
}
ksmith
September 5, 2017, 3:39pm
3
Just another issue with visualization in ROOT in log space. Here is an alternate solution:
void testTPolyLine3D(){
TCanvas* canvas = new TCanvas("canvas");
canvas->SetLogz();
TF2 *f2 = new TF2("myfunc","pow(10, x)",0,5,0,5);
f2->SetMinimum(1E0);
f2->SetMaximum(1E3);
f2->Draw("surf");
TPolyLine3D *l = new TPolyLine3D(2);
l->SetLineWidth(5);
l->SetPoint(0,0,0,log10(1E0));
l->SetPoint(1,1,0,log10(1E1));
l->SetPoint(2,2,0,log10(1E2));
l->SetPoint(3,3,0,log10(1E3));
l->Draw("same");
}
Other issues with log space include:
I recently discovered that TCutG objects are always plotted as straight lines connecting points even if on a log axis. This can lead to misleading cuts. Say I draw a nice and square box around my data that happens to be exponential and plotted on a log plot and then use that cut to only look at that data. The result is not what one would expect as the cut needs to be evaluated against the data in linear space due to the plotting.
Below is an example where I created a cut around the data in the …
Dear ROOTers,
I have this annoying problem with the Pad axis limits command, GetUymax(). When I want to plot a vertical line on a plot, I normally do like this:
histo->Draw();
c1->Update();
TLine *l = new TLine(0.5,c1->GetUymin(),0.5,c1->GetUymax());
l->Draw();
This works very well for plots with a linear y scale. However, when I want to use a log scale, I observed the following:
If I add the following line before the code above, I get a tiny line, for which Uymax is too small (Uymin looks o…
Thanks a lot for both of your solutions! These workarounds are very straightforward.
Cheers,
Falk
pamputt
September 6, 2017, 9:29am
5
I did not understand if this is a bug in ROOT or if TPolyLine3D was misused. If it is a bug, then a JIRA report should be opened to track it, isn’t it?
Seems like a bug to me. Would it be my responsibility to send a report?
couet
September 6, 2017, 10:42am
7
TPolyLine3D is a basic graphics primitive for which the log scales have not been implemented. I would call it a missing feature rather than a bug. Now the question is: do we want to keep such primitive very simple and working in the current world coordinate, in that case we leave it as it is and the two solutions provided before should be used. Or do we want to promote it to an higher level and let it look at the log flag.
pamputt
September 7, 2017, 7:43am
8
I understand the point; it makes sense. So if you decide to keep TPolyLine3D as a basic graphics primitive, you should at least add some warning in the documentation in order to alert that it is not displayed correctly in log scale.
ksmith
September 7, 2017, 1:49pm
9
In addition, some of the other log issues could be documented better such as TPad::GetUxmax
.
EDIT: I’ve submitted a pull request to improve the TPad::GetUxmax
documentation as this come up frequently.
couet
September 8, 2017, 7:01am
10
Done, thanks for pointing this.
system
Closed
September 22, 2017, 7:05am
12
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.