Strange TMarker behaviour with ROOT plotting package
<p>Hopefully someone here has some experience with the ROOT package (root.cern.ch). I'm trying to define my own class that utilises several ROOT classes. I have noticed some strange behaviour with the TMarker class, though.</p>

<p>Here is my code:</p>

<p><strong>Skymap.h:</strong></p>

<pre><code>#ifndef SKYMAP_H_
#define SKYMAP_H_

#include &lt;cmath&gt;
#include &lt;iostream&gt;
#include &lt;cstdlib&gt;
#include &lt;vector&gt;

#include "TCanvas.h"
#include "TMarker.h"

class Skymap {
 public:

  Skymap();

  void PlotSinglePoint(const float&amp;,const float&amp;);
  void Print(const std::string&amp;);

  void DrawAll();

 private:
  TCanvas mCanvas;
  std::vector&lt;TMarker&gt; mMarkers;
};

#endif
</code></pre>

<p><strong>Skymap.cpp:</strong></p>

<pre><code>#include "Skymap.h"

Skymap::Skymap() 
  : mCanvas("c1","",0,0,800,800)
{
  mCanvas.Range(-30,-30,30,30);
}

void Skymap::Print(const std::string&amp; filepth)
{
  mCanvas.Print(filepth.c_str());
}


void Skymap::PlotSinglePoint(const float&amp; x,const float&amp; y)
{
  mMarkers.push_back(TMarker(x,y,7));
  mMarkers.back().Draw();
}


void Skymap::DrawAll()
{
  for(int i=0;i&lt;mMarkers.size();++i){
   mMarkers[i].Draw();
  }
}
</code></pre>

<p><strong>Main.cpp:</strong></p>

<pre><code>#include &lt;cstdlib&gt;
#include &lt;iostream&gt;
#include "Skymap.h"

int main(){
  Skymap test;
  float x1=-10.,y1=15.;
  test.PlotSinglePoint(x1,y1);

  float x2=10.,y2=20.;
  test.PlotSinglePoint(x2,y2);

  //test.DrawAll();
  test.Print("test.eps");
}
</code></pre>

<p>Now, if I take the code as above and run it, only the most recently-drawn TMarker in mMarkers appears in the final image I output.</p>

<p>However, if I comment out the Draw() command in PlotSinglePoint and uncomment the DrawAll() line in Main.cpp (i.e. meaning I draw all the TMarkers in mMarkers in one function call, rather than drawing each one as I add them) then the final image contains all of my TMarkers. Is anyone able to enlighten me as to why this is occurring?</p>
