TMultiGraph not showing one plot

Hello, I tried to search before I posted my question but unsuccessfully, so here it goes:

I have following (in short):

TCanvas * c = new TCanvas();
c->SetLogy();

int n;
double t[];
double tg1[], tg2[], tg3[];

TGraph * _tg1 = new Tgraph (n, t, tg1);
TGraph * _tg2 = new Tgraph (n, t, tg2);
TGraph * _tg3 = new Tgraph (n, t, tg3);

TMultiGraph * mg = TMultiGraph();

mg->Add(_tg1, "p");
mg->Add(_tg2, "p");
mg->Add(_tg3, "p");

mg->Draw("A");

tg1 - is in the range [10, 20]
tg2 - is equal to 0.0015
tg3 - is in the range [1, 5]

As a result I do not see tg2 drawn on the final plot. If I draw only tg2 witg mg it draws it fine, as soon as I add any of other two or both tg2 disappears. So far I’ve been using TMultiGraph successfully, please help me with problem.

Thanks,
Irakli

{
   TCanvas * c = new TCanvas();
   c->SetLogy();

   int n = 3;
   double t[] = {1,2,3};
   double tg1[] = {1,2,3}, tg2[] = {4,5,6}, tg3[] = {7,8,9};

   TGraph *g1 = new TGraph (n, t, tg1);
   TGraph *g2 = new TGraph (n, t, tg2);
   TGraph *g3 = new TGraph (n, t, tg3);

   TMultiGraph *mg = new TMultiGraph();

   g1->SetMarkerStyle(20);
   g2->SetMarkerStyle(21);
   g3->SetMarkerStyle(22);
   mg->Add(g1, "p");
   mg->Add(g2, "p");
   mg->Add(g3, "p");

   mg->Draw("A");
}

Hello, I think what you are trying to say is that, the code will actually work, right? I know that I have used TMultiGraph many times and it works. But It doesn’t in this particular case…

I gave the ranges for each TGraph-s because I thing may be TMultiGraph cannot hande scales very well when the difference is so pronounced.

If I give mg->SetMinimum(0.000001) then I see all 3 plots.

So the question is: is it a problem with TMultiGraph or is it something else?

Can you modify the macro I sent you in a way it reproduces the problem you are facing ?
Thanks.

Hello,

I tried to investigate it a little and figured out that if there is 0 in tg3 then it sets the scale around 10^(-2) so it won’t show anything below, is this an expected behavior? Please see to code below:

        {
        TCanvas * c = new TCanvas();
        c->SetLogy();

        int n = 3;
        double t[] = {1,2,3};
        double tg1[] = {1,2,3}, tg2[] = {0.00015,0.00015,0.00015}, tg3[] = {17,0,19}; // <- this doesn't show tg2
//      double tg1[] = {1,2,3}, tg2[] = {15,15,15}, tg3[] = {17,0,19}; // <- this would show tg2

        TGraph *g1 = new TGraph (n, t, tg1);
        TGraph *g2 = new TGraph (n, t, tg2);
        TGraph *g3 = new TGraph (n, t, tg3);

        TMultiGraph *mg = new TMultiGraph();

        g1->SetMarkerStyle(20);
        g2->SetMarkerStyle(21);
        g3->SetMarkerStyle(22);
        mg->Add(g1, "p");
        mg->Add(g2, "p");
        mg->Add(g3, "p");

        mg->Draw("A");
        }

Yes it is … you asked for log scale along the Y axis … and log(0) is not defined …

absolutely, I andurstand it. But it does plot the TGraph which has 0 in it, and it shows all the plots that are ebove 10^-2, what is so special about 10^-2? Why not make sure all the plots get plotted?

If the graph has a 0 but the graph maximum is positive, then the system tries to show something by setting the graph minimum to 3 decades below the maximum. That’s what you see.

I understand that. I don’t want to be annoying, but why is it not possible for TMultiGraph to scale the axis acoording to lowest point that is not 0 and then it would work for the cases when there is 0 in one of the plosts?

thanks
Irakli

Finding the positive minimum will not fly because, as it is not stored, it will mean recomputing it each time the graph is repaint. As TGraph is a very basic class on which relies many others, it will kill the performances. That’s why a computation based on the stored maximum and minimum is done (if the minimum is <=0 and the maximum >0 the minimum is set to 0,001*maximum in case of log scale along the Y axis).

thanks a lot for your answers.