# Regarding the canvas and plotting of graphs

**URL:** <https://root-forum.cern.ch/t/regarding-the-canvas-and-plotting-of-graphs/53230>\
**Category:** Newbie\
**Created:** [January 23, 2023, 9:46pm UTC](https://root-forum.cern.ch/t/regarding-the-canvas-and-plotting-of-graphs/53230 "2023-01-23T21:46:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lovish\_Sharma](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/lovish_sharma/32/32106_2.png) [@Lovish\_Sharma](https://root-forum.cern.ch/u/Lovish_Sharma)\
**Post date:** [January 23, 2023, 9:46pm UTC](https://root-forum.cern.ch/t/regarding-the-canvas-and-plotting-of-graphs/53230/1 "2023-01-23T21:46:30Z")

</div>

whenever i try to plot a graph in root it looks like this. I ran a slit code which was on root primer and got this  
_ROOT Version:_ 6.26/10  
_Platform:_ Ubuntu 22  
_Compiler:_ Not Provided

* * *

 ![Screenshot_20230124_031505](https://root-forum.cern.ch/uploads/default/original/3X/7/a/7a087e748a8169976dc158c9af240ce2fd18c3a5.png)

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [January 24, 2023, 6:48am UTC](https://root-forum.cern.ch/t/regarding-the-canvas-and-plotting-of-graphs/53230/2 "2023-01-24T06:48:18Z")

</div>

Really weird, can you post the macro you are running ? and also the command you type to run it ?

---

<div class="post-metadata">

**Author:** ![Lovish\_Sharma](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/lovish_sharma/32/32106_2.png) [@Lovish\_Sharma](https://root-forum.cern.ch/u/Lovish_Sharma)\
**Post date:** [January 24, 2023, 10:19am UTC](https://root-forum.cern.ch/t/regarding-the-canvas-and-plotting-of-graphs/53230/3 "2023-01-24T10:19:38Z")

</div>

I am using the sample fnslit code that is written in the root primer,

```cpp
// Example drawing the interference pattern of light
// falling on a grid with n slits and ratio r of slit
// width over distance between slits.

auto pi = TMath::Pi();

// function code in C
double single(double *x, double *par) {
  return pow(sin(pi*par[0]*x[0])/(pi*par[0]*x[0]),2);
}

double nslit0(double *x,double *par){
  return pow(sin(pi*par[1]*x[0])/sin(pi*x[0]),2);
}

double nslit(double *x, double *par){
  return single(x,par) * nslit0(x,par);
}

// This is the main program
void slits() {
  float r,ns;

  // request user input
  cout << "slit width / g ? ";
  scanf("%f",&r);
  cout << "# of slits? ";
  scanf("%f",&ns);
  cout <<"interference pattern for "<< ns
       <<" slits, width/distance: "<<r<<endl;

  // define function and set options
  TF1 *Fnslit = new TF1("Fnslit",nslit,-5.001,5.,2);
  Fnslit->SetNpx(500);

  // set parameters, as read in above
  Fnslit->SetParameter(0,r);
  Fnslit->SetParameter(1,ns);

  // draw the interference pattern for a grid with n slits
  Fnslit->Draw();
}

```

 ![Screenshot_20230124_154813](https://root-forum.cern.ch/uploads/default/original/3X/5/9/5951731734147954b0955c45928cf2a3d7d4f5cd.png)  
 ![Screenshot_20230124_154913](https://root-forum.cern.ch/uploads/default/original/3X/1/b/1b91443e765b275197ba0dc1315e946e7d106d53.png)

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [January 24, 2023, 10:42am UTC](https://root-forum.cern.ch/t/regarding-the-canvas-and-plotting-of-graphs/53230/4 "2023-01-24T10:42:34Z")

</div>

In your first post I find: `*Platform:* Ubuntu 22`  
In your last post I find that you try to use ROOT built with: “`c++ (Ubuntu ... 20.04 ...) 9.4.0`”.  
They will not play together.

You need ROOT binaries built for your system / compiler.
