Scale changed

Found a bug? Tell us about it here

Moderator: DPlotAdmin

Post Reply
plazmon
Posts: 6
Joined: Sat Apr 17, 2010 2:45 am

Scale changed

Post by plazmon »

I am trying to make some animation with DPlotJr on Fortran.
I have wrote next example:

Code: Select all

! 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.
User avatar
DPlotAdmin
Posts: 2312
Joined: Tue Jun 24, 2003 9:34 pm
Location: Vicksburg, Mississippi
Contact:

Post by DPlotAdmin »

Is your new data within the extents set with ManualScale? If not then the plot window will shift.

If that doesn't answer your question you are welcome to send me your source.
Visualize Your Data
support@dplot.com
User avatar
DPlotAdmin
Posts: 2312
Joined: Tue Jun 24, 2003 9:34 pm
Location: Vicksburg, Mississippi
Contact:

Post by DPlotAdmin »

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.

If instead of

dx = 4.0 / (NP-1)

you use

dx = 4.D0 / (NP-1)

then you should get the results you're expecting.
Visualize Your Data
support@dplot.com
plazmon
Posts: 6
Joined: Sat Apr 17, 2010 2:45 am

Post by plazmon »

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?

Anyway, thank you very much for your work!
User avatar
DPlotAdmin
Posts: 2312
Joined: Tue Jun 24, 2003 9:34 pm
Location: Vicksburg, Mississippi
Contact:

Post by DPlotAdmin »

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.
Visualize Your Data
support@dplot.com
plazmon
Posts: 6
Joined: Sat Apr 17, 2010 2:45 am

Post by plazmon »

If you would rather the plot be resized then don't use ManualScale before calling DPlot_AddData.
I want the plot window remain the same size and the same position.
Or instead of DPlot_AddData you could repeat the call to DPlot_Plot.
But DPlot_Plot create new Document, isn't it?
User avatar
DPlotAdmin
Posts: 2312
Joined: Tue Jun 24, 2003 9:34 pm
Location: Vicksburg, Mississippi
Contact:

Post by DPlotAdmin »

But DPlot_Plot create new Document, isn't it?
Yes, sorry. I wasn't thinking clearly.
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.
Visualize Your Data
support@dplot.com
User avatar
DPlotAdmin
Posts: 2312
Joined: Tue Jun 24, 2003 9:34 pm
Location: Vicksburg, Mississippi
Contact:

Post by DPlotAdmin »

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.
Visualize Your Data
support@dplot.com
Post Reply