How to Make Scatter Plot with Log Axis on Y-Axis

I couldn’t quite find out how to do this by searching on Google. I am trying to make a scatter plot with some data and put the y-axis on a logarithmic scale (base 10).

I have two arrays, x and y, of type Double_t. Then I have tried the following lines:

Int_t n = 11000; //The length of my arrays.
TGraph *g = new Tgraph(n,x,y);
TCanvas *c1 = new TCanvas(“My plot”,“Tree Canvas”)
//TCanvas takes two other numerical arguments, w and h. I can set these later.

Something is clearly wrong. I’d appreciate any correction.


there are some typos in the code such as missing “;” and usage of . instead of ->.
In any case the point here is that you need to draw the graph and not the canvas and then change to log scale.
Here you see the working exmple

Int_t n = 11000; //The length of my arrays.
TGraph *g = new TGraph(n);
TCanvas *c1 = new TCanvas("My plot","Tree Canvas");


The problems remaining are that this does not produce a scatter plot, and the line


produces an error (“Unkown binary” is displayed repeatedly).

Also, ROOT is not accepting

Int_t n = 11000;
Double_t x[n];

The declaration of n (first line) is okay, but it says I cannot declare a Double_t when n is of a variable type. So I have to go Double_t = x[11000]; Could this be causing problems?

const Int_t n = 11000;
// …


I don’t think so. This is a feature of C(++). The compiler must have a constant size for that kind of array.

As for the “uknown binary”: this is odd. This seems to suggest a bauggy installation. How did you build ROOT?