Navigation:  How do I ...? > Appearance >

How do I create a real-time plot?

 

Previous pageReturn to chapter overviewNext page
Show/Hide Hidden Text

lampe

Info: A very detailed example for real-time plots can be found in the DPlot_example2.prg example program, see SUB Dplot_realtime.

 

The following chapter shows how to create a simple real-time plot like this:

clip0042

 

hmtoggle_plus1Create a new document

Doc_num=FNDplot_doc_new(0)      ! create new document

 

hmtoggle_plus1Some tweaking

! legend text and style for curve

Dummy=FNDplot_send_cmd("[Legend(1,""x=sin(2*t), y=sin(5*t)  {0<t<2*PI}"")]")

!

Dummy=FNDplot_send_cmd("[NumberFormat(0,8)]")  ! x axis = fractions of PI

Dummy=FNDplot_send_cmd("[ManualScale(0,-1.2,6.28,1.2)]") ! manual scale of y axis

Dummy=FNDplot_send_cmd("[Color(1,0,255,255)]") ! curve 1 = cyan

Dummy=FNDplot_send_cmd("[Color(2,255,200,0)]") ! curve 2 = kind of yellow

 

hmtoggle_plus1Create the point pairs and update the screen

DIM Dat1(1:1,1:2)                   ! point pairs (x and y) for curve 1

DIM Dat2(1:1,1:2)                   ! point pairs (x and y) for curve 2

!

Xmin=0

Xmax=2*PI

Xpoints=200

Xstep=Xmax/Xpoints

!

Scr_update=4                         ! screen update every 4 data points only

Scr_count=1

!

RANDOMIZE

Xi=BASE(Datxy,1)

FOR X=Xmin TO Xmax-Xstep STEP Xstep

Dat1(1,1)=X                 ! x value curve 1

Dat1(1,2)=LGT(X+.00001)     ! y value curve 1

Dat2(2,1)=X                 ! x value curve 2

Dat2(2,2)=SIN(1.5*X)       ! y value curve 2

!

! transfer all data points to DPlot curve 1, line type 1

Dummy=FNDplot_xyz_data(Doc_num,Datxy(*),0,0,1,"",1)

!

! transfer all data points to DPlot curve 2, line type 1

Dummy=FNDplot_xyz_data(Doc_num,Datxy(*),0,0,2,"",1)

!

Scr_count=Scr_count+1

IF Scr_count/Scr_update=INT(Scr_count/Scr_update) THEN

CALL Dplot_show(Doc_num)   ! screen update

END IF

NEXT X

 

hmtoggle_plus1Show the diagram on the HTBasic screen again and close document

! show the diagram, 100% screen size

CALL Dplot_show(Doc_num)

Dummy=FNDplot_doc_close(Doc_num)     ! close the document

 

Info3

Please note: In order to get the fastest possible screen update interval we strongly recommend to disable the è antialiasing feature when creating real-time plots.