Overlaying multiple plots

Q&A for C, C++, and/or C# developers using DPlot

Moderator: DPlotAdmin

Post Reply
cyberphox
Posts: 1
Joined: Sun Nov 08, 2009 4:32 am

Overlaying multiple plots

Post by cyberphox »

Hi all,

Before I carry on I have to say DPLOT is a fantastic tool!

I have recently found out about using dplotlib in c# and now am trying to add some real-time plotting capabilites to some automatic test software.

What I would like to do is plot an array of data (histogram of levels of an ADC output, 16 levels in total). This histogram is updated at a specific rate.

I use this every time I get new data on the ADC statistics: -

for (int i = 0; i < 16 i++)
{
x = i;
y1 = AdcBins;
dplot.DPlot_AddData8(DocNum, dplot.DATA_XYXY, 1, 1, ref x, ref y1);
}


Now the problem I encounter is the plot wraps back on itself, basically the last point joins back to the start point after each update.

There are two options I would like to try:

1. Is just show one plot at each update. In other words clear the last plot and show the new one but do it quickly without recreating the axis etc.

2. Also to plot each new plot over the other not clearing the previous one but not to have the wrapping of last point to first.

I hope this makes a bit of sense.

Kind regards,
M.
User avatar
DPlotAdmin
Posts: 2312
Joined: Tue Jun 24, 2003 9:34 pm
Location: Vicksburg, Mississippi
Contact:

Post by DPlotAdmin »

1.

dplot.DPlot_Command(DocNum,"[EditEraseData(1)]");
for (int i = 0; i < 16; i++)
{
x = i;
y1 = AdcBins;
dplot.DPlot_AddData8(DocNum, dplot.DATA_XYXY, 1, 1, ref x, ref y1);
}

EditEraseData doesn't delete the curve (and since that's the only curve, close the plot) and it doesn't redraw anything. It just resets the number of points in that curve to 0.

2. Two ways to do this. a) You can use separate curves for each group of 16 points. That would mean you'd need to keep track of how many curves were present, plus DPlot will balk if you need to do this more than 100 times.

b) Use the YCutoff command to set a range of values outside which points won't be drawn (or line segments drawn to/from). Then before your loop add a point whose Y value is outside that range. For example if you know your Y values will always range from 0 to 100:

dplot.DPlot_Command(DocNum,"[YCutoff(1,-100,200)]")
// You only need to use YCutoff once, but multiple calls won't hurt anything.
x = 0;
y = 201;
dplot.DPlot_AddData8(DocNum,dplot.DATA_XYXY,1,1,ref x,ref y1);
for (int i = 0; i < 16; i++)
{
x = i;
y1 = AdcBins;
dplot.DPlot_AddData8(DocNum, dplot.DATA_XYXY, 1, 1, ref x, ref y1);
}
Visualize Your Data
support@dplot.com
Post Reply