subroutine savefig(me, figfile, pyfile)
class(pyplot), intent(inout) :: me !! pyplot handler
character(len=*), intent(in) :: figfile !! file name for the figure
character(len=*), intent(in), optional :: pyfile !! name of the Python script to generate
if (allocated(me%str)) then
!finish up the string:
if (me%show_legend) then
call me%add_str('ax.legend(loc="best")')
call me%add_str('')
end if
if (me%axis_equal) then
call me%add_str('ax.axis("equal")')
call me%add_str('')
end if
call me%add_str('plt.savefig("'//trim(figfile)//'")')
!run it:
call me%execute(pyfile)
else
error stop 'error in savefig: pyplot class not properly initialized.'
end if
end subroutine savefig