{ "cells": [ { "cell_type": "markdown", "id": "4ce36a5f", "metadata": {}, "source": [ "# ZoomHistogram\n", "Changing the Range on the X-Axis of a Histogram\n", "\n", "Image produced by `.x ZoomHistogram.C`\n", "\n", "This demonstrates how to zoom into a histogram by\n", "changing the range on one of the axes (or both).\n", "\n", "\n", "\n", "\n", "**Author:** Advait Dhingra \n", "This notebook tutorial was automatically generated with ROOTBOOK-izer from the macro found in the ROOT repository on Tuesday, March 19, 2024 at 07:11 PM." ] }, { "cell_type": "code", "execution_count": 1, "id": "368e49de", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2024-03-19T19:12:02.310285Z", "iopub.status.busy": "2024-03-19T19:12:02.309886Z", "iopub.status.idle": "2024-03-19T19:12:03.476649Z", "shell.execute_reply": "2024-03-19T19:12:03.475345Z" } }, "outputs": [], "source": [ "TH1F *orig = new TH1F(\"Normal Histogram\", \"Normal Histogram\", 100, 0, 100);\n", "\n", "for (int i = 0; i < 100; ++i) {\n", " Double_t x = gRandom->Gaus(50, 10);\n", " orig->Fill(x);\n", "}\n", "\n", "TH1F *zoom = (TH1F *)orig->Clone(\"zoom\");\n", "zoom->SetTitle(\"Zoomed-in Histogram\");\n", "zoom->GetXaxis()->SetRangeUser(50, 100);\n", "\n", "TCanvas *c1 = new TCanvas(\"c1\", \"Histogram\", 1500, 700);\n", "c1->Divide(2, 1);\n", "\n", "c1->cd(1);\n", "orig->Draw();\n", "c1->cd(2);\n", "zoom->Draw();" ] }, { "cell_type": "markdown", "id": "4cd0a011", "metadata": {}, "source": [ "Draw all canvases " ] }, { "cell_type": "code", "execution_count": 2, "id": "ff456156", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2024-03-19T19:12:03.489094Z", "iopub.status.busy": "2024-03-19T19:12:03.488716Z", "iopub.status.idle": "2024-03-19T19:12:03.920799Z", "shell.execute_reply": "2024-03-19T19:12:03.919281Z" } }, "outputs": [ { "data": { "text/html": [ "\n", "\n", "