Navigation:  Welcome to GRAPH-XT > Getting Started >

Getting Started with XYZ Surface Plots

 

Previous pageReturn to chapter overviewNext page
Show/Hide Hidden Text

lampe

Info: A very detailed example for XYZ surface plots can be found in the DPlot_example1.prg example program, see SUB DPlot_3d_demo.

 

The following chapter shows how to create a XYZ surface plot similar to this:

clip0038

 

hmtoggle_plus1Create a new 3D document

Doc_num=FNDplot_doc_new(3)      ! create new 3D document

 

hmtoggle_plus1Create the point pairs and store them into a 3D REAL array

Xstep=.15       ! x step value

Xmin=0         ! x start value

Xmax=10         ! x stop value

Ystep=.15       ! y step value

Ymin=0         ! y start value

Ymax=10         ! y stop value

Xpoints=(Xmax-Xmin)/Xstep+1

Ypoints=(Ymax-Ymin)/Ystep+1

!

ALLOCATE REAL Datxyz(1:Xpoints,1:Ypoints,1:3)   ! 3-dimensional array

Xbase=BASE(Datxyz,1)

Ybase=BASE(Datxyz,2)

!

Xi=Xbase

FOR X=Xmin TO Xmax STEP Xstep

   Yi=Ybase

  FOR Y=Ymin TO Ymax STEP Ystep

       Z=SIN(X)*COS(Y)

      !

       Datxyz(Xi,Yi,1)=X

       Datxyz(Xi,Yi,2)=Y

       Datxyz(Xi,Yi,3)=Z

      IF Yi<Ypoints THEN Yi=Yi+1

  NEXT Y

  IF Xi<Xpoints THEN Xi=Xi+1

NEXT X

 

hmtoggle_plus1Send the data points to DPlot

! now transfer all data points to new DPlot curve (curve 1)

Dummy=FNDplot_xyz_data(Doc_num,Datxyz(*),0,0,1,Z_$,1)

DEALLOCATE Datxyz(*)

 

hmtoggle_plus1Switch to 3D contour mode

Dummy=FNDplot_send_cmd("[Contour3D(1)]","")   ! 3D contour diagram

 

hmtoggle_plus1Some tweaking In order to make the 3D plot even nicer

Dummy=FNDplot_send_cmd("[ContourGrid(0)]")       ! no grid

Dummy=FNDplot_send_cmd("[ContourLighting(1,0)]") ! ligthing options = gouraud

Dummy=FNDplot_send_cmd("[ContourView(30,35)]")   ! contour view options

Dummy=FNDplot_send_cmd("[ContourColorScheme(2)]") ! custom colors for contour plot

Dummy=FNDplot_send_cmd("[ContourCustomColors(65535,32768)]") ! yellow to green

! Document title 1

Dummy=FNDplot_send_cmd("[Title1(""3D Contour Plot created by HTBasic"")]")

 

hmtoggle_plus1Show the 3D diagram on the HTBasic screen and close document

! show the diagram in a Basic Plus widget, 100% screen size

CALL Dplot_show(Doc_num,"",1,0,100,100,100,@Bitmap1)

Dummy=FNDplot_doc_close(Doc_num)     ! close the document

 

Info3

Please note:
Since the DPlot document is displayed in high colour mode we show it in a Basic Plus bitmap widget in order to display thousands of colours under HTBasic (HTBasic normally only supports up to 256 different colours). Please note that since we use a Basic Plus widget some restrictions apply:

A Basic Plus widget will be destroyed when your HTBasic program has been finished or you leave the SUB program context where you have created the Basic Plus widget
If you do a DUMP GRAPHICS only 256 colours will be dumped (this is a restriction of HTBasic !)
Kanji labels are not supported due to high colour mode
Mixing with traditional HTBasic graphic commands like LABEL, RECTANGLE etc. not possible