diff --git a/tools/test_wfanalyzer.cxx b/tools/test_wfanalyzer.cxx
index f31fbac55b3ff36a70fb66b6e5d3ceaaf10d220d..ccbc15aa13326825fa55b8171869f0021b4a9efe 100644
--- a/tools/test_wfanalyzer.cxx
+++ b/tools/test_wfanalyzer.cxx
@@ -138,6 +138,7 @@ void test_wfanalyzer(const std::string &path = "", const std::vector<int> &indic
 
     int count = 0;
     for (auto &event : events) {
+        TMultiGraph *mg = new TMultiGraph();
         auto samples = event.raw;
         count ++;
         c->cd(count);
@@ -150,8 +151,7 @@ void test_wfanalyzer(const std::string &path = "", const std::vector<int> &indic
         wf->SetLineColor(kRed + 1);
         wf->SetLineWidth(3);
         wf->SetLineStyle(2);
-        wf->Draw("AL");
-        wf->GetXaxis()->SetRangeUser(0, samples.size() - 1);
+        mg->Add(wf, "l");
 
         // waveform resolution
         auto wf2 = new TGraph(samples.size());
@@ -161,7 +161,7 @@ void test_wfanalyzer(const std::string &path = "", const std::vector<int> &indic
         }
         wf2->SetLineColor(kBlue + 1);
         wf2->SetLineWidth(3);
-        wf2->Draw("L same");
+        mg->Add(wf2, "l");
 
         // peak finding
         auto data = ana.Analyze(&samples[0], samples.size());
@@ -169,14 +169,14 @@ void test_wfanalyzer(const std::string &path = "", const std::vector<int> &indic
         for (size_t i = 0; i < data.peaks.size(); ++i) {
             auto color = i + 40;
             auto peak = data.peaks[i];
-            auto grm = new TGraph(samples.size());
+            auto grm = new TGraph(1);
             grm->SetMarkerStyle(peak.height > 0 ? 23 : 22);
             grm->SetMarkerSize(1.5);
             grm->SetMarkerColor(kBlack);
             double range = wf->GetYaxis()-> GetXmax() - wf->GetYaxis()-> GetXmin();
             double height = peak.height + data.ped.mean + (peak.height > 0 ? 1. : -1.5)*range*0.02;
             grm->SetPoint(0, peak.pos, height);
-            grm->Draw("P same");
+            mg->Add(grm, "p");
 
             auto nint = peak.right - peak.left + 1;
             auto grs = new TGraph(2*nint);
@@ -186,12 +186,10 @@ void test_wfanalyzer(const std::string &path = "", const std::vector<int> &indic
                 grs->SetPoint(nint + i, peak.right - i, ped.mean);
             }
             grs->SetFillColor(color);
-            grs->SetFillStyle(3002);
-            grs->Draw("f same");
-            // gr->SetPoint(gr->GetN(), peak.pos - peak.left, peak.height + peak.base);
-            // gr->SetPoint(gr->GetN(), peak.pos + peak.right, peak.height + peak.base);
-            std::cout << peak.pos << ", " << peak.left << ", " << peak.right
-                      << ", " << peak.height << ", " << peak.integral << std::endl;
+            grs->SetFillStyle(3001);
+            mg->Add(grs, "f");
+            // std::cout << peak.pos << ", " << peak.left << ", " << peak.right
+            //           << ", " << peak.height << ", " << peak.integral << std::endl;
 
             if (i == 0 && count == 1) {
                 legend->AddEntry(grm, Form("Peaks (threhold = %.2f)", thres), "p");
@@ -200,38 +198,42 @@ void test_wfanalyzer(const std::string &path = "", const std::vector<int> &indic
         }
 
         // pedestal line
-        /*
-        std::vector<double> tped(samples.size());
-        tped.assign(samples.begin(), samples.end());
-        TSpectrum s;
-        s.Background(&tped[0], samples.size(), samples.size()/4, TSpectrum::kBackDecreasingWindow,
-                     TSpectrum::kBackOrder2, false, TSpectrum::kBackSmoothing3, false);
-        */
-        auto grp = new TGraph(samples.size());
-        auto gre = new TGraph(2*samples.size());
+        auto grp = new TGraphErrors(samples.size());
         for (size_t i = 0; i < samples.size(); ++i) {
-            double pedy = ped.mean;
-            grp->SetPoint(i, i, pedy);
+            grp->SetPoint(i, i, ped.mean);
+            grp->SetPointError(i, 0, ped.err);
             // grp->SetPoint(i, i, tped[i]);
-            gre->SetPoint(i, i, pedy + ped.err);
-            size_t j = samples.size() - i - 1;
-            double pedy2 = ped.mean; // p0 + ped.p1*j;
-            gre->SetPoint(i + samples.size(), j, pedy2 - ped.err);
         }
-        gre->SetFillStyle(3001);
-        gre->SetFillColor(kBlack);
-        grp->SetFillStyle(3001);
         grp->SetFillColor(kBlack);
+        grp->SetFillStyle(3001);
         grp->SetLineStyle(0);
         grp->SetLineWidth(2);
         grp->SetLineColor(kBlack);
-        gre->Draw("f same");
-        grp->Draw("L same");
+        mg->Add(grp, "l3");
+
+        // TSpectrum background
+        std::vector<double> tped(samples.size());
+        tped.assign(samples.begin(), samples.end());
+        TSpectrum s;
+        s.Background(&tped[0], samples.size(), samples.size()/4, TSpectrum::kBackDecreasingWindow,
+                     TSpectrum::kBackOrder2, false, TSpectrum::kBackSmoothing3, false);
+        auto grp2 = new TGraph(samples.size());
+        for (size_t i = 0; i < samples.size(); ++i) {
+            grp2->SetPoint(i, i, tped[i]);
+        }
+        grp2->SetLineStyle(2);
+        grp2->SetLineWidth(2);
+        grp2->SetLineColor(kBlack);
+        mg->Add(grp2, "l");
+        if (count == 1) { legend->AddEntry(grp2, "TSpectrum Background", "l"); }
+
         if (count == 1) {
             legend->AddEntry(wf, "Raw Samples", "l");
             legend->AddEntry(wf2, Form("Smoothed Samples (res = %zu)", res), "l");
             legend->AddEntry(grp, "Pedestal", "lf");
         }
+        mg->Draw("A");
+        mg->GetXaxis()->SetRangeUser(0, samples.size() - 1);
     }
     c->cd(events.size() + 1);
     legend->Draw();