{ "cells": [ { "cell_type": "markdown", "id": "3a43e476", "metadata": {}, "source": [ "# logscales\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": "21db96ff", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:37:15.293570Z", "iopub.status.busy": "2026-05-19T20:37:15.293460Z", "iopub.status.idle": "2026-05-19T20:37:15.842978Z", "shell.execute_reply": "2026-05-19T20:37:15.842476Z" } }, "outputs": [], "source": [ "TCanvas *c1 = new TCanvas(\"c1\", \"Various options on LOG scales plots\", 0, 0, 700, 900);\n", "c1->SetFillColor(30);\n", "\n", "TPad *pad1 = new TPad(\"pad1\", \"pad1\", 0.03, 0.62, 0.50, 0.92, 32);\n", "TPad *pad2 = new TPad(\"pad2\", \"pad2\", 0.51, 0.62, 0.98, 0.92, 33);\n", "TPad *pad3 = new TPad(\"pad3\", \"pad3\", 0.03, 0.02, 0.97, 0.535, 38);\n", "pad1->Draw();\n", "pad2->Draw();\n", "pad3->Draw();\n", "\n", "TPaveLabel *title = new TPaveLabel(0.1, 0.94, 0.9, 0.98, \"Various options on LOG scales plots\");\n", "title->SetFillColor(16);\n", "title->SetTextFont(42);\n", "title->Draw();\n", "\n", "TPaveText *pave = new TPaveText(0.1, 0.55, 0.9, 0.61);\n", "pave->SetFillColor(42);\n", "pave->SetTextAlign(12);\n", "pave->SetTextFont(42);\n", "pave->AddText(\"When more Log labels are requested, the overlapping labels are removed\");\n", "pave->Draw();\n", "\n", "pad1->cd();\n", "pad1->SetLogy();\n", "pad1->SetGridy();\n", "TF1 *f1 = new TF1(\"f1\", \"x*sin(x)*exp(-0.1*x)+15\", -10., 10.);\n", "TF1 *f2 = new TF1(\"f2\", \"(sin(x)+cos(x))**5+15\", -10., 10.);\n", "TF1 *f3 = new TF1(\"f3\", \"(sin(x)/(x)-x*cos(x))+15\", -10., 10.);\n", "f1->SetLineWidth(1);\n", "f1->SetLineColor(2);\n", "f2->SetLineWidth(1);\n", "f2->SetLineColor(3);\n", "f3->SetLineWidth(1);\n", "f3->SetLineColor(4);\n", "f1->Draw();\n", "f2->Draw(\"same\");\n", "f3->Draw(\"same\");\n", "f1->GetYaxis()->SetMoreLogLabels();\n", "TPaveText *pave1 = new TPaveText(-6, 2, 6, 6);\n", "pave1->SetFillColor(42);\n", "pave1->SetTextAlign(12);\n", "pave1->SetTextFont(42);\n", "pave1->AddText(\"Log scale along Y axis.\");\n", "pave1->AddText(\"More Log labels requested.\");\n", "pave1->Draw();\n", "\n", "pad2->cd();\n", "double x[10] = {200, 300, 400, 500, 600, 650, 700, 710, 900, 1000};\n", "double y[10] = {200, 1000, 900, 400, 500, 250, 800, 150, 201, 220};\n", "TGraph *g_2 = new TGraph(10, x, y);\n", "g_2->Draw(\"AL*\");\n", "g_2->SetMarkerColor(2);\n", "g_2->GetYaxis()->SetMoreLogLabels();\n", "g_2->GetYaxis()->SetNoExponent();\n", "pad2->SetLogy();\n", "g_2->GetXaxis()->SetMoreLogLabels();\n", "pad2->SetLogx();\n", "pad2->SetGridx();\n", "TPaveText *pave2 = new TPaveText(150, 80, 500, 180);\n", "pave2->SetFillColor(42);\n", "pave2->SetTextFont(42);\n", "pave2->SetTextAlign(12);\n", "pave2->AddText(\"Log scale along X and Y axis.\");\n", "pave2->AddText(\"More Log labels on both.\");\n", "pave2->AddText(\"No exponent along Y axis.\");\n", "pave2->Draw();\n", "\n", "pad3->cd();\n", "pad3->SetGridx();\n", "pad3->SetGridy();\n", "pad3->SetLogy();\n", "pad3->SetLogx();\n", "TF1 *f4 = new TF1(\"f4a\", \"x*sin(x+10)+25\", 1, 21);\n", "f4->SetLineWidth(1);\n", "f4->Draw();\n", "f4->SetNpx(200);\n", "f4->GetYaxis()->SetMoreLogLabels();\n", "f4->GetXaxis()->SetMoreLogLabels();\n", "f4 = new TF1(\"f4b\", \"x*cos(x+10)*sin(x+10)+25\", 1, 21);\n", "f4->SetLineWidth(1);\n", "f4->Draw(\"same\");\n", "f4->SetNpx(200);\n", "Int_t a = 20;\n", "for (int i = a; i >= 1; i--) {\n", " f4 = new TF1(Form(\"f4b_%d\", i), \"x*sin(x+10)*[0]/[1]+25\", 1, 21);\n", " f4->SetParameter(0, i);\n", " f4->SetParameter(1, a);\n", " f4->SetNpx(200);\n", " f4->SetLineWidth(1);\n", " f4->SetLineColor(i + 10);\n", " f4->Draw(\"same\");\n", " f4 = new TF1(Form(\"f4c_%d\", i), \"x*cos(x+10)*sin(x+10)*[0]/[1]+25\", 1, 25);\n", " f4->SetParameter(0, i);\n", " f4->SetParameter(1, a);\n", " f4->SetNpx(200);\n", " f4->SetLineWidth(1);\n", " f4->SetLineColor(i + 30);\n", " f4->Draw(\"same\");\n", "}\n", "TPaveText *pave3 = new TPaveText(1.2, 8, 9, 15);\n", "pave3->SetFillColor(42);\n", "pave3->AddText(\"Log scale along X and Y axis.\");\n", "pave3->SetTextFont(42);\n", "pave3->SetTextAlign(12);\n", "pave3->AddText(\"More Log labels on both.\");\n", "pave3->AddText(\"The labels have no exponents (they would be 0 or 1)\");\n", "pave3->Draw();" ] }, { "cell_type": "markdown", "id": "f0f09497", "metadata": {}, "source": [ "Draw all canvases " ] }, { "cell_type": "code", "execution_count": 2, "id": "1f0df728", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:37:15.855414Z", "iopub.status.busy": "2026-05-19T20:37:15.855275Z", "iopub.status.idle": "2026-05-19T20:37:16.178017Z", "shell.execute_reply": "2026-05-19T20:37:16.177591Z" } }, "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 }