@@ -233,6 +233,30 @@ def draw_parabola(self, gp, *, scale=None):
233233 a = self .am [n ] + xi * (self .ap [n ] - self .am [n ] + self .a6 [n ] * (1.0 - xi ))
234234 gp .ax .plot (x , a / scale , color = "C1" , lw = 2 )
235235
236+ def draw_average (self , gp , * , scale = None ):
237+ """Draw the horizontal line that represents the cell-average
238+ in each zone on the axes ax.
239+
240+ Parameters
241+ ----------
242+
243+ gp : GridPlot
244+ the grid plot object
245+ scale : float, optional
246+ normalization factor (default is maximum data value)
247+ """
248+
249+ ilo = max (gp .lo_index , self .grid .lo - 1 )
250+ ihi = min (gp .hi_index , self .grid .hi + 1 )
251+
252+ if scale is None :
253+ scale = np .max (self .a [ilo :ihi + 1 ])
254+
255+ for n in range (ilo , ihi + 1 ):
256+ gp .ax .hlines (y = self .a [n ]/ scale ,
257+ xmin = self .grid .xl [n ], xmax = self .grid .xr [n ],
258+ linestyle = '--' , lw = 1 , color = 'k' )
259+
236260 def mark_cubic (self , gp , * , scale = None ):
237261 """Mark the location of the initial interface states from the
238262 cubic interpolant on the axes ax.
@@ -244,7 +268,6 @@ def mark_cubic(self, gp, *, scale=None):
244268 the grid plot object
245269 scale : float, optional
246270 normalization factor (default is maximum data value)
247-
248271 """
249272
250273 ilo = max (gp .lo_index - 1 , self .grid .lo - 2 )
0 commit comments