matplotlib_backend.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:artemis 作者: QUVA-Lab 项目源码 文件源码
def update(self, data):
        """
        :param data: A (left, bottom, right, top) bounding box.
        """
        if self._image_handle is None:
            self._image_handle = next(c for c in plt.gca().get_children() if isinstance(c, AxesImage))

        data_shape = self._image_handle.get_array().shape # Hopefully this isn't copying
        if data_shape != self._last_data_shape:
            extent =(-.5, data_shape[1]-.5, data_shape[0]-.5, -.5)
            self._image_handle.set_extent(extent)
            plt.gca().set_xlim(extent[:2])
            plt.gca().set_ylim(extent[2:])
            self._last_data_shape = data_shape

        l, b, r, t = data
        # x = np.array([l+.5, l+.5, r+.5, r+.5, l+.5])  # Note: should we be adding .5? The extend already subtracts .5
        # y = np.array([t+.5, b+.5, b+.5, t+.5, t+.5])
        x = np.array([l, l, r, r, l])  # Note: should we be adding .5? The extend already subtracts .5
        y = np.array([t, b, b, t, t])

        LinePlot.update(self, (x, y))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号