Problem with SAME option TGraph

Hi guys,

I have a problem with the SAME option of TGraph. I wrote:
"TCanvas *c1 = new TCanvas(“c1”, “c1”,10,31,717,526);
c1->Range(40.85,-0.286,59.75,2.574);
c1->SetFillColor(0);
c1->SetBorderMode(0);
c1->SetBorderSize(2);
c1->SetFrameBorderMode(0);
c1->SetFrameBorderMode(0);

g->SetTitle(“Uncoated Silica”);
g->GetXaxis()->SetTitle(“Wavelength (nm)”);
g->GetYaxis()->SetTitle(“%”);

g->SetMarkerColor(kBlack);
g->SetMarkerStyle(31);
g->SetMarkerSize(0.2);
g->Draw(“AP”);

g1->SetMarkerColor(kMagenta +4);
g1->SetMarkerStyle(31);
g1->SetMarkerSize(0.2);
g1->Draw(“same”);"

but only the second graph is plotted. Any idea? Note that the two graphs have different ranges on the Y axis.


Please read tips for efficient and successful posting and posting code

ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided


TMultiGraph

Also, note that the option “SAME” does not exist for TGraph.

@couet Actually, only the "M" option does not exist ("S", "A", and "E" are there).
I’ve seen many times that people use "SAME" where it does not belong (not just for graphs, but for other “primitives”, too). Maybe adding a “protection” in all Draw methods would be a good idea so that this particular string is quietly “forgotten” (when not needed).

It is already the case:

I mean, not only for graphs but for all other “primitives”, too.

TGraph is the most obvious because it is as the “same level” as histograms.
I am not sure we want that test for TText TBox TLine etc …

Well, that’s what I mean by “other primitives” (texts, legends, graphics primitives, and so on). I saw quite a few examples of this “misbehavior”.

I also know that some people (mis)use "SAME " such as it is available everywhere. It is only available for histograms and documented only there. Do you we really want to also document the options which are NOT available ? Do we want to slow down the very basic graphics primitives with an extra test on an option they do not have ? We do that test for graphs because it takes longer to draw anyway and the error was super frequent (and, as I said, histograms and graphs are the same kind of very high level graphics objects).

So, maybe another idea … if some “primitive” is sensitive to any of “S”, “A”, “M”, or “E”, then it should be protected against “SAME”.

Makes more sense…

I just had a quick look and to not saw any obvious candidates except, maybe, TGaxis.

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