{ "cells": [ { "cell_type": "markdown", "id": "5585f31b", "metadata": {}, "source": [ "# transparency\n", "\n", "It is done by specifying the alpha value of a given color.\n", "For instance\n", "\n", "```\n", " ellipse->SetFillColorAlpha(9, 0.571);\n", "```\n", "\n", "changes the ellipse fill color to the index 9 with an alpha value of 0.571.\n", "0. would be fully transparent (invisible) and 1. completely opaque (the default).\n", "\n", "The transparency is available on all platforms when the flag\n", "`OpenGL.CanvasPreferGL` is set to `1` in `$ROOTSYS/etc/system.rootrc`, or\n", "on Mac with the Cocoa backend. X11 does not support transparency. On the file\n", "output it is visible with PDF, PNG, Gif, JPEG, SVG, TeX ... but not PostScript.\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:37 PM." ] }, { "cell_type": "code", "execution_count": 1, "id": "6d4f2a21", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:37:35.798512Z", "iopub.status.busy": "2026-05-19T20:37:35.798389Z", "iopub.status.idle": "2026-05-19T20:37:36.148928Z", "shell.execute_reply": "2026-05-19T20:37:36.147791Z" } }, "outputs": [], "source": [ "auto c1 = new TCanvas(\"c1\", \"c1\", 224, 330, 700, 527);\n", "c1->Range(-0.125, -0.125, 1.125, 1.125);\n", "\n", "auto tex = new TLatex(0.06303724, 0.0194223, \"This text is opaque and this line is transparent\");\n", "tex->SetLineWidth(2);\n", "tex->Draw();\n", "\n", "auto arrow = new TArrow(0.5555158, 0.07171314, 0.8939828, 0.6195219, 0.05, \"|>\");\n", "arrow->SetLineWidth(4);\n", "arrow->SetAngle(30);\n", "arrow->Draw();" ] }, { "cell_type": "markdown", "id": "d5019e4f", "metadata": {}, "source": [ "Draw a transparent graph." ] }, { "cell_type": "code", "execution_count": 2, "id": "7b36afd8", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:37:36.150625Z", "iopub.status.busy": "2026-05-19T20:37:36.150485Z", "iopub.status.idle": "2026-05-19T20:37:36.357711Z", "shell.execute_reply": "2026-05-19T20:37:36.357082Z" } }, "outputs": [], "source": [ "Double_t x[10] = {0.5232808, 0.8724928, 0.9280086, 0.7059456, 0.7399714,\n", " 0.4659742, 0.8241404, 0.4838825, 0.7936963, 0.743553};\n", "Double_t y[10] = {0.7290837, 0.9631474, 0.4775896, 0.6494024, 0.3555777,\n", " 0.622012, 0.7938247, 0.9482072, 0.3904382, 0.2410359};\n", "auto graph = new TGraph(10, x, y);\n", "graph->SetLineColorAlpha(46, 0.1);\n", "graph->SetLineWidth(7);\n", "graph->Draw(\"l\");" ] }, { "cell_type": "markdown", "id": "2ba2530e", "metadata": {}, "source": [ "Draw an ellipse with opaque colors." ] }, { "cell_type": "code", "execution_count": 3, "id": "0a9aacd5", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:37:36.359807Z", "iopub.status.busy": "2026-05-19T20:37:36.359674Z", "iopub.status.idle": "2026-05-19T20:37:36.570940Z", "shell.execute_reply": "2026-05-19T20:37:36.570539Z" } }, "outputs": [], "source": [ "auto ellipse = new TEllipse(0.1740688, 0.8352632, 0.1518625, 0.1010526, 0, 360, 0);\n", "ellipse->SetFillColor(30);\n", "ellipse->SetLineColor(51);\n", "ellipse->SetLineWidth(3);\n", "ellipse->Draw();" ] }, { "cell_type": "markdown", "id": "1d3433ca", "metadata": {}, "source": [ "Draw an ellipse with transparent colors, above the previous one." ] }, { "cell_type": "code", "execution_count": 4, "id": "f7d27dd9", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:37:36.573030Z", "iopub.status.busy": "2026-05-19T20:37:36.572891Z", "iopub.status.idle": "2026-05-19T20:37:36.785025Z", "shell.execute_reply": "2026-05-19T20:37:36.784049Z" } }, "outputs": [], "source": [ "ellipse = new TEllipse(0.2985315, 0.7092105, 0.1566977, 0.1868421, 0, 360, 0);\n", "ellipse->SetFillColorAlpha(9, 0.571);\n", "ellipse->SetLineColorAlpha(8, 0.464);\n", "ellipse->SetLineWidth(3);\n", "ellipse->Draw();" ] }, { "cell_type": "markdown", "id": "4dc4d163", "metadata": {}, "source": [ "Draw a transparent blue text." ] }, { "cell_type": "code", "execution_count": 5, "id": "485087dc", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:37:36.786439Z", "iopub.status.busy": "2026-05-19T20:37:36.786321Z", "iopub.status.idle": "2026-05-19T20:37:36.997988Z", "shell.execute_reply": "2026-05-19T20:37:36.997037Z" } }, "outputs": [], "source": [ "tex = new TLatex(0.04871059, 0.1837649, \"This text is transparent\");\n", "tex->SetTextColorAlpha(9, 0.476);\n", "tex->SetTextSize(0.125);\n", "tex->SetTextAngle(26.0);\n", "tex->Draw();" ] }, { "cell_type": "markdown", "id": "276cb9c3", "metadata": {}, "source": [ "Draw two transparent markers" ] }, { "cell_type": "code", "execution_count": 6, "id": "d10ffb15", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:37:36.999356Z", "iopub.status.busy": "2026-05-19T20:37:36.999241Z", "iopub.status.idle": "2026-05-19T20:37:37.211437Z", "shell.execute_reply": "2026-05-19T20:37:37.210474Z" } }, "outputs": [], "source": [ "auto marker = new TMarker(0.03080229, 0.998008, 20);\n", "marker->SetMarkerColorAlpha(2, .3);\n", "marker->SetMarkerStyle(20);\n", "marker->SetMarkerSize(1.7);\n", "marker->Draw();\n", "marker = new TMarker(0.1239255, 0.8635458, 20);\n", "marker->SetMarkerColorAlpha(2, .2);\n", "marker->SetMarkerStyle(20);\n", "marker->SetMarkerSize(1.7);\n", "marker->Draw();" ] }, { "cell_type": "markdown", "id": "49dfaeda", "metadata": {}, "source": [ "Draw an opaque marker" ] }, { "cell_type": "code", "execution_count": 7, "id": "5da6d0a1", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:37:37.212836Z", "iopub.status.busy": "2026-05-19T20:37:37.212712Z", "iopub.status.idle": "2026-05-19T20:37:37.424344Z", "shell.execute_reply": "2026-05-19T20:37:37.423433Z" } }, "outputs": [], "source": [ "marker = new TMarker(0.3047994, 0.6344622, 20);\n", "marker->SetMarkerColor(2);\n", "marker->SetMarkerStyle(20);\n", "marker->SetMarkerSize(1.7);\n", "marker->Draw();" ] }, { "cell_type": "markdown", "id": "392402f9", "metadata": {}, "source": [ "Draw all canvases " ] }, { "cell_type": "code", "execution_count": 8, "id": "33bd4d0f", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:37:37.425716Z", "iopub.status.busy": "2026-05-19T20:37:37.425585Z", "iopub.status.idle": "2026-05-19T20:37:37.637512Z", "shell.execute_reply": "2026-05-19T20:37:37.636635Z" } }, "outputs": [ { "data": { "text/html": [ "\n", "\n", "