TPolyLine3D with log scale

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

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");
}

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:


Thanks a lot for both of your solutions! These workarounds are very straightforward.

Cheers,
Falk

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?

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.

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.

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.

Done, thanks for pointing this.

Thanks. I put it in .

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