Some final things to add before saving or showing the figure.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(pyplot), | intent(inout) | :: | me |
pyplot handler |
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