initialize Subroutine

private subroutine initialize(me, grid, xlabel, ylabel, zlabel, title, legend, use_numpy, figsize, font_size, axes_labelsize, xtick_labelsize, ytick_labelsize, ztick_labelsize, legend_fontsize, mplot3d, axis_equal, polar, real_fmt)

Arguments

Type IntentOptional AttributesName
class(pyplot), intent(inout) :: me
logical, intent(in), optional :: grid
character(len=*), intent(in), optional :: xlabel
character(len=*), intent(in), optional :: ylabel
character(len=*), intent(in), optional :: zlabel
character(len=*), intent(in), optional :: title
logical, intent(in), optional :: legend
logical, intent(in), optional :: use_numpy
integer, intent(in), optional dimension(2):: figsize
integer, intent(in), optional :: font_size
integer, intent(in), optional :: axes_labelsize
integer, intent(in), optional :: xtick_labelsize
integer, intent(in), optional :: ytick_labelsize
integer, intent(in), optional :: ztick_labelsize
integer, intent(in), optional :: legend_fontsize
logical, intent(in), optional :: mplot3d
logical, intent(in), optional :: axis_equal
logical, intent(in), optional :: polar
character(len=*), intent(in), optional :: real_fmt

Calls

proc~~initialize~~CallsGraph proc~initialize initialize proc~integer_to_string integer_to_string proc~initialize->proc~integer_to_string proc~optional_int_to_string optional_int_to_string proc~initialize->proc~optional_int_to_string proc~optional_int_to_string->proc~integer_to_string
Help

Source Code


