Skip to content

plot3d (surf)

Fabian Kindermann edited this page Apr 2, 2021 · 1 revision
subroutine plot3d(xin, yin, zin, color, linewidth, marker, markersize, noline, xlim, xticks, xlabel, 
ylim, yticks, ylabel, zlim, zticks, zlevel, zlabel, surf, surf_color, transparent, 
view, title, filename, filetype, output)

Description:

Our toolbox provides a set of routines that can be used for plotting graphs directly out of your Fortran program. Contrary to the plotting process for 2D-graphs, there is only one 3D plotting routine that allows to draw lines or surfaces in 3D in one step. It directly transfers your plotting data to the program GNUplot and starts this program, so that your graph will be displayed in a pop-up window. Note that this routine only allows to draw one line or surface at a time.

A surface in 3D is defined by a function that maps two points into a real value. As we can not work in function spaces on our computer, we have to define or surface at a discrete set of points. For the sake of simplicity, we restrict the discrete representation to rectilinear grids. Hence, a surface in 3D for us is represented by a discrete set of triplets . The surface-plotting version of the subroutine plot3d receives the sets , and as input and plots the respective surface in 3D-space.

Input arguments:

  • real*8 :: xin(:)
    This is a one-dimensional array of arbitrary length that contains the x-data for plotting.
  • real*8 :: yin(:)
    This is a one-dimensional array that contains the y-data for plotting.
  • real*8 :: zin(:, :)
    This is a two-dimensional array that contains the z-data for plotting. This array needs to have exactly the same length as the array xin in the first dimension and the same length as the array yin in the second dimension. Otherwise the subroutine throws an error message.

Optional arguments:

  • character(LEN=*) :: color
    This character argument allows to specify the color of the line that should be drawn. You can use both literal color names like 'blue' or 'red' or hexadecimal color codes like '#0000FF' for blue or '#FF0000' for red. The internet offers multiple sources that allow you to determine the hexadecimal codes of colors. For further information about colors in GNUplot, you can look at its documentation. If no color value is specified, then the plotting routine will give each line a different color according to a predetermined color scheme.
  • real*8 :: linewidth
    This variable specifies the width of the line that should be drawn. The default linewidth is equal to 2d0.
  • integer :: marker
    This variable specifies whether a marker should be placed on each x-y-data-pair and how this marker should look like. If this argument is not present when the subroutine plot is called, then no marker will be placed. If this argument is present in your subroutine call, then you can choose among 13 different markers. Just try out for yourself how they look like. Note that when the nolines option is set to .true., then markers are placed automatically on this plot.
  • real*8 :: markersize
    This variable specifies the size of the markers set on each x-y-data-pair. The default markersize is equal to 1d0.
  • logical :: noline
    If this logical variable is present and set to a value of .true., then there will be no connecting line between the x-y-data-pairs supplied in xi and yi. Instead, the subroutine will only draw markers for each x-y-data-pair.
  • real*8 :: xlim(2)
    This one-dimensional array of length two defines the plotting range on the x-axis of your plot. The first entry gives the lower bound of the range, the second the upper bound.
  • real*8 :: xticks
    This argument defines the distance between two successive tick values on the x-axis of the plot.
  • character(LEN=*) :: xlabel
    This character variable allows to attach a label to the x-axis informing about its content.
  • real*8 :: ylim(2)
    This one-dimensional array of length two defines the plotting range on the y-axis of your plot. The first entry gives the lower bound of the range, the second the upper bound.
  • real*8 :: yticks
    This argument defines the distance between two successive tick values on the y-axis of the plot.
  • character(LEN=*) :: ylabel
    This character variable allows to attach a label to the y-axis informing about its content.
  • real*8 :: zlim(2)
    This one-dimensional array of length two defines the plotting range on the z-axis of your plot. The first entry gives the lower bound of the range, the second the upper bound.
  • real*8 :: zticks
    This argument defines the distance between two successive tick values on the z-axis of the plot.
  • real*8 :: zlevel
    By means of this variable, you can alter the level at which the x-y-plane intersects with the z-axis. This input variable needs to have a value in the interval . If zlevel is equal to 0, then the x-y-plane will appear at the bottom of the z-axis range. If zlevel is equal to 1, then the x-y-plane will appear at the top of the z-axis range. For anything in between, the x-y-plane intersects with the z-axis somewhere in the middle.
  • character(LEN=*) :: zlabel
    This character variable allows to attach a label to the y-axis informing about its content.
  • logical :: surf
    If this logical variable has a value of .true., then the surface in between the point combinations will be colored. If no value is present for this variable, the subroutine will not color the surface.
  • integer :: surf_color
    With this variable, you can choose one of 6 different color palettes for the coloring of the surface. This will only be effective, if the optional input variable surf is present and equal to .true.. Just try out for yourself how the color palettes look like.
  • logical :: transparent
    If this logical variable has a value of .false., then the surface in between the point combinations will not appear transparent but be fully colored. If no value is present for this variable, the subroutine will use a value of .true..
  • real*8 :: view(2)
    This one-dimensional array of length two defines the viewing angle for the 3d plot. Both elements should range in the interval and define the rotation angles of the graph along the x-axis and the z-axis in degrees, respectively. If no value is present for this variable, GNUplot will try to search for a useful viewing angle. If you set both elements of view to zero, then the plot will appear with the screen horizontal axis being the x-axis and the vertical axis the y-axis. The z-axis is hence perpendicular to the screen.
  • character(LEN=*) :: title
    This character variable will be displayed as title above the plot.
  • character(LEN=*) :: filename
    This character variable allows to specify a filename under which the graph should be exported. If no input is present, then the graph is not exported at all.
  • character(LEN=*) :: filetype
    This character variable allows to specify a file type under which the graph should be exported. You can choose from either 'eps' or 'png'. Note that this option only takes effect, if the variable filename is specified. If no input is present, then the subroutine exports the graph in 'eps' format.
  • character(LEN=*) :: output
    This character variable allows you to export the actual raw plotting data in GNUplot format. This can be a useful option if you want to manually work on the appearance of your graph. output thereby defines the name of the output files created by this subroutine. Please see the documentation of GNUplot for further details.

References

Clone this wiki locally