Defining plot parameters

Hello everyone,

I’m a newbie in plotting graphs with root. Here is my problem: I want to draw an exponential function with parameters, which I set after defining the TF1. For some reason I don’t understand, the parameters seem uninitialized, so that I get a weird setting with very large parameter numbers.
Here is my minimal example. I attach a pdf of the output of that minimal example.

#include <vector>
#include <map>
#include <iostream>
#include <string>
#include <stdlib.h>
#include <stdio.h>
#include <sstream>
#include <fstream>

#include "TCanvas.h"
#include "TF1.h"
#include "TFrame.h"

void draw_a_graph(){

	TCanvas *c1 = new TCanvas("c1_fit1","The Fit Canvas",200,10,700,500);
	c1->SetGridx();
	c1->SetGridy();
	c1->GetFrame()->SetFillColor(21);
	c1->GetFrame()->SetBorderMode(-1);
	c1->GetFrame()->SetBorderSize(5);

	TF1* gfunction;
	gfunction = new TF1("gfunction","expo(0)", -500, 100);
   
	gfunction->SetParameter(0, 1.); 
        gfunction->SetParameter(1, 4.); 
	gfunction->Draw();
}

I would be so glad if anyone tells me what I do wrong here.

Best regards,
Aiedala
example_plot.pdf (13.8 KB)

You got exactly what you asked for.
Try with: gfunction->SetParameter(1, 0.004);

Thanks :slight_smile: Not my brightest moment #-o