add_3d_plot Subroutine

private subroutine add_3d_plot(me, x, y, z, label, linestyle, markersize, linewidth, istat)

Add a 3D x,y,z plot.

Note

Must initialize the class with mplot3d=.true.

Type Bound

pyplot

Arguments

Type IntentOptional Attributes Name
class(pyplot), intent(inout) :: me

pyplot handler

real(kind=wp), intent(in), dimension(:) :: x

x values

real(kind=wp), intent(in), dimension(:) :: y

y values

real(kind=wp), intent(in), dimension(:) :: z

z values

character(len=*), intent(in) :: label

plot label

character(len=*), intent(in) :: linestyle

style of the plot line

integer, intent(in), optional :: markersize

size of the plot markers

integer, intent(in), optional :: linewidth

width of the plot line

integer, intent(out), optional :: istat

status output (0 means no problems)


Calls

proc~~add_3d_plot~~CallsGraph proc~add_3d_plot pyplot%add_3d_plot proc~add_str pyplot%add_str proc~add_3d_plot->proc~add_str proc~optional_int_to_string optional_int_to_string proc~add_3d_plot->proc~optional_int_to_string proc~vec_to_string vec_to_string proc~add_3d_plot->proc~vec_to_string proc~integer_to_string integer_to_string proc~optional_int_to_string->proc~integer_to_string

Source Code

    subroutine add_3d_plot(me, x, y, z, label, linestyle, markersize, linewidth, istat)

    class(pyplot),          intent (inout)         :: me           !! pyplot handler
    real(wp), dimension(:), intent (in)            :: x            !! x values
    real(wp), dimension(:), intent (in)            :: y            !! y values
    real(wp), dimension(:), intent (in)            :: z            !! z values
    character(len=*),       intent (in)            :: label        !! plot label
    character(len=*),       intent (in)            :: linestyle    !! style of the plot line
    integer,                intent (in),  optional :: markersize   !! size of the plot markers
    integer,                intent (in),  optional :: linewidth    !! width of the plot line
    integer,                intent (out), optional :: istat        !! status output (0 means no problems)

    character(len=:), allocatable :: xstr         !! x values stringified
    character(len=:), allocatable :: ystr         !! y values stringified
    character(len=:), allocatable :: zstr         !! z values stringified
    character(len=max_int_len)    :: imark        !! actual markers size
    character(len=max_int_len)    :: iline        !! actual line width
    character(len=*), parameter   :: xname = 'x'  !! x variable name for script
    character(len=*), parameter   :: yname = 'y'  !! y variable name for script
    character(len=*), parameter   :: zname = 'z'  !! z variable name for script

    if (allocated(me%str)) then

        if (present(istat)) istat = 0

        !convert the arrays to strings:
        call vec_to_string(x, me%real_fmt, xstr, me%use_numpy)
        call vec_to_string(y, me%real_fmt, ystr, me%use_numpy)
        call vec_to_string(z, me%real_fmt, zstr, me%use_numpy)

        !get optional inputs (if not present, set default value):
        call optional_int_to_string(markersize, imark, '3')
        call optional_int_to_string(linewidth, iline, '3')

        !write the arrays:
        call me%add_str(trim(xname)//' = '//xstr)
        call me%add_str(trim(yname)//' = '//ystr)
        call me%add_str(trim(zname)//' = '//zstr)
        call me%add_str('')

        !write the plot statement:
        call me%add_str('ax.plot('//&
                        trim(xname)//','//&
                        trim(yname)//','//&
                        trim(zname)//','//&
                        trim(me%raw_str_token)//'"'//trim(linestyle)//'",'//&
                        'linewidth='//trim(adjustl(iline))//','//&
                        'markersize='//trim(adjustl(imark))//','//&
                        'label='//trim(me%raw_str_token)//'"'//trim(label)//'")')
        call me%add_str('')

    else
        if (present(istat)) istat = -1
        write(error_unit,'(A)') 'Error in add_3d_plot: pyplot class not properly initialized.'
    end if

    end subroutine add_3d_plot