Scatter Plot with Colorbar


I was trying to draw a scatter plot (2D Graph) with a color bar (the z-axis) with the draw option g_temp->Draw("x:y:z","colz"); following the earlier post
However, it says “too many arguments” to the “Draw” function as in below:

/Scatter.C:13:24: error: too many arguments to function call, expected at most single argument 'option',
      have 2 arguments
  ~~~~~~~~~~~~         ^~~~~~
/usr/local/etc/../include/TGraph2D.h:95:4: note: 'Draw' declared here
   virtual void          Draw(Option_t *option="P0");

Only the "colz" working fine, but I want a scatter plot instead.

I have attached the example macro and a data file. Could kindly guide me what option should I give?
data.txt (63.5 KB)
Scatter.C (353 Bytes)

ROOT Version: 6.16/00
Platform: linuxx8664gcc
Compiler: g++ 7.5.0

That’s for drawing trees or ntuples, not for graphs (or TGraph2D in your case). Anyway, I don’t think TGraph2D is appropriate for what you want; just use a TH2 (e.g. TH2D) and draw it with “colz”

If you use a newer ROOT version, you can use New class TScatter - ROOT

1 Like

Thanks a lot, @dastudillo and @ferhue .
It seemed easier with the TScatter class. However, in another machine with root 6.24/08 I tried. It doesn’t have the class. Could you tell me from which version the TScatter class is available?

6.30 at least is needed

Okay, I see. Thanks a lot, @ferhue . Let me try to install it and try.

If you are going to install a newer version, get the latest (currently 6.32), unlesss you have a very specific reason to avoid it,

1 Like

Okay, I will do that @dastudillo .

I just needed a clarification and an advice.

If I install two ROOT – 1. with snap and 2. by building from source; will they create a conflict anyhow? For other ROOT-dependent packages (e.g. Delphes) which root they will consider?

And how do you think is the best way to install ROOT – in a specified installation directory or in the /usr/local.

Thanks a lot.

Maybe a developer can give better advice, but I’d say it’s ok as long as you keep the installs in different folders; remember that before using any ROOT you have to source the file /path/to/that/root/bin/ (for bash shells), so that will define which ROOT is used at any time.

I confirm what @dastudillo said. I have several ROOT versions installed on my machine, and I can easily switch between each of them using

I think it is better to download the binary release, rather than building from source.

Download different versions, and unzip them under /opt/root632 and /opt/root630 to easily switch between them. And uninstall the snap version (in my opinion).