ROOT Version: 6.10
Platform: Ubuntu
Compiler: Not Provided
Hi,
I’m trying to get two TGraphErrors drawn in the same canvas, but my second TGraphErrors is not being drawn correctly. It has no markers (even though I specified them) and is just a straight line. Making the changes manually to the second graph in the TBrowser also does not work. This is all in C++11. The code I’m using is below. I have no idea why this is not working, I feel like I’m missing something very straight forward…
Current behaviour:
Expected behaviour,
gr1 with square markers of size 1.0 with no line
gr2 with circle markers of size 1.0 with no line
#include "TROOT.h"
#include "TFile.h"
#include "TTree.h"
#include "TCanvas.h"
#include "TBrowser.h"
#include "TGraphErrors.h"
#include <string>
int main() {
string outputRootFileName = "location_to_root_file.root";
TFile *rootFile = new TFile(outputRootFileName.c_str(), "recreate");
TCanvas *canv = new TCanvas("canvtest", "canvtest", 800, 600);
vector <double> x = {0,1,2,3,4,5,6,7,8,9};
vector <double> y = {0,1,2,3,4,5,6,7,8,9};
vector <double> x1 = {1,2,3,4,5,6,7,8,9,10};
vector <double> y1 = {1,1,1,1,1,1,1,1,1,1};
vector <double> zeros(10,0);
TGraphErrors *gr1 = new TGraphErrors(10, &x[0], &y[0], &zeros[0], &zeros[0]);
TGraphErrors *gr2 = new TGraphErrors(10, &x1[0], &y1[0], &zeros[0], &zeros[0]);
gr1 -> SetMarkerStyle(21);
gr1 -> SetMarkerSize(1.0);
gr2 -> SetMarkerStyle(20);
gr2 -> SetMarkerSize(1.0);
gr1 -> Draw("AP");
gr2 -> Draw("SAME");
canv -> Update();
canv -> Write();
rootFile -> Close();
return 0;
}