Help with plotting widget

I am having problems plotting using a Polygon widget. It displays an extra line (randomly) after the last point. Otherwise it works great.

It also fails to display circles (PtEllipses) on each data point for the plot. It only display the fist one

Here is my code

/////////////////////////////////////////////////////////////////////
int plotData(PtWidget_t *widget, double * data, int n){

/* Local Variables  */
int pixx,pixy;
float count=(float) n;	
int padding=400 ;			// Pixels away from edge 
double max=0;				// Initialization of max and min 
double  min=0;
int i;							// Counter I guess
PtWidget_t *plot; 			// Polygon widget (We use the fact it does not need to be closed)
PhPoint_t  points[n];		// Struct with n short values for plotting
PhPoint_t  R_origin;		
PtWidget_t * ppplot;			// Widget Pointer -> PlotPane
PtArg_t  argt[5];				// Arguement array for polygon
PhDim_t   EllipseSize = { 20,20};


// Get PlotPane size and add padding (90%)
ppplot=ApGetWidgetPtr(widget, ABN_PlotPane);

// PtGetResource( ppplot, Pt_ARG_HEIGHT , &tmp, 0 );
pixx=380; // atof(tmp) *padding;
// PtGetResource( ppplot, Pt_ARG_WIDTH , &tmp, 0 );
pixy=360; //atoi(tmp) *padding;

// Find max and min 
for (i=0; i<n;i++){
	max=max(data[i],max);
	min=min(data[i],min);
	sprintf(tmp, "%d; %#.1f\n", i, data[i]);
	strcat(msg, tmp);							 // Append raw to mesage string 
	}
PtSetArg(&argt[0], Pt_ARG_DIM, &EllipseSize, n ) ;		
PtSetArg(&argt[2], Pt_ARG_COLOR, Pg_MAGENTA, n ) ;		
// Translate coordinates
for ( i=1; i<=n ; i++){
	points[i].x=(i / count)*pixx;			// This should transform the data 
	points[i].y=abs(pixy-((data[i]/max)*pixy));
	PtSetArg(&argt[1], Pt_ARG_POS, &points[i], 1 ) ;		
	plot =PtCreateWidget( PtEllipse, ppplot ,1, argt ) ; // Doesnt work !!!!!
	PtRealizeWidget (plot);
}

// Display the messages and draw the polygon
PtSetResource(
ApGetWidgetPtr( widget, ABN_txtList ),
Pt_ARG_TEXT_STRING, msg , 0 );

R_origin.x=padding;			// Not Working ?
R_origin.y=padding;
PtSetArg(&argt[0], Pt_ARG_POINTS, points, n-1 ) ;
PtSetArg(&argt[1], Pt_ARG_ORIGIN, &R_origin, 0 ) ;
plot = PtCreateWidget( PtPolygon, ppplot ,1, argt ) ;	 
PtRealizeWidget (plot);

return( Pt_CONTINUE );

}