# Draw("P") option not working correctly

**URL:** <https://root-forum.cern.ch/t/draw-p-option-not-working-correctly/32088>\
**Category:** Newbie\
**Tags:** hist\
**Created:** [December 23, 2018, 6:35pm UTC](https://root-forum.cern.ch/t/draw-p-option-not-working-correctly/32088 "2018-12-23T18:35:13Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![FlorianB](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/f/e95f7d/32.png) [@FlorianB](https://root-forum.cern.ch/u/FlorianB)\
**Post date:** [December 23, 2018, 6:35pm UTC](https://root-forum.cern.ch/t/draw-p-option-not-working-correctly/32088/1 "2018-12-23T18:35:13Z")

</div>

```auto
TFile* event_time_per_cluster(int debug = 0)
{
    //gROOT->ProcessLine(".x cbmsim.C");
    TCanvas* c1 = new TCanvas("c1","c1");
    TFile* rec_root = new TFile("ev100_12gev_00001.rec.root", "UPDATE");
    rec_root->cd("MonitorResults;1");
    if (debug) rec_root->pwd();
    if (debug) rec_root->ls();
    TH1F* sts_cluster_exec_time = (TH1F*) gDirectory->Get("hist_0x55ed969e1d50_StsFindClusters_EXEC_TIM;1");
    if (debug) cout << "pointer of sts cluster exec time " << sts_cluster_exec_time << endl;

    //TCanvas* c1 = new TCanvas("c1","c1");

    int size = sts_cluster_exec_time->GetNbinsX();
    if (debug) cout << "number of bins " << size << endl;
    float time_per_event[size];
    for (int i=0; i < size; i++) {
        time_per_event[i] = sts_cluster_exec_time->GetBinContent(i);
        if (debug) cout << sts_cluster_exec_time->GetBinContent(i) << endl;
    }

    cbmsim t;
    int* cluster_per_event = t.Loop();

    TH1F* h1 = new TH1F("h1", "Time per Cluster Event Mode", 2000, 7000, 9000);
    h1->SetXTitle("Number of Clusters");
    h1->SetYTitle("Time");

    for(int i=0; i< size; i++) {
        h1->Fill(cluster_per_event[i], time_per_event[i]);
        if (1) cout << "i = " << i << " clusters = " << cluster_per_event[i] << " time = " << time_per_event[i] << endl;
    }
    gDirectory->pwd();
    h1->SetMarkerStyle(20);
    h1->Draw("P");
    //h1->Print();
    c1->Modified();
    c1->Update();
    h1->Write("Time_per_Event_Clusters",TObject::kOverwrite);

    //rec_root->Close();
    return rec_root;
}

```

So basically I want to draw a histogram without connected lines. When using the Draw(“P”) function, it draws the markers but also draws lines.  
Can anyone explain what’s happening?

Ubuntu with Root version 6.10/8

---

<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:** [December 23, 2018, 6:42pm UTC](https://root-forum.cern.ch/t/draw-p-option-not-working-correctly/32088/2 "2018-12-23T18:42:21Z")

</div>

Try: [`h1->Draw("HIST P");`](https://root.cern.ch/doc/master/classTHistPainter.html#HP01a)

---

<div class="post-metadata">

**Author:** ![FlorianB](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/f/e95f7d/32.png) [@FlorianB](https://root-forum.cern.ch/u/FlorianB)\
**Post date:** [December 23, 2018, 6:46pm UTC](https://root-forum.cern.ch/t/draw-p-option-not-working-correctly/32088/3 "2018-12-23T18:46:21Z")

</div>

Still produces the same output for me. Any other ideas?  
Edit: Now it seems to work but I can’t open my histo anymore?  
Edit 2: Okay, i don’t know what happened but it all worked out after restarting, thanks.  
Would you mind explaining why adding HIST did the job? Where did i tell the histo i had error bars??

---

<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:** [December 23, 2018, 7:24pm UTC](https://root-forum.cern.ch/t/draw-p-option-not-working-correctly/32088/4 "2018-12-23T19:24:55Z")

</div>

[TH1::Fill](https://root.cern.ch/doc/master/classTH1.html#a498de8e0804e75fc75e62dc14a3bb62d)

---

<div class="post-metadata">

**Author:** ![FlorianB](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/f/e95f7d/32.png) [@FlorianB](https://root-forum.cern.ch/u/FlorianB)\
**Post date:** [December 23, 2018, 7:49pm UTC](https://root-forum.cern.ch/t/draw-p-option-not-working-correctly/32088/5 "2018-12-23T19:49:30Z")

</div>

Mhm okay thanks, I now do understand where it comes from, but I don’t quite get why it’s implemented like that.  
Is there a better way to fit various values to a float?
