{ "cells": [ { "cell_type": "markdown", "id": "6d51a510", "metadata": {}, "source": [ "# gr110_logscale\n", "The logarithmic scale can be applied to either the x-axis, the y-axis, or both axes at the same time.\n", "When using a logarithmic scale, the data must be positive since the logarithm is undefined for non-positive values and zero.\n", "\n", "\n", "\n", "**Author:** Emanuele Chiamulera \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": "23c7f03f", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:38:27.823275Z", "iopub.status.busy": "2026-05-19T20:38:27.823144Z", "iopub.status.idle": "2026-05-19T20:38:28.284415Z", "shell.execute_reply": "2026-05-19T20:38:28.283960Z" } }, "outputs": [], "source": [ "auto c = new TCanvas(\"c\",\"Reversed graphs\",0,0,900,400);\n", "c->Divide(2,1);\n", "c->cd(1);\n", "\n", "const Int_t n = 6; //Fill the arrays x and y with the data points\n", "Double_t x[n], y[n];\n", "for (Int_t i=0;iSetLineColor(2);\n", "gr1->SetLineWidth(4);\n", "gr1->SetMarkerColor(4);\n", "gr1->SetMarkerStyle(21);\n", "gr1->SetTitle(\"Graph without log scale\");\n", "gr1->DrawClone(\"ACP\");" ] }, { "cell_type": "markdown", "id": "f96becb6", "metadata": {}, "source": [ "The logarithmic scale setting can also be done in a ROOT interactive session." ] }, { "cell_type": "code", "execution_count": 2, "id": "78e36b6d", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:38:28.291252Z", "iopub.status.busy": "2026-05-19T20:38:28.291100Z", "iopub.status.idle": "2026-05-19T20:38:28.519939Z", "shell.execute_reply": "2026-05-19T20:38:28.519475Z" } }, "outputs": [], "source": [ "c->cd(2);\n", "gPad->SetLogy();" ] }, { "cell_type": "markdown", "id": "39dcace4", "metadata": {}, "source": [ "gPad->SetLogx(); Uncomment this line if log scale is needed on both axes" ] }, { "cell_type": "code", "execution_count": 3, "id": "1acecbc8", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:38:28.527714Z", "iopub.status.busy": "2026-05-19T20:38:28.527560Z", "iopub.status.idle": "2026-05-19T20:38:28.735634Z", "shell.execute_reply": "2026-05-19T20:38:28.734561Z" } }, "outputs": [], "source": [ "gr1->SetTitle(\"Graph with y log scale\");\n", "gr1->Draw(\"ACP\");" ] }, { "cell_type": "markdown", "id": "d20732fd", "metadata": {}, "source": [ "Draw all canvases " ] }, { "cell_type": "code", "execution_count": 4, "id": "6e1a568f", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:38:28.737317Z", "iopub.status.busy": "2026-05-19T20:38:28.737182Z", "iopub.status.idle": "2026-05-19T20:38:28.948971Z", "shell.execute_reply": "2026-05-19T20:38:28.948391Z" } }, "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 }