当前位置: 首页>>代码示例>>Python>>正文


Python History.com_traces方法代码示例

本文整理汇总了Python中history.History.com_traces方法的典型用法代码示例。如果您正苦于以下问题:Python History.com_traces方法的具体用法?Python History.com_traces怎么用?Python History.com_traces使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在history.History的用法示例。


在下文中一共展示了History.com_traces方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Simulation

# 需要导入模块: from history import History [as 别名]
# 或者: from history.History import com_traces [as 别名]

#.........这里部分代码省略.........
        m.save(filename)
        print 'export_motion OK:', filename

    def load(self, filename):
        self.name = self.name.replace('_naive', '')
        with open(filename, 'r') as fp:
            self.plan = pickle.load(fp)
            self.tip_controller = model.controller.Controller(self.skel,
                                                              self.prob,
                                                              self.plan)
            self.tip_controller.pd.set_pd_params(self.name)
            targets = pickle.load(fp)
            self.tip_controller.targets = targets

    def save_motion(self, filename):
        protocol = pickle.HIGHEST_PROTOCOL
        # protocol = 0
        with open(filename, 'w+') as fp:
            pickle.dump(self.history, fp, protocol)
        print 'save #', len(self.history), 'frames'

    def load_motion(self, filename):
        with open(filename, 'r') as fp:
            self.history = pickle.load(fp)
        print 'load #', len(self.history), 'frames'

    def plot_com(self):
        # mycolors = ['r', 'b', 'g', 'k', 'c']

        traces = []
        colors = []
        styles = []

        traces += self.history.com_traces()
        n = len(traces)
        # colors += mycolors[:n]
        colors += ['r'] * n
        styles += ['-'] * n
        if hasattr(self, 'plan') and self.plan is not None:
            traces += self.plan.com_traces()
            m = len(traces) - n
            # colors += mycolors[:n]
            colors += ['b'] * m
            styles += ['-'] * m

        # Ploting with matplotlib
        plt.ioff()
        fig = plt.figure()
        fig.set_size_inches(18.5, 10.5)
        pp = []
        for trace, c, ls in zip(traces, colors, styles):
            (x, y, text) = trace
            print 'plot'
            print 'x:', x
            print 'y:', y
            p = plt.plot(x, y, ls=ls, color=c, linewidth=2)
            pp.append(p[0])
        # plt.title('Compare %d Trials on %s' % (num_trials, prob_name),
        name = self.name.replace('_', ' ')
        name = name.replace('Lean', '')
        t = plt.title('%s' % name,
                      fontdict={'size': 40})
        t.set_y(0.92)
        font = {'size': 36}
        plt.xlabel('X', fontdict=font)
        plt.ylabel('Y', fontdict=font)
开发者ID:sehoonha,项目名称:pydart_private,代码行数:70,代码来源:simulation.py


注:本文中的history.History.com_traces方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。