finish_ops Subroutine

private subroutine finish_ops(me)

Some final things to add before saving or showing the figure.

Type Bound

pyplot

Arguments

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

pyplot handler


Calls

proc~~finish_ops~~CallsGraph proc~finish_ops pyplot_module::pyplot%finish_ops proc~add_str pyplot_module::pyplot%add_str proc~finish_ops->proc~add_str

Called by

proc~~finish_ops~~CalledByGraph proc~finish_ops pyplot_module::pyplot%finish_ops proc~savefig pyplot_module::pyplot%savefig proc~savefig->proc~finish_ops proc~showfig pyplot_module::pyplot%showfig proc~showfig->proc~finish_ops

Source Code

    subroutine finish_ops(me)

    class(pyplot),intent(inout) :: me  !! pyplot handler

    if (me%show_legend) then
        call me%add_str('ax.legend(loc="best")')
        call me%add_str('')
    end if
    if (me%axis_equal) then
        if (me%mplot3d) then
            call me%add_str('ax.set_aspect("auto")')
            call me%add_str('')

            call me%add_str('def set_axes_equal(ax):')
            call me%add_str('    x_limits = ax.get_xlim3d()')
            call me%add_str('    y_limits = ax.get_ylim3d()')
            call me%add_str('    z_limits = ax.get_zlim3d()')
            call me%add_str('    x_range = abs(x_limits[1] - x_limits[0])')
            call me%add_str('    x_middle = np.mean(x_limits)')
            call me%add_str('    y_range = abs(y_limits[1] - y_limits[0])')
            call me%add_str('    y_middle = np.mean(y_limits)')
            call me%add_str('    z_range = abs(z_limits[1] - z_limits[0])')
            call me%add_str('    z_middle = np.mean(z_limits)')
            call me%add_str('    plot_radius = 0.5*max([x_range, y_range, z_range])')
            call me%add_str('    ax.set_xlim3d([x_middle - plot_radius, x_middle + plot_radius])')
            call me%add_str('    ax.set_ylim3d([y_middle - plot_radius, y_middle + plot_radius])')
            call me%add_str('    ax.set_zlim3d([z_middle - plot_radius, z_middle + plot_radius])')
            call me%add_str('set_axes_equal(ax)')

        else
            call me%add_str('ax.axis("equal")')
        end if
        call me%add_str('')
    end if
    if (allocated(me%xaxis_date_fmt) .or. allocated(me%yaxis_date_fmt)) then
        call me%add_str('from matplotlib.dates import DateFormatter')
        if (allocated(me%xaxis_date_fmt)) &
            call me%add_str('ax.xaxis.set_major_formatter(DateFormatter("'//trim(me%xaxis_date_fmt)//'"))')
        if (allocated(me%yaxis_date_fmt)) &
            call me%add_str('ax.yaxis.set_major_formatter(DateFormatter("'//trim(me%yaxis_date_fmt)//'"))')
        call me%add_str('')
    end if
    if (me%tight_layout) then
        call me%add_str('fig.tight_layout()')
        call me%add_str('')
    end if

    end subroutine finish_ops