TMultiGraph->SetLineStyle() Problem

I can’t seem to plot any other line style others than solid and dashed, both using TMultigraph and TGraph.

I’ve set gROOT->SetStyle=“none” to remove the annoying canvas defaults, but thats isn’t the source of the problem.

Any ideas? Its clearly something simple…

Thanks,

Tim

{
   TGraph *g[3];
   Double_t x[10] = {0,1,2,3,4,5,6,7,8,9};
   Double_t y[10] = {1,2,3,4,5,5,4,3,2,1};
   TMultiGraph *mg = new TMultiGraph();
   for (int i=0; i<3; i++) {
      g[i] = new TGraph(10, x, y);
      g[i]->SetLineStyle(i);   
      g[i]->SetLineColor(i+2);  
      for (int j=0; j<10; j++) y[j] = y[j]-1;
      mg->Add(g[i]);
   }
   mg->Draw("AL");
}

Thanks, used your exact script but I get three lines, 2 of which are solid, 1 dashed.

Increasing i to 10, just gives 2 solid and 8 dashed.

The available line styles are listed here:
root.cern.ch/root/html/TAttLine.html#L3

Yes I know…I only seem to be able to get two!

In the macro I sent you do:

  g[i]->SetLineStyle(i+2);    

and you will see 3 of them.

Sorry my last post was unclear:

I’m getting 3 lines, 3 diff colours, all of which are dashed, i.e. same style.

With:

{ TGraph *g[3]; Double_t x[10] = {0,1,2,3,4,5,6,7,8,9}; Double_t y[10] = {1,2,3,4,5,5,4,3,2,1}; TMultiGraph *mg = new TMultiGraph(); for (int i=0; i<3; i++) { g[i] = new TGraph(10, x, y); g[i]->SetLineStyle(i+2); g[i]->SetLineColor(i+2); for (int j=0; j<10; j++) y[j] = y[j]-1; mg->Add(g[i]); } mg->Draw("AL"); }
I get the attached picture (3 different dashes) … which ROOT version are you using ? on which platform ?


root 5.22/00 on Scientific Linux

Ok, I produced this output with the latest root version on SLC also.

Problem solved…

Writing the canvas as a .ps, all the different styles are apparent, but NOT when saved as either .png or .gif, or when viewed through Exceed (all line styles revert to solid or dashed).

Thanks for your help, I don’t know how to remedy the problem in Exceed or or the dodgy formats, but atleast I can get a decent output now.

Use a more recent root version. we are now at 5.27 …