Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 import os
00034 import numpy as np
00035 import matplotlib.pyplot as plt
00036 import matplotlib.patches as mpatches
00037
00038 def _equal_axes(ax):
00039 ax.set_aspect('equal')
00040 ax.set_aspect('equal', adjustable='datalim')
00041
00042 def newfig(title="", xlabel="", ylabel="", equal_axes=False, grid=True, hold=True):
00043 fig = plt.figure()
00044 plt.plot(0,0,'r')
00045 ax = plt.gca()
00046 ax.set_title(title)
00047 if equal_axes:
00048 _equal_axes(ax)
00049 ax.set_xlabel(xlabel)
00050 ax.set_ylabel(ylabel)
00051 plt.grid(grid)
00052 plt.hold(hold)
00053 fmwin = plt.get_current_fig_manager().window
00054 fignum_txt = fmwin.title()
00055 fmwin.title(fignum_txt + ': ' + title)
00056 return ax
00057
00058 def new_timeseries_fig(title="", ylabel="", grid=True, hold=True):
00059 ax = newfig(title, xlabel='time [s]', ylabel=ylabel, equal_axes=False, grid=grid, hold=hold)
00060
00061
00062 def plot_traj(x,y, *args, **kwargs):
00063 plt.plot(x, y, *args, **kwargs)
00064 plt.plot(x[0], y[0], 'go')
00065 plt.plot(x[-1], y[-1], 'rx')
00066
00067 def show():
00068 plt.show()
00069
00070 def save_all_figs(output_dir, prefix="", ext=".eps", **savefig_kwargs):
00071 fignums = plt.get_fignums()
00072 for fignum in fignums:
00073 f = plt.figure(fignum)
00074 fname = os.path.join(output_dir, prefix, ("%03d" % fignum) + ext)
00075 f.savefig(fname, orientation='landscape', **savefig_kwargs)
00076