Menu

#26 The Histogram width problem on build NPlot-0.9.8.5

open
nobody
None
5
2005-03-28
2005-03-28
No

Thanks for the great library ;-)
David

on build NPlot-0.9.8.5

I have an array of dates and values. see the attached
image.

The problem is that the width of all the columns are not
consistent. Sometimes the columns overlap.

here is my code:

for (int i=0; i<npt; ++i)
{
x[i] = ((DateTime)(DataSource.Table.Rows[i]
[TimeColumnName])).Ticks;
y[i] = (float)Convert.ToDouble((DataSource.Table.Rows[i]
[ValueColumnName]))+1.0f;
}
double xmin = x[0];
double xmax = x[npt-1];
float ymin = 1;
float ymax = 1000;

PointPlot pp = new PointPlot();
pp.OrdinateData = y;
pp.AbscissaData = x;
pp.Marker.DropLine = true;
pp.Marker = new Marker
(Marker.MarkerType.FilledCircle ,4, new Pen
(Color.Red));
plotSurface.Add( pp );

HistogramPlot sp = new HistogramPlot();
sp.OrdinateData = y;
sp.AbscissaData = x;
sp.Pen = Pens.DarkBlue;
sp.Filled = true;
sp.RectangleBrush = new
RectangleBrushes.HorizontalCenterFade(
Color.Lavender, Color.Gold );
sp.BaseWidth = 0.8f;
sp.Label = "Random Data";
plotSurface.Add( sp );

LogAxis loga = new LogAxis( plotSurface.YAxis1 );
loga.WorldMin = ymin;
loga.WorldMax = ymax;
loga.AxisColor = Color.Red;
loga.LabelColor = Color.Red;
loga.TickTextColor = Color.Red;
loga.LargeTickStep = 1.0f;
loga.Label = "Counts";
plotSurface.YAxis1 = loga;

DateTimeAxis lx = new DateTimeAxis
(plotSurface.XAxis1);
lx.WorldMin = xmin;
lx.WorldMax = xmax;
lx.Label = "Time";
lx.AutoScaleText = true;
lx.TickTextColor = Color.Green;
plotSurface.XAxis1 = lx;

Discussion

  • DavidDehghan

    DavidDehghan - 2005-03-28

    screen shot

     
  • Matt Howlett

    Matt Howlett - 2005-05-20

    Logged In: YES
    user_id=412511

    I suspect this is because the points are out of order along
    the x direction.

    I'll look into this, also might make histogram plot have
    option to have same width bars even if spacing different.

    Matt.

     

Log in to post a comment.

MongoDB Logo MongoDB