You can plot 3D surface plots (in case of functions) or show data points in 3D using plot3D method. The plots are fully interactive and one can rotate and zoom-in particular regions.
First, let us create a canvas and prepare for plotting of data in 3D.
There are several methods associated with it: clear3d (clear the canvas from data) and expert3d(file), to export the plot to the vector format image, such as PDF, EPS, as well as PNG and JPG. You can also put title, label and change the minimum and maximum ranges for X-axis and Y-axis. You can pass the following options to this canvas:
Functions can be shown as surface plots in 3D. You will need to define symbolic variables x and y, and then construct symbolic function. The pass it to the method draw3d: Run this example to find how it works. It will show a pop-up canvas with a surface plot in 3D:
Alternatively, one can pass a string which specifies a function using “x” and “y” as variables. Run this example to see how it works:
This generates interactive surface plot in 3D. The ranges of X,Y,Z can be specified as option for the method plot3d.
Data may be graphed using the plot3d function as well. In this case you need to pass 3 vectors
Let as show a simple example of plotting sin(x) between 0 and 10 with a step 0.1
Note that it is convenient to set X,Y,Z ranges during the canvas creating step, in this case the axis labels will be nicely formatted (unlike the example above).
To clear the plot, use “clear3d” method. One can export the plot in PDF, EPS, PS, PNG, JPG image formats using the method export3d(file) method. For example, export3d(“image.eps”) will export the graph to EPS/PS format using high-quality vector graphics.
You can pass the following options to the “draw3d” method: