plot_window.py 文件源码

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

项目:yt 作者: yt-project 项目源码 文件源码
def __init__(self, data, cbname, cblinthresh, cmap, extent, zlim,
                 figure_size, fontsize, aspect, figure, axes, cax):
        from matplotlib.ticker import ScalarFormatter
        self._draw_colorbar = True
        self._draw_axes = True
        self._fontsize = fontsize
        self._figure_size = figure_size

        # Compute layout
        fontscale = float(fontsize) / 18.0
        if fontscale < 1.0:
            fontscale = np.sqrt(fontscale)

        if iterable(figure_size):
            fsize = figure_size[0]
        else:
            fsize = figure_size
        self._cb_size = 0.0375*fsize
        self._ax_text_size = [1.2*fontscale, 0.9*fontscale]
        self._top_buff_size = 0.30*fontscale
        self._aspect = ((extent[1] - extent[0])/(extent[3] - extent[2])).in_cgs()
        self._unit_aspect = aspect

        size, axrect, caxrect = self._get_best_layout()

        super(WindowPlotMPL, self).__init__(
            size, axrect, caxrect, zlim, figure, axes, cax)

        self._init_image(data, cbname, cblinthresh, cmap, extent, aspect)

        # In matplotlib 2.1 and newer we'll be able to do this using
        # self.image.axes.ticklabel_format
        # See https://github.com/matplotlib/matplotlib/pull/6337
        formatter = ScalarFormatter(useMathText=True)
        formatter.set_scientific(True)
        formatter.set_powerlimits((-2, 3))
        self.image.axes.xaxis.set_major_formatter(formatter)
        self.image.axes.yaxis.set_major_formatter(formatter)
        if cbname == 'linear':
            self.cb.formatter.set_scientific(True)
            self.cb.formatter.set_powerlimits((-2, 3))
            self.cb.update_ticks()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号