
{
 static s ;
 static oxp[50], oyp[50] ;
 static double D1, fBudEp ;

		D1 = hi_y - lo_y ;
//---------------------------------------------------------
		 
		if (PlotData)  // Plot the raw lambda data
		{
			PlotRawLambdaSeries() ;
		}

/***
		 void PlotRawLambdaSeries( void )
 ***/

//--------------------------------------------------------------

		if (mPlotData)  // plot moving mean lambda data
		{
			PlotMeanLambdaSeries() ;
		}

/***
		void PlotMeanLambdaSeries( void )
 ***/

// *******************************************************************
//			Synthesese
// *******************************************************************
//------------------------------------------------------------------
if (PlotSynth)  // plot synthesis on raw data
		{
			PlotSynthRawLambdaSeries() ;
		}

/****
	void PlotSynthRawLambdaSeries( void )
 ****/

//-----------------------------------------------------------------------------

if (PlotFSynth)  // plot forced (const. amp.) synthesis on raw lambda data
		{
			PlotForcedSynthRawLambdaSeries();
		}
/***
	void PlotForcedSynthRawLambdaSeries(void)
 ***/


//--------------------------------------------------------------------------

if (mPlotSynth) // plot synthesis on moving-mean lambda data
		{
			PlotSynthMeanLambdaSeries();
		}

/***
	void PlotSynthMeanLambdaSeries( void )
 ***/

//-----------------------------------------------------------------------------------------
if (mPlotFSynth) // plot forced (const. amp.) synthesis on moving-mean data
		{
			PlotForcedSynthMeanLambdaSeries() ;
 		}              
/***
	void PlotForcedSynthMeanLambdaSeries( void )
 ***/



//-----------------------------------------------------------------------------------------
if (LPlotSynTune)  // tuned synthesis of raw lambdas
		{
			PlotTunedSynthRawLambdaSeries();
		}

/****
		void PlotTunedSynthRawLambdaSeries( void )
 ****/
//-----------------------------------------------------------------------------------------
if (mLPlotSynTune) // tuned synthesis of moving mean lambdas
		{
			PlotTunedSynthMeanLambdaSeries();
		}

/****
		void PlotTunedSynthMeanLambdaSeries( void )
 ****/


// *******************************************************************
//		Peaks and Dips
// *******************************************************************

// Show dips on synthesised raw lambdas

/*****

void PlotSynthRawDips( void )
{
  			static i, Y, xp, yp ;
			double sh, g, D ;
			HBITMAP hPatch ;
			HDC hdc ;

				hdc = GetDC(hWndArch) ;
				D = HiGH - LoW ;

			for (i = 0 ; i <= pSamp->nDips ; i++)
			{
				xp = ep2xp(g = pSamp->DipEps[i]) ;

				if (xp >= xlmar && xp <= (xlmar + chartwid))
				{
				yp = rcArc.bottom - 
						((int)((double)charthyt * (pSamp->DipVal[i] - LoW) / D)  +  ylmar) ;

				DrawIcon(hdc, xp - 15, yp - 31, icDipRaw) ;	// draw the icon

				SetRect(&rcRawDip[i], xp - 5, yp - 5, xp + 5, yp + 5) ; // rectangle for mousing

				if (ShowShifts)	// vertically
					{
						oPen = SelectObject(hdc, redPen) ;
						  sh = pSamp->rdpShift[i] ;
						   Y = rcArc.bottom - ((int)((double)charthyt * (1.0 - fabs(sh)/14.0)) + ylmar) ;

						Ellipse(hdc, xp - 5, Y - 5, xp + 5, Y + 5 ) ;

						DrawCross(hWndArch, 0, xp, Y, 6, redPen) ;
						SelectObject(hdc, oPen) ;

						if (toLink)
						{
							oPen = SelectObject(hdc, cltredPen) ;
							MoveToEx(hdc,xp, yp, NULL) ;
							LineTo(hdc, xp, Y) ;
							SelectObject(hdc, oPen) ;

						} // End if (toLink)
					} // End if (ShowShifts)
				} // End if (xp >= ...
			} // End for (i = 0 ...

			ReleaseDC(hWndArch,hdc) ;

} // End PlotSynthRawDips()

***/

if ((PlotRawDips) && _is.RawDipsExist)
		{
			int Y ; double s ;
			double g ;
			for (i = 0 ; i <= pSamp->nDips ; i++)
			{
				xp = ep2xp(g = pSamp->DipEps[i]) ;

				if (xp >= xlmar && xp <= (xlmar + wd))
				{
				yp = rcArc.bottom - 
						((int)((double)ht * (pSamp->DipVal[i] - lo_y) / D1)  +  ylmar) ;
				DrawIcon(hdc, xp - 15, yp - 31, icDipRaw) ;
				SetRect(&rcRawDip[i], xp - 5, yp - 5, xp + 5, yp + 5) ;
				if (ShowShifts)
					{
						oPen = SelectObject(hdc, redPen) ;
						s = pSamp->rdpShift[i] ;
						Y = rcArc.bottom - ((int)((double)ht * (1.0 - fabs(s)/14.0)) + ylmar) ;
						Ellipse(hdc, xp - 5, Y - 5, xp + 5, Y + 5 ) ;
						DrawCross(hWndArch, 0, xp, Y, 6, redPen) ;
						SelectObject(hdc, oPen) ;
						if (toLink)
						{
							oPen = SelectObject(hdc, ltredPen) ;
							MoveToEx(hdc,xp, yp, NULL) ;
							LineTo(hdc, xp, Y) ;
							SelectObject(hdc, oPen) ;
						}
					}
				}
			}
		}

//****************************************************
// Show dips on synthesised running mean lambdas

if ((PlotMeanDips) && _is.MeanDipsExist)
		{
			int Y ; double s ;
			double g ;
			for (i = 0 ; i <= pSamp->nmDips ; i++)
			{
				xp = ep2xp(g = pSamp->mDipEps[i]) ;

				if (xp >= xlmar && xp <= (xlmar + wd))
				{
				yp = rcArc.bottom -
						((int)((double)ht * (pSamp->mDipVal[i] - lo_y) / D1)  +  ylmar) ;
				DrawIcon(hdc, xp - 15, yp - 31, icDipMean) ;
				SetRect(&rcMeanDip[i], xp - 5, yp - 5, xp + 5, yp + 5) ;
				if (ShowShifts)
					{
						oPen = SelectObject(hdc, bluePen) ;
						s = pSamp->mdpShift[i] ;
						Y = rcArc.bottom - ((int)((double)ht * (1.0 - fabs(s)/14.0)) + ylmar) ;
						Ellipse(hdc, xp - 5, Y - 5, xp + 5, Y + 5 ) ;
						DrawCross(hWndArch, 0, xp, Y, 6, bluePen) ;
						SelectObject(hdc, oPen) ;
						if (toLink)
						{
							oPen = SelectObject(hdc, ltbluePen) ;
							MoveToEx(hdc,xp, yp, NULL) ;
							LineTo(hdc, xp, Y) ;
							SelectObject(hdc, oPen) ;
						}				
					}

				}				
			}
		}

//****************************************************
// Show dips on tuned synthesis of raw lambdas

if ((PlotRawTunedDips) && _is.RawTunedDipsExist)
		{
			int Y ; double s ;
			double g ;
			for (i = 0 ; i <= pSamp->ntDips ; i++)
			{
				xp = ep2xp(g = pSamp->tDipEps[i]) ;

				if (xp >= xlmar && xp <= (xlmar + wd))
				{
				yp = rcArc.bottom - 
						((int)((double)ht * (pSamp->tDipVal[i] - lo_y) / D1)  +  ylmar) ;
				DrawIcon(hdc, xp - 15, yp - 31, ictDipRaw) ;
				SetRect(&rctunedRawDip[i], xp - 5, yp - 5, xp + 5, yp + 5) ;
				if (ShowShifts)
					{
						oPen = SelectObject(hdc, redPen) ;
						s = pSamp->trdpShift[i] ;
						Y = rcArc.bottom - ((int)((double)ht * (1.0 - fabs(s)/14.0)) + ylmar) ;
						Ellipse(hdc, xp - 5, Y - 5, xp + 5, Y + 5 ) ;
						DrawCross(hWndArch, 0, xp, Y, 6, redPen) ;
						SelectObject(hdc, oPen) ;
						if (toLink)
						{
							oPen = SelectObject(hdc, ltredPen) ;
							MoveToEx(hdc,xp, yp, NULL) ;
							LineTo(hdc, xp, Y) ;
							SelectObject(hdc, oPen) ;
						}
					}				
				}
			}
		}

//****************************************************
// Show dips on tuned synthesis of mean lambdas

if ((PlotMeanTunedDips) && _is.MeanTunedDipsExist)
		{
			int Y ; double s ;
			for (i = 0 ; i <= pSamp->nmtDips ; i++)
			{
				xp = ep2xp(pSamp->tmDipEps[i]) ;

				if (xp >= xlmar && xp <= (xlmar + wd))
				{
				yp = rcArc.bottom - 
						((int)((double)ht * (pSamp->tmDipVal[i] - lo_y) / D1)  +  ylmar) ;
				DrawIcon(hdc, xp - 15, yp - 31, ictDipMean) ;
				SetRect(&rctunedMeanDip[i], xp - 5, yp - 5, xp + 5, yp + 5) ;

				if (ShowShifts)
					{
						oPen = SelectObject(hdc, bluePen) ;
						s = pSamp->tmdpShift[i] ;
						Y = rcArc.bottom - ((int)((double)ht * (1.0 - fabs(s)/14.0)) + ylmar) ;
						Ellipse(hdc, xp - 5, Y - 5, xp + 5, Y + 5 ) ;
						DrawCross(hWndArch, 0, xp, Y, 6, bluePen) ;
						SelectObject(hdc, oPen) ;
						if (toLink)
						{
							oPen = SelectObject(hdc, ltbluePen) ;
							MoveToEx(hdc,xp, yp, NULL) ;
							LineTo(hdc, xp, Y) ;
							SelectObject(hdc, oPen) ;
						}
					}				
				}				
			}
		}

//****************************************************
// Show peaks on synthesised raw lambdas

if ((PlotRawPeaks) && _is.RawPeaksExist)
		{
			for (i = 0 ; i <= pSamp->nPeaks ; i++)
			{
				xp = ep2xp(pSamp->PeakEps[i]) ;

				if (xp >= xlmar && xp <= (xlmar + wd))
				{
				yp = rcArc.bottom - 
						((int)((double)ht * (pSamp->PeakVal[i] - lo_y) / D1)  +  ylmar) ;
				DrawIcon(hdc, xp - 15, yp, icPeakRaw) ;
				SetRect(&rcRawPeak[i], xp - 5, yp - 5, xp + 5, yp + 5) ;
				}
			}
		}

//****************************************************
// Show peaks on synthesised running mean lambdas

if ((PlotMeanPeaks) && _is.MeanPeaksExist)
		{
			for (i = 0 ; i <= pSamp->nmPeaks ; i++)
			{
				xp = ep2xp(pSamp->mPeakEps[i]) ;

				if (xp >= xlmar && xp <= (xlmar + wd))
				{
				yp = rcArc.bottom -
						((int)((double)ht * (pSamp->mPeakVal[i] - lo_y) / D1)  +  ylmar) ;
				DrawIcon(hdc, xp - 15, yp, icPeakMean) ;
				SetRect(&rcMeanPeak[i], xp - 5, yp - 5, xp + 5, yp + 5) ;
				}
			}
		}

//****************************************************
// Show peaks on tuned synthesis of raw lambdas

if ((PlotRawTunedPeaks) && _is.RawTunedPeaksExist)
		{
			for (i = 0 ; i <= pSamp->ntPeaks ; i++)
			{
				xp = ep2xp(pSamp->tPeakEps[i]) ;

				if (xp >= xlmar && xp <= (xlmar + wd))
				{
				yp = rcArc.bottom - 
						((int)((double)ht * (pSamp->tPeakVal[i] - lo_y) / D1)  +  ylmar) ;
				DrawIcon(hdc, xp - 15, yp, ictPeakRaw) ;
				SetRect(&rctunedRawPeak[i], xp - 5, yp - 5, xp + 5, yp + 5) ;
				}
			}
		}


//****************************************************
// Show peaks on tuned synthesis of mean lambdas

if ((PlotMeanTunedPeaks) && _is.MeanTunedPeaksExist)
		{
			for (i = 0 ; i <= pSamp->nmtPeaks ; i++)
			{
				xp = ep2xp(pSamp->tmPeakEps[i]) ;

				if (xp >= xlmar && xp <= (xlmar + wd))
				{
				yp = rcArc.bottom - 
						((int)((double)ht * (pSamp->tmPeakVal[i] - lo_y) / D1)  +  ylmar) ;
				DrawIcon(hdc, xp - 15, yp, ictPeakMean) ;
				SetRect(&rctunedMeanPeak[i], xp - 5, yp - 5, xp + 5, yp + 5) ;
				}
			}
		}


//****************************************************
if (PlotAlData && _is.AlDataExist) // plot alignment data (this is the cos^2 graph)
		{
			double ival ;
			oPen = SelectObject( hdc, goldPen ) ;
			ival = AstGP / (double)(pa->items - 1) ;
		// graph of alignment data
			for ( i = 0 ; i < pa->items ; i++)
			{
				xp = ep2xp(i * ival + AstEp1) ;
				yp = rcArc.bottom -
					((int)((double)ht * pa->data[i] / 4.0) + ylmar) ;
				if ( i == 0 )
					MoveToEx( hdc, xp, yp, NULL ) ;
				else
					  LineTo( hdc, xp, yp ) ;
			}
			SelectObject(hdc, oPen) ;
		}

//****************************************************
if (PlotAlModData && _is.AlDataExist) // plot modified alignment data (this is the modified cos^2 graph)
		{
			double ival ;
			oPen = SelectObject( hdc, orangePen ) ;
			ival = AstGP / (double)(pa->items - 1) ;
		// graph of alignment data
			for ( i = 0 ; i < pa->items ; i++)
			{
				xp = ep2xp(i * ival + AstEp1) ;
				yp = rcArc.bottom -
					((int)((double)ht * pa->moddata[i] / 4.0) + ylmar) ;
				if ( i == 0 )
					MoveToEx( hdc, xp, yp, NULL ) ;
				else
					  LineTo( hdc, xp, yp ) ;
			}
			SelectObject(hdc, oPen) ;
		}

//****************************************************
if (PlotCRate && _is.AlDataExist) // angular "closure" rate
		{								 // between moon and body
			// This is just the difference between apparent
			// angular velocities of Moon and body.  It is
			// the rate of change of the angle between Moon
			// and body, in radians per day.

			// It is the "envelope" of dA/dt, indicating
			// that the time rate-of-change of Alignment
			// is amplitude-modulated by the angular velocity
			// difference (AVD, or closure rate).  This accounts
			// for the pair of spectral peaks, one on each side
			// of the dominant: they are "sidebands at one
			// remove".

			// First, angular velocity of moon, included for comparison.

			double ival ;
			ival = AstGP / (double)(pa->items - 1) ;

			oPen = SelectObject(hdc, goldPen) ;

			for ( i = 0 ; i < pa->items ; i++)
			{
			  xp = ep2xp(i * ival + AstEp1) ;
			  yp = rcArc.bottom -
				  ((int)((double)ht * pa->avlun[i] / pi) + ylmar) ;

				if ( i == 0 )
					MoveToEx( hdc, xp, yp, NULL ) ;
				else
					  LineTo( hdc, xp, yp ) ;
			}
			SelectObject(hdc, oPen) ;

			oPen = SelectObject( hdc, blackPen ) ;

			// The AVD (and upper envelope bound).

			for ( i = 0 ; i < pa->items ; i++)
			{
			 xp = ep2xp(i * ival + AstEp1) ;
			 yp = rcArc.bottom -
				  ((int)((double)ht * pa->angclr[i] / pi) + ylmar) ;

				if ( i == 0 )
					MoveToEx( hdc, xp, yp, NULL ) ;
				else
					  LineTo( hdc, xp, yp ) ;
			}

			// Lower envelope bound, to show only when dA/dt is also showing.

			if (PlotCsqRate)
			for ( i = 0 ; i < pa->items ; i++)
			{
			 xp = ep2xp(i * ival + AstEp1) ;
			 yp = rcArc.bottom -
				  ((int)((double)ht * -pa->angclr[i] / pi) + ylmar ) ;

				if ( i == 0 )
					MoveToEx( hdc, xp, yp, NULL ) ;
				else
					  LineTo( hdc, xp, yp ) ;
			}
			SelectObject(hdc, oPen) ;
		} // if (PlotCRate..


//****************************************************
if (PlotCsqRate && _is.AlDataExist)
		{	
			/**********************************
			  The following is the time rate-of-change
			  of the cos^2 alignment function:

			         A = pow(cos(lm - lp), 2.0)

			  => dA/dt = -2.0 * w * sin(lm - lp) * cos(lm - lp)
			           = -w * {sin[(lm-lp) + (lm-lp)] + sin(0)}
					   =  w * sin(2.0 * (lm - lp))

              where lm is the moon's longitude,
			        lp is the body's longitude,
				and  w is the above "closure" rate.

			 **********************************/
			double ival ;
			oPen = SelectObject( hdc, dkgreenPen ) ;
			ival = AstGP / (double)(pa->items - 1) ;
			for ( i = 0 ; i < pa->items ; i++)
			{
				xp = ep2xp(i * ival + AstEp1) ;
				yp = rcArc.bottom -
					((int)((double)ht * pa->dAbydt[i] / pi) + ylmar) ;

				if ( i == 0 )
					MoveToEx( hdc, xp, yp, NULL ) ;
				else
					  LineTo( hdc, xp, yp ) ;
			}
			SelectObject(hdc, oPen) ;
		} // if (PlotCsqRate ....

//****************************************************
		 if (PlotObsShift) // Observed phase shift markers.
		 {
			    int i ;
			 double k, tosh ;
			   char str[10] ;
		   COLORREF col ;
				int mod ;

			if (Plot7daygrat)
			{
			 oPen = SelectObject(hdc, blackPen) ;
			 for ( k = 0.0 ; k < 14.0 ; k++) // day ticks on left border
			 {
				 yp = rcArc.bottom -
					 (int)((double)ht * k / 14.0 + (double)ylmar) ;

				 xp = D.left + 5 ;
				 MoveToEx(hdc, xp, yp, NULL) ;

				 xp = D.left ;
				   LineTo(hdc, xp, yp) ;
			 }

				sprintf(str,"-35") ;
 				GetTextExtentPoint32(hdc, str, strlen(str), &sz) ;

			 for ( k = 0.0 ; k < 14.0 ; k++) // seven-day grid
			 {
				 yp = rcArc.bottom -
					 (int)((double)ht * k / 14.0 + (double)ylmar) ;

				 xp = D.left + sz.cx ;
				 MoveToEx(hdc, xp, yp, NULL) ;

				 xp = D.right ;
				   LineTo(hdc, xp, yp) ;
			 }
			 SelectObject(hdc, oPen) ;


		// notation for phase shift
			 
				col = GetBkColor(hdc) ;
				mod = GetBkMode(hdc) ;
				      SetBkMode(hdc, TRANSPARENT) ;

				for ( i = 0 ; i <= 14 ; i++) 
				{
				sprintf(str,"%2.2d", -(14 - i)) ;
				 xp = xlmar - 15 ;
				 yp = rcArc.bottom - (ht * i/14 + ylmar + sz.cy / 2) ;
				    SetTextColor(hdc, RGB(255, 0, 0)) ;
				         TextOut(hdc, xp, yp, str, strlen(str)) ;
				}
			}

			 for ( i = 0 ; i < nphases ; i++ ) // the markers
			 {
				 // show markers available for the currently displayed
				 // grand period only. ('tosh' = time of shift)
				 if ((tosh = ph.epPhase[i]) >= AstEp1  && tosh <= AstEp2)
				 {
					 double v ;
					 xp = ep2xp(tosh) ;		// per epoch on chart

					//v = ph.Advance[i]/35.0 + 1.0 ; // why the 1.0?

					  v = ph.Advance[i] ; // advance can go from 0 to -35 and is calculated as negative

					// keep the advance in range 0 to +14 days
					  while (v <  0.0) v += 14.0 ;
					  while (v > 14.0) v -= 14.0 ;
//					  while (v <      0.0) v += Semi_lun ;
//					  while (v > Semi_lun) v -= Semi_lun ;

					 yp = rcArc.bottom - (int)((double)ht * v / 14.0 + (double)ylmar) ;
//					 yp = rcArc.bottom - (int)((double)ht * v / Semi_lun + (double)ylmar) ;

					 DrawIcon(hdc, xp - 5, yp - 5, icPhase) ;
				 }
			 }
				      SetBkColor(hdc, col) ;
					  SetBkMode(hdc, mod) ;
		 }


//****************************************************
	if (PlotComp)  // plot Fourier mIAP component
		 {
		  oPen = SelectObject( hdc, redPen ) ;

		   coe = twopi * st.pord / (double)(bud-1) ;
		   Am = pf->amp[stash] ;
		   Ph = pf->phase[stash] ;
		   Dm = pf->DataMean ;

		  for ( u = 0.0 ; u <= (double)(bud - 1) ; u += 0.25 )
		  {
			  th = coe * u ;
			  ys = Am * cos(th - Ph) + Dm ;
			  xp = (int)((double)wd * u /(double)big) + xlmar ;
		      yp = rcArc.bottom -
			       (int)((double)ht * (ys - lo_y) / D1 + 
				   (double)ylmar) ;

			if (u == 0.0)
				MoveToEx(hdc, xp, yp, NULL) ;
			else
				LineTo(hdc, xp, yp) ;
		  }
		
//**************
	if (PlotShifts)  
		  {
			  if (IsZoomed(hWnd) == TRUE) // larger font in full window
			  oFnt = SelectObject(hdc, hfnt) ;
			  else
			  oFnt = SelectObject(hdc, hfnt1) ;
			  SetBkColor(hdc, RGB(255, 255, 255)) ;

		    for ( 
				i = 0, on_plot = 0 ;
	  (st.rx_t[i] =	(double)wd * ((double)(2*(i-1) + 1)*pi + Ph) / (twopi * st.pord)) <= wd ;
	 st.rt2min[i] = align->period * st.rx_t[i++] / (double)wd  
				)
				  {
					  xp = (int)st.rx_t[i] + xlmar ;
					  if (xp >= xlmar) // we are on-plot
					  {
					  if (!on_plot)	 // note the 1st on-plot index
					     {			 // and what to subtract from what!
						   on_plot = 1 ;
					        index1 = i ;
						// initially assume	to subtract
						// first min. from first align., and so on,	
						   k_index = 1 ;
						// but if the first alignment _precedes_
						// the first minimum, then subtract first
						// minimum from _second_ alignment, and so on.
						  if (Date_Time[UsePlanet][1]->daycount < st.rt2min[index1])
						  k_index = 2 ;
					     }
					  ys = Dm + 0.01 ;
		              yp = rcArc.bottom -
			               (int)((double)ht * (ys - lo_y) / D1 + (double)ylmar) ;
					  MoveToEx(hdc, xp, yp, NULL) ;
					  ys = Dm - 0.2 ;
		              yp = rcArc.bottom -
			               (int)((double)ht * (ys - lo_y) / D1 + (double)ylmar) ;
					  LineTo(hdc, xp, yp) ;
					  }
				  }

	        for (
				  k = k_index, n = 0, rSum = 0.0, j = index1 ;
			      k <= align->found ;
				  j++,
				  k++
				)
			{
			// The minima precede the alignments, so should
			// be negative.
			st.rdt[k] = st.rt2min[j] - Date_Time[UsePlanet][k]->daycount;
			    rSum += st.rdt[k] ;
				n++ ;
			xp = (int)st.rx_t[j] + xlmar ;
			if ( xp >= xlmar)
			  {
			  ys = Dm - 0.2 ;
		      yp = rcArc.bottom -
			     (int)((double)ht * (ys - lo_y) / D1 + (double)ylmar) ;
			  sprintf(buff, "%3.1f", st.rdt[k]) ;
			  TextOut(hdc, xp, yp, buff, strlen(buff)) ;
			  } // if (xp..
		  } // for (k..
			st.rshift = rSum /(double)n ;
			SelectObject(hdc, oFnt) ;

			oFnt = SelectObject(hdc, hfnt) ;
			SetTextColor(hdc, RGB( 255,   0,   0)) ;
			  SetBkColor(hdc, RGB( 192, 192, 192)) ;

			sprintf(buffer,"Raw Minima Shift: %3.1f days", st.rshift) ;

			TextOut(hdc, xlmar + 30, D.top - 40, buffer, strlen(buffer)) ;
			SelectObject(hdc, oFnt) ;

		} // if (PlotShifts)
	} // if (PlotComp)

//****************************************************
		 if (mPlotComp) 
		 {
		   coe = twopi * st.pord / (double)(bud-1) ;
		   Am = pf->mamp[mstash] ;
		   Ph = pf->mphase[mstash] ;
		   Dm = pf->mDataMean ;

		  oPen = SelectObject( hdc, bluePen ) ;

		  for ( u = 0.0 ; u <= (double)(bud - 1) ; u += 0.25 )
		  {
			  th = coe * u ;
			  ys = Am * cos(th - Ph) + Dm ;
			  xp = (int)((double)wd * u /(double)big) + xlmar ;
		      yp = rcArc.bottom -
			       (int)((double)ht * (ys - lo_y) / D1 + (double)ylmar) ;

			if (u == 0.0)
				MoveToEx(hdc, xp, yp, NULL) ;
			else
				LineTo(hdc, xp, yp) ;
		  }
			SelectObject(hdc, oPen) ;

//*****************
		  if (mPlotShifts) // plot timings of mov. mean comp. shifts
		  {
			  if (IsZoomed(hWnd) == TRUE)
			  SelectObject(hdc, hfnt) ;
			  else
			  SelectObject(hdc, hfnt1) ;
			  SetBkColor(hdc, RGB(255, 255, 255)) ;

		    for ( 
	           i  = 0, on_plot = 0 ;
	  (st.mx_t[i] = (double)wd * ((double)(2*(i-1)+1)*pi + Ph) / (twopi * st.pord)) <= wd ;
	 st.mt2min[i] = align->period * st.mx_t[i++] / (double)wd  
				)
				  {
					  xp = (int)st.mx_t[i] + xlmar ;
					  if (xp >= xlmar)
					  {
					  if (!on_plot)
					     {
						   on_plot = 1 ;
						    index1 = i ;
						   k_index = 1 ;
						  if (Date_Time[UsePlanet][1]->daycount < st.mt2min[index1])
							  k_index = 2 ;
					     }
					  ys = Dm + 0.2 ;
		              yp = rcArc.bottom -
			               (int)((double)ht * (ys - lo_y) / D1 + (double)ylmar) ;
					  MoveToEx(hdc, xp, yp, NULL) ;
					  ys = Dm - 0.01 ;
		              yp = rcArc.bottom -
			               (int)((double)ht * (ys - lo_y) / D1 + (double)ylmar) ;
					  LineTo(hdc, xp, yp) ;
					  }
				  }
	        for (
				  k = k_index, m = 0, mSum = 0.0, j = index1 ;
			      k <= align->found ;
				  j++,
				  k++
				)
			{
			// The minima precede the alignments, so should
			// be negative.
				st.mdt[k] = st.mt2min[j] - Date_Time[UsePlanet][k]->daycount;
				mSum += st.mdt[k] ;
				m++ ;
			xp = (int)st.mx_t[j] + xlmar ;
			if (xp >= xlmar)
			{
			ys = Dm + 0.2 ;
		    yp = rcArc.bottom -
			     (int)((double)ht * (ys - lo_y) / D1 + (double)ylmar) ;
			sprintf(buff, "%3.1f", st.mdt[k]) ;
			TextOut(hdc, xp, yp - 10, buff, strlen(buff)) ;
			} // if (xp..
		  } // for (k..
		  SelectObject(hdc, oFnt) ;

			st.mshift = mSum / (double)m ;
			oFnt = SelectObject(hdc, hfnt) ;
			SetTextColor(hdc, RGB(  0,   0, 255)) ;
			  SetBkColor(hdc, RGB(192, 192, 192)) ;

			sprintf(buffer,"Moving-Mean Minima Shift: %3.1f days", st.mshift) ;

			TextOut(hdc, (xlmar + xrmar)/2, D.top - 53, buffer, strlen(buffer)) ;
			SelectObject(hdc, oFnt) ;
		} // if (mPlotshifts)
	  } // if (mPlotComp)
}