Source Code

    subroutine initialize(me, grid, xlabel, ylabel, zlabel, title, legend, use_numpy, figsize, &
                          font_size, axes_labelsize, xtick_labelsize, ytick_labelsize, ztick_labelsize, &
                          legend_fontsize, mplot3d, axis_equal, polar, real_fmt)

    class(pyplot),         intent(inout)        :: me              !! pyplot handler
    logical,               intent(in), optional :: grid            !! activate grid drawing
    character(len=*),      intent(in), optional :: xlabel          !! label of x axis
    character(len=*),      intent(in), optional :: ylabel          !! label of y axis
    character(len=*),      intent(in), optional :: zlabel          !! label of z axis
    character(len=*),      intent(in), optional :: title           !! plot title
    logical,               intent(in), optional :: legend          !! plot legend
    logical,               intent(in), optional :: use_numpy       !! activate usage of numpy python module
    integer, dimension(2), intent(in), optional :: figsize         !! dimension of the figure
    integer,               intent(in), optional :: font_size       !! font size
    integer,               intent(in), optional :: axes_labelsize  !! size of axis labels
    integer,               intent(in), optional :: xtick_labelsize !! size of x axis tick lables
    integer,               intent(in), optional :: ytick_labelsize !! size of y axis tick lables
    integer,               intent(in), optional :: ztick_labelsize !! size of z axis tick lables
    integer,               intent(in), optional :: legend_fontsize !! size of legend font
    logical,               intent(in), optional :: mplot3d         !! set true for 3d plots (cannot use with polar)
    logical,               intent(in), optional :: axis_equal      !! set true for axis = 'equal'
    logical,               intent(in), optional :: polar           !! set true for polar plots (cannot use with mplot3d)
    character(len=*),      intent(in), optional :: real_fmt        !! format string for real numbers (examples: '(E30.16)' [default], '*')

    character(len=max_int_len)  :: width_str                    !! figure width dummy string
    character(len=max_int_len)  :: height_str                   !! figure height dummy string
    character(len=max_int_len)  :: font_size_str                !! font size dummy string
    character(len=max_int_len)  :: axes_labelsize_str           !! size of axis labels dummy string
    character(len=max_int_len)  :: xtick_labelsize_str          !! size of x axis tick labels dummy string
    character(len=max_int_len)  :: ytick_labelsize_str          !! size of x axis tick labels dummy string
    character(len=max_int_len)  :: ztick_labelsize_str          !! size of z axis tick labels dummy string
    character(len=max_int_len)  :: legend_fontsize_str          !! size of legend font dummy string

    character(len=*), parameter :: default_font_size_str = '10' !! the default font size for plots

    call me%destroy()

    if (present(legend)) then
        me%show_legend = legend
    else
        me%show_legend = .false.
    end if
    if (present(use_numpy)) then
        me%use_numpy = use_numpy
    else
        me%use_numpy = .true.
    end if
    if (present(figsize)) then
        call integer_to_string(figsize(1), width_str)
        call integer_to_string(figsize(2), height_str)
    end if
    if (present(mplot3d)) then
        me%mplot3d = mplot3d
    else
        me%mplot3d = .false.
    end if
    if (present(polar)) then
        me%polar = polar
    else
        me%polar = .false.
    end if
    if (present(axis_equal)) then
        me%axis_equal = axis_equal
    else
        me%axis_equal = .false.
    end if
    if (present(real_fmt)) then
        me%real_fmt = trim(adjustl(real_fmt))
    else
        me%real_fmt = real_fmt_default
    end if

    call optional_int_to_string(font_size, font_size_str, default_font_size_str)
    call optional_int_to_string(axes_labelsize, axes_labelsize_str, default_font_size_str)
    call optional_int_to_string(xtick_labelsize, xtick_labelsize_str, default_font_size_str)
    call optional_int_to_string(ytick_labelsize, ytick_labelsize_str, default_font_size_str)
    call optional_int_to_string(ztick_labelsize, ztick_labelsize_str, default_font_size_str)
    call optional_int_to_string(legend_fontsize, legend_fontsize_str, default_font_size_str)

    me%str = ''

    call me%add_str('#!/usr/bin/env python')
    call me%add_str('')

    call me%add_str('import matplotlib')
    call me%add_str('import matplotlib.pyplot as plt')
    if (me%mplot3d) call me%add_str('from mpl_toolkits.mplot3d import Axes3D')
    if (me%use_numpy) call me%add_str('import numpy as np')
    call me%add_str('')

    call me%add_str('matplotlib.rcParams["font.family"] = "Serif"')
    call me%add_str('matplotlib.rcParams["font.size"] = '//trim(font_size_str))
    call me%add_str('matplotlib.rcParams["axes.labelsize"] = '//trim(axes_labelsize_str))
    call me%add_str('matplotlib.rcParams["xtick.labelsize"] = '//trim(xtick_labelsize_str))
    call me%add_str('matplotlib.rcParams["ytick.labelsize"] = '//trim(ytick_labelsize_str))
    call me%add_str('matplotlib.rcParams["legend.fontsize"] = '//trim(legend_fontsize_str))

    call me%add_str('')

    if (present(figsize)) then  !if specifying the figure size
        call me%add_str('fig = plt.figure(figsize=('//trim(width_str)//','//trim(height_str)//'))')
    else
        call me%add_str('fig = plt.figure()')
    end if

    if (me%mplot3d) then
        call me%add_str('ax = fig.gca(projection=''3d'')')
    elseif (me%polar) then
        call me%add_str('ax = fig.gca(projection=''polar'')')
    else
        call me%add_str('ax = fig.gca()')
    end if

    if (present(grid)) then
        if (grid) call me%add_str('ax.grid()')
    end if

    if (present(xlabel)) call me%add_str('ax.set_xlabel("'//trim(xlabel)//'")')
    if (present(ylabel)) call me%add_str('ax.set_ylabel("'//trim(ylabel)//'")')
    if (present(zlabel)) call me%add_str('ax.set_zlabel("'//trim(zlabel)//'")')
    if (present(title))  call me%add_str('ax.set_title("' //trim(title) //'")')

    call me%add_str('')

    end subroutine initialize


add_3d_plot add_bar add_contour add_plot add_str bctoi_I1P bctoi_I2P bctoi_I4P bctoi_I8P bcton bctor_R16P bctor_R4P bctor_R8P bit_size bit_size bit_size_chr bit_size_R16P bit_size_R4P bit_size_R8P bstr bstr_I1P bstr_I2P bstr_I4P bstr_I8P bstr_R16P bstr_R4P bstr_R8P byte_size byte_size_chr byte_size_I1P byte_size_I2P byte_size_I4P byte_size_I8P byte_size_R16P byte_size_R4P byte_size_R8P check_endian compact_real_string compute compute compute compute compute compute compute compute compute compute create create create create create create create create create create_alpha_coefficients create_alpha_coefficients_js_constructor create_alpha_coefficients_m_constructor create_alpha_coefficients_z_constructor create_base_object create_interpolator_constructor create_interpolator_js_constructor create_optimal_weights create_optimal_weights_js_constructor create_polynomials create_polynomials_js_constructor create_smoothness_indicators create_smoothness_indicators_js_constructor ctoi_I1P ctoi_I2P ctoi_I4P ctoi_I8P cton ctor_R16P ctor_R4P ctor_R8P description description description description description description description description description description description description destroy destroy destroy destroy destroy destroy destroy destroy destroy destroy destroy_interpolator_constructor digit digit_I1 digit_I2 digit_I4 digit_I8 execute initialize integer_to_string interpolate interpolate matrix_to_string optional_int_to_string penf_init penf_print savefig str str_a_I1P str_a_I2P str_a_I4P str_a_I8P str_a_R16P str_a_R4P str_a_R8P str_bol str_I1P str_I2P str_I4P str_I8P str_R16P str_R4P str_R8P strf_I1P strf_I2P strf_I4P strf_I8P strf_R16P strf_R4P strf_R8P strz strz_I1P strz_I2P strz_I4P strz_I8P tau vec_to_string weno_exp weno_odd wenoof_create