TGraphPainter - Error bars not drawn if marker too large

Hi,

it seems that TGraphPainter doesn’t draw error bars if the marker size is too large. In the attached image, produced with source code

	TCanvas c1("c1","c1",800,400);
	c1.Divide(2,1);
	
	double x[3] = {1,2,3}, dx[3] = {0,0,0};
	double y[3] = {1,2,3}, dy[3] = {0.05,0.1,0.2}; 
	gStyle->SetEndErrorSize(4);
	
	TGraphErrors g1(3,x,y,dx,dy);
	TGraphErrors g2(3,x,y,dx,dy);
	
	c1.cd(1);
	g1.SetMarkerStyle(33);
	g1.SetLineWidth(2);
	g1.SetMarkerSize(1.4);
	g1.Draw("AP");
	
	c1.cd(2);
	g2.SetMarkerStyle(33);
	g2.SetLineWidth(2);
	g2.SetMarkerSize(1.5);
	g2.Draw("AP");
	
	c1.SaveAs("error_not_drawn.gif");

the marker size on the left is 1.4, on the right 1.5, where the error bar is not drawn anymore for the leftmost marker (although it should be still visible with this marker style). Is there a way to force drawing the error bars always?

Best regards and thanks,

Klaus


ROOT Version: 6.06/02
Platform: Not Provided
Compiler: Not Provided


When the marker is larger than the error bar le error bar is not drawn as it is hidden by the marker. It makes sense seems to me.

I agree that the idea makes sense, however, as you can see in the plot, the error bar actually wouldn’t be completely hidden by the marker, and it looks like the point doesn’t have any (measurable) error which is not true. So I consider this as a bug…

You are talking about the horizontal error bar ?

Yes, now I get your argument.

Indeed I agree that the error without the end ticks would be hidden by the marker, but with the end ticks it should be visible.

so you would like to draw the horizontal bar in all cases ?

Let’s say, it would be nice to have a draw option in TGraphPainter which forces the errors (with end tick markers) to be drawn.

My workaround for now is to create two TGraphs, one with marker style 1, and the second with the real markers and draw them on top of each other. This is somewhat cumbersome.

can you post the macro ?

	TCanvas c1("c1","c1",800,400);
	c1.Divide(2,1);
	
	double x[3] = {1,2,3}, dx[3] = {0,0,0};
	double y[3] = {1,2,3}, dy[3] ={0.05,0.1,0.2}; 
	gStyle->SetEndErrorSize(4);
	
	TGraphErrors g1(3,x,y,dx,dy);
	TGraphErrors g2(3,x,y,dx,dy);
	TGraphErrors g2copy(3,x,y,dx,dy);
	
	c1.cd(1);
	g1.SetMarkerStyle(33);
	g1.SetLineWidth(2);
	g1.SetMarkerSize(1.4);
	g1.Draw("AP");
	
	c1.cd(2);
	g2.SetMarkerStyle(1);
	g2.SetLineWidth(2);
	g2.Draw("AP");
	
	g2copy.SetMarkerStyle(33);
	g2copy.SetLineWidth(2);
	g2copy.SetMarkerSize(1.8);
	g2copy.Draw("P same");
	
	c1.SaveAs("error_not_drawn.gif");

gives the following result:

The logic in the code is the following:
When drawing the Y top error bar if the bottom of the error bar is higher than the top of the error bar then the error bar is not drawn. That’s logic …

This case can occur because the bottom of the error bar is computed according to the symbol size. The error bar includes the bar itself and the horizontal terminators.

If I do what you suggest (drawing always the terminators) you may end up with some plot like the following one:

35

which is not really nice… So I guess the workaround you are using is the right way to proceed .

In any case I think it is also good to point out the fact the marker is too large compared to the real extend of the error bars. Because in a way you are extending artificially the real value of the errors which is a bit misleading …

Yes, the sketch you made is exactly what happens, i.e. the end bar markers cross the main marker. Your last statement about the marker being larger than the errors doesn’t worry me at all, if only error bars without end markers are drawn.

The problem when skipping to draw the error bars including end markers in case the main marker hides the vertical error itself is, that visually the entry looks like there isn’t any error present. I think the visual impression is misleading, because it looks like being unintended, since one expects to see these horizontal lines at every entry. It actually took me quite some time to realize, that this was not a bug in my macro when setting the errors but a feature of TGraphPainter.

As I said, it’s fine that by default the error bars are skipped in such cases, but as user I’d like to have an option to suppress that supression of error bar drawing.

I think the choice of “not drawing it” was to make clear that the marker is too big and hides the error bars. And it seems to work as it attracted your attention. If somebody wants to draw the end ticks anyway it should be clear that it is done on purpose despite the fact the marker is bigger than the errors. And in that case it worse the effort using the work around you found or make the marker a bit smaller.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.