{ "cells": [ { "cell_type": "markdown", "id": "b5f55e05", "metadata": {}, "source": [ "# tree142_parallelcoordtrans\n", "Use of transparency with ||-Coord.\n", "\n", "It displays the same data set twice. The first time without transparency and\n", "the second time with transparency. On the second plot, several clusters\n", "appear.\n", "\n", "### Images without and with transparency\n", "\n", "\n", "### Transparency works in PDF files\n", "\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:19 PM." ] }, { "cell_type": "code", "execution_count": 1, "id": "f900765a", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:19:24.601951Z", "iopub.status.busy": "2026-05-19T20:19:24.601840Z", "iopub.status.idle": "2026-05-19T20:19:24.611192Z", "shell.execute_reply": "2026-05-19T20:19:24.610755Z" } }, "outputs": [], "source": [ "%%cpp -d\n", "#include \"TFile.h\"\n", "#include \"TCanvas.h\"\n", "#include \"TStyle.h\"\n", "#include \"TRandom.h\"\n", "#include \"TNtuple.h\"\n", "#include \"TParallelCoord.h\"\n", "#include \"TParallelCoordVar.h\"\n", "#include \"TParallelCoordRange.h\"\n", "\n", "Double_t r1, r2, r3, r4, r5, r6, r7, r8, r9;\n", "Double_t dr = 3.5;\n", "TRandom *r;" ] }, { "cell_type": "markdown", "id": "745a8cce", "metadata": {}, "source": [ " Definition of a helper function: " ] }, { "cell_type": "code", "execution_count": 2, "id": "3dfd3d3a", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:19:24.612658Z", "iopub.status.busy": "2026-05-19T20:19:24.612524Z", "iopub.status.idle": "2026-05-19T20:19:24.615939Z", "shell.execute_reply": "2026-05-19T20:19:24.615534Z" } }, "outputs": [], "source": [ "%%cpp -d\n", "void generate_random(Int_t i)\n", "{\n", " r->Rannor(r1, r4);\n", " r->Rannor(r7, r9);\n", " r2 = (2 * dr * r->Rndm(i)) - dr;\n", " r3 = (2 * dr * r->Rndm(i)) - dr;\n", " r5 = (2 * dr * r->Rndm(i)) - dr;\n", " r6 = (2 * dr * r->Rndm(i)) - dr;\n", " r8 = (2 * dr * r->Rndm(i)) - dr;\n", "}" ] }, { "cell_type": "code", "execution_count": 3, "id": "118263ce", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:19:24.617033Z", "iopub.status.busy": "2026-05-19T20:19:24.616923Z", "iopub.status.idle": "2026-05-19T20:19:24.966813Z", "shell.execute_reply": "2026-05-19T20:19:24.966277Z" } }, "outputs": [], "source": [ "Double_t x, y, z, u, v, w, a, b, c;\n", "Double_t s1x, s1y, s1z;\n", "Double_t s2x, s2y, s2z;\n", "Double_t s3x, s3y, s3z;\n", "r = new TRandom();\n", "\n", "auto c1 = new TCanvas(\"c1\", \"c1\", 0, 0, 900, 1000);\n", "c1->Divide(1, 2);\n", "\n", "auto nt = new TNtuple(\"nt\", \"Demo ntuple\", \"x:y:z:u:v:w:a:b:c\");\n", "\n", "int n=0;\n", "for (Int_t i = 0; i < 1500; i++) {\n", " r->Sphere(s1x, s1y, s1z, 0.1);\n", " r->Sphere(s2x, s2y, s2z, 0.2);\n", " r->Sphere(s3x, s3y, s3z, 0.05);\n", "\n", " generate_random(i);\n", " nt->Fill(r1, r2, r3, r4, r5, r6, r7, r8, r9);\n", " n++;\n", "\n", " generate_random(i);\n", " nt->Fill(s1x, s1y, s1z, s2x, s2y, s2z, r7, r8, r9);\n", " n++;\n", "\n", " generate_random(i);\n", " nt->Fill(r1, r2, r3, r4, r5, r6, r7, s3y, r9);\n", " n++;\n", "\n", " generate_random(i);\n", " nt->Fill(s2x - 1, s2y - 1, s2z, s1x + .5, s1y + .5, s1z + .5, r7, r8, r9);\n", " n++;\n", "\n", " generate_random(i);\n", " nt->Fill(r1, r2, r3, r4, r5, r6, r7, r8, r9);\n", " n++;\n", "\n", " generate_random(i);\n", " nt->Fill(s1x + 1, s1y + 1, s1z + 1, s3x - 2, s3y - 2, s3z - 2, r7, r8, r9);\n", " n++;\n", "\n", " generate_random(i);\n", " nt->Fill(r1, r2, r3, r4, r5, r6, s3x, r8, s3z );\n", " n++;\n", "}\n", "\n", "TParallelCoordVar *pcv;\n", "\n", "c1->cd(1);" ] }, { "cell_type": "markdown", "id": "cf9c4f77", "metadata": {}, "source": [ "||-Coord plot without transparency" ] }, { "cell_type": "code", "execution_count": 4, "id": "92a93483", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:19:24.968544Z", "iopub.status.busy": "2026-05-19T20:19:24.968426Z", "iopub.status.idle": "2026-05-19T20:19:25.173768Z", "shell.execute_reply": "2026-05-19T20:19:25.173213Z" } }, "outputs": [], "source": [ "nt->Draw(\"x:y:z:u:v:w:a:b:c\", \"\", \"para\");\n", "TParallelCoord* para1 = (TParallelCoord*)gPad->GetListOfPrimitives()->FindObject(\"ParaCoord\");\n", "para1->SetLineColor(25);\n", "pcv = (TParallelCoordVar*)para1->GetVarList()->FindObject(\"x\");\n", "pcv->SetHistogramHeight(0.);\n", "pcv = (TParallelCoordVar*)para1->GetVarList()->FindObject(\"y\");\n", "pcv->SetHistogramHeight(0.);\n", "pcv = (TParallelCoordVar*)para1->GetVarList()->FindObject(\"z\");\n", "pcv->SetHistogramHeight(0.);\n", "pcv = (TParallelCoordVar*)para1->GetVarList()->FindObject(\"a\");\n", "pcv->SetHistogramHeight(0.);\n", "pcv = (TParallelCoordVar*)para1->GetVarList()->FindObject(\"b\");\n", "pcv->SetHistogramHeight(0.);\n", "pcv = (TParallelCoordVar*)para1->GetVarList()->FindObject(\"c\");\n", "pcv->SetHistogramHeight(0.);\n", "pcv = (TParallelCoordVar*)para1->GetVarList()->FindObject(\"u\");\n", "pcv->SetHistogramHeight(0.);\n", "pcv = (TParallelCoordVar*)para1->GetVarList()->FindObject(\"v\");\n", "pcv->SetHistogramHeight(0.);\n", "pcv = (TParallelCoordVar*)para1->GetVarList()->FindObject(\"w\");\n", "pcv->SetHistogramHeight(0.);" ] }, { "cell_type": "markdown", "id": "c4755a41", "metadata": {}, "source": [ "||-Coord plot with transparency" ] }, { "cell_type": "code", "execution_count": 5, "id": "6b02b3ae", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:19:25.175423Z", "iopub.status.busy": "2026-05-19T20:19:25.175306Z", "iopub.status.idle": "2026-05-19T20:19:25.380343Z", "shell.execute_reply": "2026-05-19T20:19:25.379983Z" } }, "outputs": [], "source": [ "TColor *col26 = gROOT->GetColor(26);\n", "col26->SetAlpha(0.01);\n", "c1->cd(2);\n", "nt->Draw(\"x:y:z:u:v:w:a:b:c\", \"\", \"para\");\n", "TParallelCoord* para2 = (TParallelCoord*)gPad->GetListOfPrimitives()->FindObject(\"ParaCoord\");\n", "para2->SetLineColor(26);\n", "pcv = (TParallelCoordVar*)para2->GetVarList()->FindObject(\"x\");\n", "pcv->SetHistogramHeight(0.);\n", "pcv = (TParallelCoordVar*)para2->GetVarList()->FindObject(\"y\");\n", "pcv->SetHistogramHeight(0.);\n", "pcv = (TParallelCoordVar*)para2->GetVarList()->FindObject(\"z\");\n", "pcv->SetHistogramHeight(0.);\n", "pcv = (TParallelCoordVar*)para2->GetVarList()->FindObject(\"a\");\n", "pcv->SetHistogramHeight(0.);\n", "pcv = (TParallelCoordVar*)para2->GetVarList()->FindObject(\"b\");\n", "pcv->SetHistogramHeight(0.);\n", "pcv = (TParallelCoordVar*)para2->GetVarList()->FindObject(\"c\");\n", "pcv->SetHistogramHeight(0.);\n", "pcv = (TParallelCoordVar*)para2->GetVarList()->FindObject(\"u\");\n", "pcv->SetHistogramHeight(0.);\n", "pcv = (TParallelCoordVar*)para2->GetVarList()->FindObject(\"v\");\n", "pcv->SetHistogramHeight(0.);\n", "pcv = (TParallelCoordVar*)para2->GetVarList()->FindObject(\"w\");\n", "pcv->SetHistogramHeight(0.);" ] }, { "cell_type": "markdown", "id": "c60b8113", "metadata": {}, "source": [ "Produce transparent lines in interactive and batch mode" ] }, { "cell_type": "code", "execution_count": 6, "id": "90b58ea8", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:19:25.382117Z", "iopub.status.busy": "2026-05-19T20:19:25.382007Z", "iopub.status.idle": "2026-05-19T20:19:26.050836Z", "shell.execute_reply": "2026-05-19T20:19:26.050411Z" } }, "outputs": [ { "data": { "text/html": [ "\n", "\n", "
\n", "
\n", "\n", "\n", "\n" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stderr", "output_type": "stream", "text": [ "Info in : pdf file parallelcoordtrans.pdf has been created\n", "Info in : SVG file parallelcoordtrans.svg has been created\n" ] } ], "source": [ "c1->Print(\"parallelcoordtrans.pdf\");\n", "c1->Print(\"parallelcoordtrans.svg\");" ] }, { "cell_type": "markdown", "id": "5f0808a7", "metadata": {}, "source": [ "Produce transparent lines in batch mode only" ] }, { "cell_type": "code", "execution_count": 7, "id": "0c0c6e83", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:19:26.052041Z", "iopub.status.busy": "2026-05-19T20:19:26.051932Z", "iopub.status.idle": "2026-05-19T20:19:26.452060Z", "shell.execute_reply": "2026-05-19T20:19:26.451476Z" } }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "Info in : jpg file parallelcoordtrans.jpg has been created\n", "Info in : png file parallelcoordtrans.png has been created\n" ] } ], "source": [ "c1->Print(\"parallelcoordtrans.jpg\");\n", "c1->Print(\"parallelcoordtrans.png\");" ] }, { "cell_type": "markdown", "id": "121afadc", "metadata": {}, "source": [ "Draw all canvases " ] }, { "cell_type": "code", "execution_count": 8, "id": "ed29480f", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:19:26.453725Z", "iopub.status.busy": "2026-05-19T20:19:26.453578Z", "iopub.status.idle": "2026-05-19T20:19:26.658742Z", "shell.execute_reply": "2026-05-19T20:19:26.658126Z" } }, "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 }