Add new marker style

Hello,
I would like add a new marker style.
In fact, I would like to show text instead of dot or cross. Is it possible?

Not right now. In which context do you want to do this ?

For example, in nuclear physics, I plot something for different values of Z (atomic number). Color are useful most of the time but sometimes colors are unreadable (when there are too much Z for example)

Do you have a small example macro ? may be I can modify it and achieve what you are looking for using TLatex.

This is an example of macro. At the end, I have a lot of Z on the same graph and it is not really readable with only color. So, I would like show “Z=35”, “Z=36”, … instead of standard markers to see better each Z. I hope my macro will be explicit.

[code]#include
#include
#include <TGraph.h>

#define RUNMIN 295
#define RUNMAX 412

using namespace std;

void plot_Z_run()
{
int i,Z;
int RunNb=0;
int A=0;
int x[RUNMAX-RUNMIN+1];
int y[RUNMAX-RUNMIN+1];
for(i=0 ; i<=RUNMAX-RUNMIN ; i++) x[i]=0;
for(i=0 ; i<=RUNMAX-RUNMIN ; i++) y[i]=0;
char filename[50], text[50];

for(Z=35 ; Z<70 ; Z++)
{

  for(RunNb=RUNMIN ; RunNb<=RUNMAX ; RunNb++) // browse every run
{
  sprintf(filename,"file%i.dat",RunNb);
  ifstream ifile(filename);
  sscanf(text,"%i",&A);
  x[RunNb-RUNMIN]=RunNb;
  y[RunNb-RUNMIN]=A;
}

  TGraph *g = new TGraph(RUNMAX-RUNMIN,x,y);
  g->SetMarkerStyle(20);
  g->SetMarkerColor(Z%5+1);//0 is white
  g->SetLineColor(Z%5+1);

  char name[5];
  sprintf(name,"Z%i",Z);
  g->SetTitle(name);
  if(Z==35) g->Draw("ALP");
  else g->Draw("LP");
}

}[/code]

showing “Z=35”, “Z=36” for each marker position will be very unclear also I guess. You could for instance choose very different colors and them draw Z=… near the first point using the same color or use TLegend… The macro you sent is not really useful because it produces flat plots.

Right, my example was maybe not very conclusive. And it will be very unclear also. Yet, I think that it may be useful in some situation. Nevertheless, it is easier to read with “text” marker than color lines to differentiate different lines. Are you agree?

I am not sure it will be more clear … text like z=35 on each point might be really confusing if you have many curves on the same plot. They will overlap an you will see nothing. That’s why I asked you a concrete example. Anyway the idea to have user defined markers is on our list of things to do.

Indeed, I think that I may be unreadable if text is too big. So should the text be as small as markers size. Yet, maybe it will be also unreadable.

The script below illustrates how to add several text strings (here one single character)
above the data points of a graph. When the graph is written to a file, the list of strings follows.

Rene

[code]void graph() {

TCanvas *c1 = new TCanvas(“c1”,“A Simple Graph Example”,200,10,700,500);

c1->SetFillColor(42);
c1->SetGrid();

TString letters=“abcdefghijklmnopqrstuvwxyz”;
const Int_t n = 20;
TGraph gr = new TGraph(n);
TLatex l;
char let[2]; let[1]=0;
Double_t x, y;
for (Int_t i=0;i<n;i++) {
x = i
0.1;
y = 10
sin(x+0.2);
gr->SetPoint(i,x,y);
let[0] = letters[i];
l = new TLatex(x,y+0.2,let);
l->SetTextSize(0.04);
l->SetTextAlign(21);
gr->GetListOfFunctions()->Add(l);
}
gr->SetLineColor(2);
gr->SetLineWidth(4);
gr->SetMarkerColor(4);
gr->SetMarkerStyle(21);
gr->SetTitle(“a simple graph”);
gr->GetXaxis()->SetTitle(“X title”);
gr->GetYaxis()->SetTitle(“Y title”);
gr->Draw(“ACP”);
c1->Update();
c1->GetFrame()->SetFillColor(21);
c1->GetFrame()->SetBorderSize(12);
c1->Modified();
}
[/code]