! Filling arrays x and y
DPlot.Version = DPLOT_DDE_VERSION
DPlot.hwnd = 0;
DPlot.DataFormat = DATA_XYXY
DPlot.MaxCurves = 1
DPlot.MaxPoints = NP
DPlot.NumCurves = 1
DPlot.Scale = SCALE_LINEARX_LINEARY
DPlot.NP(1) = NP
DPlot.LineType(1) = LINESTYLE_SOLID
DocNum = DPlot_Plot8(Loc(DPlot), x(1), y(1), '[DocMaximize()]' // &
'[ManualScale(0,-1.25,4,1.25)]' // Char(0))
DO j=1, 100
! Do new value of y
iRes = DPlot_Command(DocNum, '[EditEraseData(1)]' // Char(0))
iRes = DPlot_AddData8(DocNum, DATA_XYXY, NP, 1, x(1), y(1))
END DO
But when NP=1001 after the first step in the loop the scale of the plot has changed. Apparently this occur due to size of data thus then NP=101 or using Real(4) the scale of the plot remain unchanged.
Andrew,
There's a precision problem with how your X's are calculated. If you pause your program at any loop and take a look at the X extents you'll find that they aren't exactly 0 and 4. The last X being slightly greater than 4 causes the extents to shift.
Yes, it's my fault!
But still, I think, DPlot show strange behaviour.
1. Why it check for exact equivalence of float number? I think it was more naturally to consider two float is equivalent if they are in some epsilon vicinity.
2. Why instead of resizing of the plot window it shift it?
3. And why eventually it change ManualScal on AutoScale after I add data?
Why it check for exact equivalence of float number?
You're viewing this as if DPlot is finding something wrong with what you've done and correcting you. That isn't the case. There's no way for DPlot to know whether you're about to send more data with greater X values (which is what DPlot_AddData was originally designed for), so it shifts the scale, ready for more data.
Why instead of resizing of the plot window it shift it?
If you would rather the plot be resized then don't use ManualScale before calling DPlot_AddData. Or instead of DPlot_AddData you could repeat the call to DPlot_Plot.
I want the plot window remain the same size and the same position.
If you don't use ManualScale then the extents should not change (in your case). But in that case the extents might not be what you want them to be. I need to add another command that dictates how ManualScale works in conjunction with DPlot_AddData. I'll try to have that done for the next release.
Edit: Changed SetPanFraction command so that it will accept a 0 argument (default is 0.5). If 0, the plot won't scroll when X exceeds the right extent. This will be available in the next release.
The workaround to the problem you noticed is now in place in dplotlib.dll. You can either download and install DPlot Jr again, or get the DLL from the smaller download at http://www.dplot.com/lib/dplotlib.zip
Whichever you do, if you use a [SetPanFraction(0)] command then your plot will not scroll.
Of course the better solution for this particular problem is to be more precise with your extents, using a D suffix where appropriate. But there may be other cases where this new feature will come in handy.