{ "cells": [ { "cell_type": "markdown", "id": "6eaa6b40", "metadata": {}, "source": [ "# gr006_scatter\n", "\n", "TScatter is available since ROOT v.6.30. See the [TScatter documentation](https://root.cern/doc/master/classTScatter.html)\n", "\n", "\n", "\n", "**Author:** Olivier Couet \n", "This notebook tutorial was automatically generated with ROOTBOOK-izer from the macro found in the ROOT repository on Tuesday, May 19, 2026 at 08:37 PM." ] }, { "cell_type": "code", "execution_count": 1, "id": "f4531697", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:37:49.762138Z", "iopub.status.busy": "2026-05-19T20:37:49.762025Z", "iopub.status.idle": "2026-05-19T20:37:50.139054Z", "shell.execute_reply": "2026-05-19T20:37:50.124681Z" } }, "outputs": [], "source": [ "auto canvas = new TCanvas();\n", "canvas->SetRightMargin(0.14);\n", "gStyle->SetPalette(kBird, 0, 0.6); // define a transparent palette\n", "\n", "const int n = 175;\n", "double x1[n];\n", "double y1[n];\n", "double c1[n];\n", "double s1[n];\n", "double x2[n];\n", "double y2[n];\n", "double c2[n];\n", "double s2[n];" ] }, { "cell_type": "markdown", "id": "30f1c3f5", "metadata": {}, "source": [ "Define four random data sets" ] }, { "cell_type": "code", "execution_count": 2, "id": "78f0b1b1", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:37:50.159214Z", "iopub.status.busy": "2026-05-19T20:37:50.159026Z", "iopub.status.idle": "2026-05-19T20:37:50.409819Z", "shell.execute_reply": "2026-05-19T20:37:50.391439Z" } }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "input_line_55:5:4: error: reference to 'y1' is ambiguous\n", " y1[i] = 200*r->Rndm(i);\n", " ^\n", "input_line_44:8:8: note: candidate found by name lookup is '__cling_N518::y1'\n", "double y1[n];\n", " ^\n", "/usr/include/bits/mathcalls.h:224:13: note: candidate found by name lookup is 'y1'\n", "__MATHCALL (y1,, (_Mdouble_));\n", " ^\n", "input_line_55:14:37: error: reference to 'y1' is ambiguous\n", "auto scatter1 = new TScatter(n, x1, y1, c1, s1);\n", " ^\n", "input_line_44:8:8: note: candidate found by name lookup is '__cling_N518::y1'\n", "double y1[n];\n", " ^\n", "/usr/include/bits/mathcalls.h:224:13: note: candidate found by name lookup is 'y1'\n", "__MATHCALL (y1,, (_Mdouble_));\n", " ^\n" ] } ], "source": [ "auto r = new TRandom();\n", "for (int i=0; iRndm(i);\n", " y1[i] = 200*r->Rndm(i);\n", " c1[i] = 300*r->Rndm(i);\n", " s1[i] = 400*r->Rndm(i);\n", " x2[i] = 100*r->Rndm(i);\n", " y2[i] = 200*r->Rndm(i);\n", " c2[i] = 100*r->Rndm(i);\n", " s2[i] = 200*r->Rndm(i);\n", "}\n", "\n", "auto scatter1 = new TScatter(n, x1, y1, c1, s1);\n", "scatter1->SetMarkerStyle(20);\n", "scatter1->SetTitle(\"Scatter plot title;X title;Y title;Z title\");\n", "scatter1->GetXaxis()->SetRangeUser(20.,90.);\n", "scatter1->GetYaxis()->SetRangeUser(55.,90.);\n", "scatter1->GetZaxis()->SetRangeUser(10.,200.);" ] }, { "cell_type": "markdown", "id": "71432b14", "metadata": {}, "source": [ "an alternative way to zoom the Z-axis:\n", "scatter->GetHistogram()->SetMinimum(10);\n", "scatter->GetHistogram()->SetMaximum(200);" ] }, { "cell_type": "code", "execution_count": 3, "id": "d6f3a539", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:37:50.417887Z", "iopub.status.busy": "2026-05-19T20:37:50.417721Z", "iopub.status.idle": "2026-05-19T20:37:50.649862Z", "shell.execute_reply": "2026-05-19T20:37:50.640378Z" } }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "input_line_57:2:3: error: use of undeclared identifier 'scatter1'\n", " (scatter1->Draw(\"A\"))\n", " ^\n", "Error in : Error evaluating expression (scatter1->Draw(\"A\"))\n", "Execution of your code was aborted.\n" ] } ], "source": [ "scatter1->Draw(\"A\");\n", "\n", "auto scatter2 = new TScatter(n, x2, y2, c2, s2);\n", "scatter2->SetMarkerStyle(21);\n", "scatter2->Draw();" ] }, { "cell_type": "markdown", "id": "bee7adbb", "metadata": {}, "source": [ "Draw all canvases " ] }, { "cell_type": "code", "execution_count": 4, "id": "b6e5441d", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:37:50.653776Z", "iopub.status.busy": "2026-05-19T20:37:50.653627Z", "iopub.status.idle": "2026-05-19T20:37:50.872287Z", "shell.execute_reply": "2026-05-19T20:37:50.871677Z" } }, "outputs": [ { "data": { "text/html": [ "\n", "\n", "
\n", "
\n", "\n", "\n", "\n" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "gROOT->GetListOfCanvases()->Draw()" ] } ], "metadata": { "kernelspec": { "display_name": "ROOT C++", "language": "c++", "name": "root" }, "language_info": { "codemirror_mode": "text/x-c++src", "file_extension": ".C", "mimetype": " text/x-c++src", "name": "c++" } }, "nbformat": 4, "nbformat_minor": 5 }