Graph margin

Hi everybody,

I would like to know how to change the width of the margins for my TMultigraph.
This is how it looks now:


But I want it to look like this:


I thought I had to put this type of commands somewhere in my script, but they don’t work.

gStyle->SetPadRightMargin(0.05); gStyle->SetPadLeftMargin(0.12);

This is the script:

[code]#include “module.h”

brightness(string IN)
{
Double_t x[42];
Double_t y[42];
Double_t dy[42];

vector<string> input = split(IN,' ');

TCanvas *c = new TCanvas("trial", "Graph", 800, 500);
gStyle->SetOptFit(0);

TMultiGraph *multigraph = new TMultiGraph;
TFile *file1 = new TFile(input[0].c_str());
TGraphErrors *graph1 = file1->Get("ge");

TGraphErrors *graph = new TGraphErrors();

if (input.size() == 2)
{
	TFile *file2 = new TFile(input[1].c_str());
	TGraphErrors *graph2 = file2->Get("ge");
}
else if (input.size() > 2)
{
	cout << "Wrong number of input files!" << endl;
	break;
}

for (int i = 0; i < 42; i++)
{
	x[i] = graph1->GetX()[i];
	if (input.size() == 2)
	{
		y[i] = graph1->GetY()[i] / graph2->GetY()[i];
		dy[i] = y[i] * (pow(graph1->GetEY()[i] / graph1->GetY()[i], 2) + pow(graph2->GetEY()[i] / graph2->GetY()[i], 2));
	}
	else
	{
		y[i] = graph1->GetY()[i];
		dy[i] = graph1->GetEY()[i];
	}
	graph->SetPoint(i, x[i], y[i]);
	graph->SetPointError(i, 0, dy[i]);
}

graph->SetTitle(title.c_str());
graph->SetLineColor(1);
graph->SetLineWidth(1);
graph->SetMarkerStyle(8);
graph->SetMarkerColor(1);
graph->SetFillColor(0);
multigraph->Add(graph);


if (input.size() == 2)
{
	multigraph->SetTitle("Brightness ratio;Beam port angle,	S1 ... E1, N1 ... W1 [deg];ratio");
}
else
{
	multigraph->SetTitle(";Beam port angle,	S1 ... E1, N1 ... W1 [deg];Integrated brightness [n/cm^{2}/sec/sr/MW]");
}
multigraph->Add(graph);

multigraph->Draw("ap");
gPad->SetGrid();

string img_output = file_name + ".png";
c->Print(img_output.c_str(), "png");

}[/code]

Thanks. :slight_smile:

This works for me:

{
   TCanvas *c = new TCanvas();
   c->DrawFrame(-10,-10,10,10);
   c->SetLeftMargin(0.032);

   // Define a TMultigraph and draw it
   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("*");
}

This works for me too. Thank you. :slight_smile: