{ "cells": [ { "cell_type": "markdown", "id": "90f90e0a", "metadata": {}, "source": [ "# hist2image\n", "Create an image from a 2-D histogram and manipulate it.\n", "\n", "\n", "\n", "\n", "**Author:** Valeriy Onuchin \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": "a7a27f38", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:38:37.557446Z", "iopub.status.busy": "2026-05-19T20:38:37.557324Z", "iopub.status.idle": "2026-05-19T20:38:37.910225Z", "shell.execute_reply": "2026-05-19T20:38:37.909552Z" } }, "outputs": [], "source": [ "TCanvas *canv = new TCanvas(\"image\", \"xygaus + xygaus(5) + xylandau(10)\");\n", "canv->ToggleEventStatus();\n", "canv->SetRightMargin(0.2);\n", "canv->SetLeftMargin(0.01);\n", "canv->SetTopMargin(0.01);\n", "canv->SetBottomMargin(0.01);" ] }, { "cell_type": "markdown", "id": "34f27ea0", "metadata": {}, "source": [ "histogram as image (hist taken from draw2dopt.C)" ] }, { "cell_type": "code", "execution_count": 2, "id": "68bd4d12", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:38:37.912196Z", "iopub.status.busy": "2026-05-19T20:38:37.912073Z", "iopub.status.idle": "2026-05-19T20:38:38.123998Z", "shell.execute_reply": "2026-05-19T20:38:38.123598Z" } }, "outputs": [], "source": [ "TImage *img = TImage::Create();\n", "\n", "TF2 *f2 = new TF2(\"f2\", \"(xygaus + xygaus(5) + xylandau(10))\", -4, 4, -4, 4);\n", "Double_t params[] = {130, -1.4, 1.8, 1.5, 1, 150, 2, 0.5, -2, 0.5, 3600, -2, 0.7, -3, 0.3};\n", "f2->SetParameters(params);\n", "TH2D *h2 = new TH2D(\"h2\", \"xygaus + xygaus(5) + xylandau(10)\", 100, -4, 4, 100, -4, 4);\n", "h2->FillRandom(\"f2\", 40000);\n", "img->SetImage((const Double_t *)h2->GetArray(), h2->GetNbinsX() + 2, h2->GetNbinsY() + 2, gHistImagePalette);\n", "img->Draw();" ] }, { "cell_type": "markdown", "id": "f1b6d1b5", "metadata": {}, "source": [ "Draw all canvases " ] }, { "cell_type": "code", "execution_count": 3, "id": "7e97df9a", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:38:38.136409Z", "iopub.status.busy": "2026-05-19T20:38:38.136280Z", "iopub.status.idle": "2026-05-19T20:38:38.348203Z", "shell.execute_reply": "2026-05-19T20:38:38.347827Z" } }, "outputs": [ { "data": { "text/html": [ "\n", "\n", "