Make a band with two lines

_ROOT Version: 5.34/10

Hi, I want to make a band with two lines that I draw them with TGraph. How can I do it?
Thanks for your help in advance


here you can find the options which can help you drawing a TGraphErrors displaying a “band around the line”


Thanks for your answer, I don’t want to make a bound around a line. I have a few lines and I want to make a band by using these lines. Do you know how can I do it?


I think I do not get what you mean by band. You can draw all of them on the same canvas with a TMultiGraph: is this what you would like to achieve?



No, I want to make a band with all graph. I want to show my results by a band instead of a few lines. I mean I have to lines and I want to fill the area between two lines with a band.

Instead of 2 graphs, put all the points in one TGraph (so that each x has two y points, see my comment below) and then plot the graph with the fill option (“F”) together with “AL”; eg:

  TGraph *grshade = new TGraph(2*N);
  for (Int_t j=0; j<N; ++j) {

where N is the number of points of each original graph (same for both), x[j] are the x-axis values and ytop and ybottom are the y-axis values for each of the original graphs. In my example, both graphs (“top” and “bottom”) have the same x-axis values, but I don’t know if this may work for different values; also, note that the bottom graph is saved into the new graph from last to first point, so that the line that joins the points in the final graph (grshade) does not cross the plot, since it now joins the last two points -top and bottom- on the right end of the graph.
EDIT: make sure both graphs (ytop, ybottom) are ordered in increasing x-axis value before filling the new graph.

Thanks a lot for your help :blush:

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