{ "cells": [ { "cell_type": "markdown", "id": "1797e14d", "metadata": {}, "source": [ "# gr019_scatter2d\n", "\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:38 PM." ] }, { "cell_type": "code", "execution_count": 1, "id": "8e751e08", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:38:09.349622Z", "iopub.status.busy": "2026-05-19T20:38:09.349497Z", "iopub.status.idle": "2026-05-19T20:38:09.702386Z", "shell.execute_reply": "2026-05-19T20:38:09.701706Z" } }, "outputs": [], "source": [ "auto canvas = new TCanvas(\"canvas\",\"canvas\");\n", "canvas->SetRightMargin(0.14);\n", "gStyle->SetPalette(kBird, 0, 0.6); // define a transparent palette\n", "\n", "const int n = 50;\n", "double x1[n];\n", "double y1[n];\n", "double z1[n];\n", "double c1[n];\n", "double s1[n];\n", "double x2[n];\n", "double y2[n];\n", "double z2[n];\n", "double c2[n];\n", "double s2[n];" ] }, { "cell_type": "markdown", "id": "3408ca18", "metadata": {}, "source": [ "Define four random data set" ] }, { "cell_type": "code", "execution_count": 2, "id": "e485ff6d", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:38:09.704682Z", "iopub.status.busy": "2026-05-19T20:38:09.704545Z", "iopub.status.idle": "2026-05-19T20:38:09.912828Z", "shell.execute_reply": "2026-05-19T20:38:09.912300Z" } }, "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:17:39: error: reference to 'y1' is ambiguous\n", "auto scatter1 = new TScatter2D(n, x1, y1, z1, 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", " z1[i] = 10*r->Rndm(i);\n", " c1[i] = 10000*r->Rndm(i);\n", " s1[i] = 10000*r->Rndm(i);\n", " x2[i] = 100*r->Rndm(i);\n", " y2[i] = 200*r->Rndm(i);\n", " z2[i] = 10*r->Rndm(i);\n", " c2[i] = 5000*r->Rndm(i);\n", " s2[i] = 100*r->Rndm(i);\n", "}\n", "c1[0] = 1;\n", "\n", "auto scatter1 = new TScatter2D(n, x1, y1, z1, c1, s1);\n", "scatter1->SetTitle(\"Scatter plot title;X title;Y title;Z title;C title\");\n", "scatter1->SetMarkerStyle(20);\n", "\n", "auto scatter2 = new TScatter2D(n, x2, y2, z2, c2, s2);\n", "scatter2->SetMarkerStyle(21);\n", "\n", "canvas->SetLogx();\n", "scatter1->Draw(\"logc\");\n", "scatter2->Draw(\"SAME\");" ] }, { "cell_type": "markdown", "id": "ec292dd4", "metadata": {}, "source": [ "Draw all canvases " ] }, { "cell_type": "code", "execution_count": 3, "id": "b79c8ca6", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:38:09.914744Z", "iopub.status.busy": "2026-05-19T20:38:09.914621Z", "iopub.status.idle": "2026-05-19T20:38:10.148396Z", "shell.execute_reply": "2026-05-19T20:38:10.147927Z" } }, "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 }