{ "cells": [ { "cell_type": "markdown", "id": "6a644d01", "metadata": {}, "source": [ "# xyplot\n", "centered at (0,0).\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": "4692b6a8", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:37:38.092161Z", "iopub.status.busy": "2026-05-19T20:37:38.092050Z", "iopub.status.idle": "2026-05-19T20:37:38.442989Z", "shell.execute_reply": "2026-05-19T20:37:38.441890Z" } }, "outputs": [], "source": [ "TCanvas *c = new TCanvas(\"c\", \"XY plot\", 200, 10, 700, 500);" ] }, { "cell_type": "markdown", "id": "dfdd3be4", "metadata": {}, "source": [ "Remove the frame" ] }, { "cell_type": "code", "execution_count": 2, "id": "8d2886de", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:37:38.444518Z", "iopub.status.busy": "2026-05-19T20:37:38.444390Z", "iopub.status.idle": "2026-05-19T20:37:38.656506Z", "shell.execute_reply": "2026-05-19T20:37:38.655437Z" } }, "outputs": [], "source": [ "c->SetFillColor(kWhite);\n", "c->SetFrameLineColor(kWhite);\n", "c->SetFrameBorderMode(0);" ] }, { "cell_type": "markdown", "id": "b2df2373", "metadata": {}, "source": [ "Define and draw a curve the frame" ] }, { "cell_type": "code", "execution_count": 3, "id": "dade5ff5", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:37:38.657991Z", "iopub.status.busy": "2026-05-19T20:37:38.657867Z", "iopub.status.idle": "2026-05-19T20:37:38.880900Z", "shell.execute_reply": "2026-05-19T20:37:38.867394Z" } }, "outputs": [], "source": [ "const Int_t n = 4;\n", "Double_t x[n] = {-1, -3, -9, 3};\n", "Double_t y[n] = {-1000, 900, 300, 300};\n", "TGraph *gr = new TGraph(n, x, y);\n", "gr->SetTitle(\"XY plot\");\n", "gr->SetMinimum(-1080);\n", "gr->SetMaximum(1080);\n", "gr->SetLineColor(kRed);\n", "gr->Draw(\"AC*\");" ] }, { "cell_type": "markdown", "id": "d7b40ee7", "metadata": {}, "source": [ "Remove the frame's axis" ] }, { "cell_type": "code", "execution_count": 4, "id": "6b09a475", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:37:38.882433Z", "iopub.status.busy": "2026-05-19T20:37:38.882306Z", "iopub.status.idle": "2026-05-19T20:37:39.094037Z", "shell.execute_reply": "2026-05-19T20:37:39.093447Z" } }, "outputs": [ { "data": { "text/html": [ "\n", "\n", "
\n", "
\n", "\n", "\n", "\n" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "gr->GetHistogram()->GetYaxis()->SetTickLength(0);\n", "gr->GetHistogram()->GetXaxis()->SetTickLength(0);\n", "gr->GetHistogram()->GetYaxis()->SetLabelSize(0);\n", "gr->GetHistogram()->GetXaxis()->SetLabelSize(0);\n", "gr->GetHistogram()->GetXaxis()->SetAxisColor(0);\n", "gr->GetHistogram()->GetYaxis()->SetAxisColor(0);\n", "\n", "gPad->Update();" ] }, { "cell_type": "markdown", "id": "eea0f1c7", "metadata": {}, "source": [ "Draw orthogonal axis system centered at (0,0).\n", "Draw the Y axis. Note the 4th label is erased with SetLabelAttributes" ] }, { "cell_type": "code", "execution_count": 5, "id": "3e1ca390", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:37:39.099422Z", "iopub.status.busy": "2026-05-19T20:37:39.099297Z", "iopub.status.idle": "2026-05-19T20:37:39.329041Z", "shell.execute_reply": "2026-05-19T20:37:39.320612Z" } }, "outputs": [], "source": [ "TGaxis *yaxis = new TGaxis(0, gPad->GetUymin(), 0, gPad->GetUymax(), gPad->GetUymin(), gPad->GetUymax(), 6, \"+LN\");\n", "yaxis->ChangeLabel(4, -1, 0.);\n", "yaxis->Draw();" ] }, { "cell_type": "markdown", "id": "c54e3de0", "metadata": {}, "source": [ "Draw the Y-axis title." ] }, { "cell_type": "code", "execution_count": 6, "id": "50a1c701", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:37:39.330975Z", "iopub.status.busy": "2026-05-19T20:37:39.330847Z", "iopub.status.idle": "2026-05-19T20:37:39.542834Z", "shell.execute_reply": "2026-05-19T20:37:39.542132Z" } }, "outputs": [], "source": [ "TLatex *ytitle = new TLatex(-0.5, gPad->GetUymax(), \"Y axis\");\n", "ytitle->Draw();\n", "ytitle->SetTextSize(0.03);\n", "ytitle->SetTextAngle(90.);\n", "ytitle->SetTextAlign(31);" ] }, { "cell_type": "markdown", "id": "b1ce9244", "metadata": {}, "source": [ "Draw the X axis" ] }, { "cell_type": "code", "execution_count": 7, "id": "edea1ac0", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:37:39.552223Z", "iopub.status.busy": "2026-05-19T20:37:39.552093Z", "iopub.status.idle": "2026-05-19T20:37:39.763740Z", "shell.execute_reply": "2026-05-19T20:37:39.763124Z" } }, "outputs": [], "source": [ "TGaxis *xaxis = new TGaxis(gPad->GetUxmin(), 0, gPad->GetUxmax(), 0, gPad->GetUxmin(), gPad->GetUxmax(), 510, \"+L\");\n", "xaxis->Draw();" ] }, { "cell_type": "markdown", "id": "385edffd", "metadata": {}, "source": [ "Draw the X axis title." ] }, { "cell_type": "code", "execution_count": 8, "id": "1791d632", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:37:39.773919Z", "iopub.status.busy": "2026-05-19T20:37:39.773791Z", "iopub.status.idle": "2026-05-19T20:37:39.986027Z", "shell.execute_reply": "2026-05-19T20:37:39.985399Z" } }, "outputs": [], "source": [ "TLatex *xtitle = new TLatex(gPad->GetUxmax(), -200., \"X axis\");\n", "xtitle->Draw();\n", "xtitle->SetTextAlign(31);\n", "xtitle->SetTextSize(0.03);" ] }, { "cell_type": "markdown", "id": "83505a1f", "metadata": {}, "source": [ "Draw all canvases " ] }, { "cell_type": "code", "execution_count": 9, "id": "c8f2462c", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:37:39.987757Z", "iopub.status.busy": "2026-05-19T20:37:39.987617Z", "iopub.status.idle": "2026-05-19T20:37:40.203239Z", "shell.execute_reply": "2026-05-19T20:37:40.202630Z" } }, "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 }