-
Notifications
You must be signed in to change notification settings - Fork 0
/
fun.cpp
60 lines (49 loc) · 1.35 KB
/
fun.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include <TCanvas.h>
#include <TLegend.h>
//#include <TRandom3.h>
#include "TH1.h"
#include "TF1.h"
#include "TMath.h"
//#include <fstream>
#include <iostream>
using namespace std;
double fun1(double* arg, double* par)
{
// arg is for the argument
// par is for parameters
double x= *arg;
return x/(1+x*x);
}
void fun()
{
// get canvas
TCanvas *canv = new TCanvas("Canvas", "Canvas Title", 800, 600);
canv->cd();
//canv->SetGrid(1,1)
// name fun m M
//TF1 *f1 = new TF1("Function", "x", 0, 10);
// name fun* m M npar
TF1 *f1 = new TF1("Function", fun1, 0, 10, 0);
//f1->SetParameters(0, 1, 2);
//f1->SetParNames("c0", "c1", "c2");
//f1->SetNpx(1000); // more points
// use this to set properies of the plot
// base_hist->GetWhatever()->SetWhatever();
TH1 *base_hist = f1->GetHistogram();
base_hist->SetTitle("Function plot");
base_hist->GetXaxis()->SetTitle("Boring X axis (Gbored/s)");
base_hist->GetYaxis()->SetTitle("Exciting Y axis (Gfun/s)");
base_hist->GetYaxis()->SetTitleOffset(1.2);
f1->Draw();
// add a legend
// lx by rx ty
//TLegend *leg = new TLegend(0.7, 0.75, 0.99, 0.9);
//leg->SetHeader("Legend Title");
//leg->AddEntry(base_hist, "Function","l");
//leg->AddEntry("a","Random string","l");
//leg->Draw();
}
int main()
{
fun();
}