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


Python transforms.blended_transform_factory函数代码示例

本文整理汇总了Python中matplotlib.transforms.blended_transform_factory函数的典型用法代码示例。如果您正苦于以下问题:Python blended_transform_factory函数的具体用法?Python blended_transform_factory怎么用?Python blended_transform_factory使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: zoom_effect

def zoom_effect(ax1, ax2, xlim, **kwargs):

	trans1 = blended_transform_factory(ax1.transData, ax1.transAxes)
	trans2 = blended_transform_factory(ax2.transData, ax2.transAxes)

	bbox = Bbox.from_extents(xlim[0], 0, xlim[1], 1)

	tbbox1 = TransformedBbox(bbox, trans1)
	tbbox2 = TransformedBbox(bbox, trans2)

	
	prop_patches = kwargs.copy()
	prop_patches['ec'] = 'none'
	prop_patches['alpha'] = 0.1

	c1, c2, bbox_patch1, bbox_patch2, p = \
			connect_bboxes(tbbox1, tbbox2, loc1a=3, loc2a=2, loc1b=4, loc2b=1, prop_lines=kwargs, prop_patches=prop_patches)
	
	ax1.add_patch(bbox_patch1)
	ax2.add_patch(bbox_patch2)
	ax2.add_patch(c1)
	ax2.add_patch(c2)
	ax2.add_patch(p)

	return c1, c2, bbox_patch1, bbox_patch2, p
开发者ID:djhshih,项目名称:genomic,代码行数:25,代码来源:cn.py

示例2: make_range_frame

    def make_range_frame(self):
        """ Constructs the component lines of the range frame """
        xtrans = transforms.blended_transform_factory(
            self.axes.transData, self.axes.transAxes
        )
        intervalx = interval_as_array(self.axes.dataLim.intervalx)

        ytrans = transforms.blended_transform_factory(
            self.axes.transAxes, self.axes.transData
        )
        intervaly = interval_as_array(self.axes.dataLim.intervaly)

        xline = LineCollection(
            segments=[[(intervalx[0], 0), (intervalx[1], 0)]],
            linewidths=[self.linewidth],
            colors=[self.color],
            transform=xtrans,
            zorder=10
        )
        yline = LineCollection(
            segments=[[(0, intervaly[0]), (0, intervaly[1])]],
            linewidths=[self.linewidth],
            colors=[self.color],
            transform=ytrans,
            zorder=10
        )

        return [xline, yline]
开发者ID:Waino,项目名称:etframes,代码行数:28,代码来源:etframes.py

示例3: get_spine_transform

    def get_spine_transform(self):
        """get the spine transform"""
        self._ensure_position_is_set()
        what, how = self._spine_transform

        if what == 'data':
            # special case data based spine locations
            data_xform = self.axes.transScale + \
                         (how+self.axes.transLimits + self.axes.transAxes)
            if self.spine_type in ['left','right']:
                result = mtransforms.blended_transform_factory(
                    data_xform,self.axes.transData)
            elif self.spine_type in ['top','bottom']:
                result = mtransforms.blended_transform_factory(
                    self.axes.transData,data_xform)
            else:
                raise ValueError('unknown spine spine_type: %s'%self.spine_type)
            return result

        if self.spine_type in ['left','right']:
            base_transform = self.axes.get_yaxis_transform(which='grid')
        elif self.spine_type in ['top','bottom']:
            base_transform = self.axes.get_xaxis_transform(which='grid')
        else:
            raise ValueError('unknown spine spine_type: %s'%self.spine_type)

        if what=='identity':
            return base_transform
        elif what=='post':
            return base_transform+how
        elif what=='pre':
            return how+base_transform
        else:
            raise ValueError("unknown spine_transform type: %s"%what)
开发者ID:umitceylan,项目名称:Visualizr,代码行数:34,代码来源:spines.py

示例4: get_spine_transform

    def get_spine_transform(self):
        """get the spine transform"""
        self._ensure_position_is_set()
        what, how = self._spine_transform

        if what == "data":
            # special case data based spine locations
            data_xform = self.axes.transScale + (how + self.axes.transLimits + self.axes.transAxes)
            if self.spine_type in ["left", "right"]:
                result = mtransforms.blended_transform_factory(data_xform, self.axes.transData)
            elif self.spine_type in ["top", "bottom"]:
                result = mtransforms.blended_transform_factory(self.axes.transData, data_xform)
            else:
                raise ValueError("unknown spine spine_type: %s" % self.spine_type)
            return result

        if self.spine_type in ["left", "right"]:
            base_transform = self.axes.get_yaxis_transform(which="grid")
        elif self.spine_type in ["top", "bottom"]:
            base_transform = self.axes.get_xaxis_transform(which="grid")
        else:
            raise ValueError("unknown spine spine_type: %s" % self.spine_type)

        if what == "identity":
            return base_transform
        elif what == "post":
            return base_transform + how
        elif what == "pre":
            return how + base_transform
        else:
            raise ValueError("unknown spine_transform type: %s" % what)
开发者ID:blitzmann,项目名称:Pyfa-skel,代码行数:31,代码来源:spines.py

示例5: _fancy_barh

def _fancy_barh(ax, values, data, val_fmt='', is_legend=False):
    """fancy-ish horizontal bar plot
       values must be same len as data, use np.nan if no values for sample
       :param is_legend: if True, will include legend like line segments
       :param val_fmt: is format string for value;
                       None don't show vlaue, '' just str()
    """
    assert( len(values) == len(data) )
    names = []
    for d in data:
        names.append(d['name'])
    width = 0.90
    bar_pos = np.arange(len(names))
    rects = ax.barh(bar_pos, values, width)
    ax.set_yticks([])
    ax.set_ylim([min(bar_pos)-(1-width)/2., max(bar_pos)+width+(1-width)/2.])
    ax.invert_yaxis()
    # set bar colors and annotate with sample name : size
    xmax = ax.get_xlim()[1]
    for ii,rect in enumerate(rects):
        rect.set_facecolor(data[ii]['plot_color'])
        x = 0.01
        y = rect.get_y()+rect.get_height()/2.
        if( val_fmt is None ):
            label = str(names[ii])
        else:
            if( np.isnan(values[ii]) ):
                label = '%s : No Info'%(names[ii])
            elif( val_fmt == '' ):
                label = '%s : %s'%(names[ii], str(values[ii]))
            else:
                label = ('%s : '+val_fmt)%(names[ii], values[ii])
        ax.text(x, y, label,
                va='center', ha='left',
                transform=transforms.blended_transform_factory(
                ax.transAxes, ax.transData),
                bbox=dict(boxstyle="round,pad=0.2", alpha=0.65, fc='w', lw=0) )
        if( is_legend ):
            # legend like line segment
            linex = [-0.12, -0.04]
            box_h= 0.5
            box_w_pad = 0.025
            ax.add_patch(MPL.patches.FancyBboxPatch((linex[0]-box_w_pad,y-box_h/2.),
                        linex[1]-linex[0]+2*box_w_pad, box_h,
                        ec='w',
                        fc='w',
                        boxstyle="square,pad=0",
                        transform=transforms.blended_transform_factory(
                                ax.transAxes, ax.transData),
                        clip_on=False) )
            line, = ax.plot([-0.12,-0.04], [y]*2,
                    '-', color=data[ii]['plot_color'],
                    marker=data[ii]['plot_marker'],
                    transform=transforms.blended_transform_factory(
                    ax.transAxes, ax.transData),
                    clip_on=False)
    ax.set_xlim((0,xmax))
    ax.set_ylabel(' \n \n ') # @TCC hack - fake ylabel so tight_layout adds spacing
    return True
开发者ID:Milt0n,项目名称:sga,代码行数:59,代码来源:sga-preqc-report.py

示例6: _set_lim_and_transforms

    def _set_lim_and_transforms(self):

        self.transAxes = self._parent_axes.transAxes

        self.transData = self.transAux + self._parent_axes.transData

        self._xaxis_transform = mtransforms.blended_transform_factory(self.transData, self.transAxes)
        self._yaxis_transform = mtransforms.blended_transform_factory(self.transAxes, self.transData)
开发者ID:npinto,项目名称:matplotlib,代码行数:8,代码来源:parasite_axes.py

示例7: __init__

    def __init__(self, transform, fig_transform,
                 sizex=0, sizey=0, labelx=None, labely=None, loc=4,
                 xbar_width = 2, ybar_width = 2,
                 pad=3, borderpad=0.1, xsep=3, ysep = 3, prop=None, textprops={'size':10}, **kwargs):
        """
        Draw a horizontal and/or vertical  bar with the size in data coordinate
        of the give axes. A label will be drawn underneath (center-aligned).
 
        - transform : the coordinate frame (typically axes.transData)
        - sizex,sizey : width of x,y bar, in data units. 0 to omit
        - labelx,labely : labels for x,y bars; None to omit
        - loc : position in containing axes
        - pad, borderpad : padding, in fraction of the legend font size (or prop)
        - sep : separation between labels and bars in points.
        - **kwargs : additional arguments passed to base class constructor
        """
        from matplotlib.patches import Rectangle
        from matplotlib.offsetbox import AuxTransformBox, VPacker, HPacker, TextArea, DrawingArea
        # new shit
        # try splitting the transform into X and Y so that
        import matplotlib.transforms as transforms
        xtransform = transforms.blended_transform_factory(transform, fig_transform)
        ytransform = transforms.blended_transform_factory(fig_transform, transform)
        # end new shit

        # bars = AuxTransformBox(xtransform)
        # if sizey:
        #     bars.add_artist(Rectangle((0,0), ybar_width, sizey,
        #                               fc="Black"))
        # if sizex:
        #     bars.add_artist(Rectangle((0,0), sizex, xbar_width,
        #                               fc="Black"))
 
        ybar_width /= 72.
        xbar_width /= 72.
        
        if sizey:
            ybar = AuxTransformBox(ytransform)
            ybar.add_artist(Rectangle((0,0), ybar_width, sizey, fc="Black"))
            bars = ybar
        if sizex:
            xbar = AuxTransformBox(xtransform)
            xbar.add_artist(Rectangle((0,0), sizex, xbar_width, fc="Black"))
            bars = xbar
        if sizex and sizey:
            bars = VPacker(children=[ybar, xbar], pad = 10, sep=ysep)
        if sizex and labelx:
            bars = VPacker(children=[bars, TextArea(labelx,
                                                    minimumdescent=False,
                                                    textprops = textprops)],
                           align="center", pad=0, sep=-3)
        if sizey and labely:
            bars = HPacker(children=[TextArea(labely,
                                              textprops = textprops), bars],
                            align="center", pad=0, sep=xsep)

        AnchoredOffsetbox.__init__(self, loc, pad=pad, borderpad=borderpad,
                                   child=bars, prop=prop, frameon=False, **kwargs)
开发者ID:matthewperkins,项目名称:plotting,代码行数:58,代码来源:mp_scale_bars.py

示例8: dhist

def dhist(xvals, yvals, xbins=20, ybins=20, ax=None, c='b', fmt='.', ms=1,
          label=None, loc='right,bottom', xhistmax=None, yhistmax=None,
          histlw=1, xtop=0.2, ytop=0.2, chist=None, **kwargs):
    """ Given two set of values, plot two histograms and the
    distribution.

    xvals,yvals are the two properties to plot.  xbins, ybins give the
    number of bins or the bin edges. c is the color.
    """

    if chist is None:
        chist = c
    if ax is None:
        pl.figure()
        ax = pl.gca()

    loc = [l.strip().lower() for l in loc.split(',')]

    if ms is None:
        ms = default_marker_size(fmt)

    ax.plot(xvals, yvals, fmt, color=c, ms=ms, label=label, **kwargs)
    x0,x1,y0,y1 = ax.axis()

    if np.__version__ < '1.5':
        x,xbins = np.histogram(xvals, bins=xbins, new=True)
        y,ybins = np.histogram(yvals, bins=ybins, new=True)
    else:
        x,xbins = np.histogram(xvals, bins=xbins)
        y,ybins = np.histogram(yvals, bins=ybins)

    b = np.repeat(xbins, 2)
    X = np.concatenate([[0], np.repeat(x,2), [0]])
    Xmax = xhistmax or X.max()
    X = xtop * X / Xmax
    if 'top' in loc:
        X = 1 - X
    trans = mtransforms.blended_transform_factory(ax.transData, ax.transAxes)
    ax.plot(b, X, color=chist, transform=trans, lw=histlw)

    b = np.repeat(ybins, 2)
    Y = np.concatenate([[0], np.repeat(y,2), [0]])
    Ymax = yhistmax or Y.max()
    Y = ytop * Y / Ymax
    if 'right' in loc:
        Y = 1 - Y
    trans = mtransforms.blended_transform_factory(ax.transAxes, ax.transData)
    ax.plot(Y, b, color=chist, transform=trans, lw=histlw)

    ax.set_xlim(xbins[0], xbins[-1])
    ax.set_ylim(ybins[0], ybins[-1])
    if pl.isinteractive():
        pl.show()

    return ax, dict(x=x, y=y, xbinedges=xbins, ybinedges=ybins)
开发者ID:nhmc,项目名称:H2,代码行数:55,代码来源:plot.py

示例9: puttext

def puttext(x,y,text,ax, xcoord='ax', ycoord='ax', **kwargs):
    """ Print text on an axis using axes coordinates."""
    if xcoord == 'data' and ycoord == 'ax':
        trans = mtransforms.blended_transform_factory(ax.transData, ax.transAxes)
    elif xcoord == 'ax' and ycoord == 'data':
        trans = mtransforms.blended_transform_factory(ax.transAxes, ax.transData)
    elif xcoord == 'ax' and ycoord == 'ax':
        trans = ax.transAxes
    else:
        raise ValueError("Bad keyword combination: %s, %s "%(xcoord,ycoord))
    return ax.text(x, y, str(text), transform=trans, **kwargs)
开发者ID:bsipocz,项目名称:Barak,代码行数:11,代码来源:plot.py

示例10: plotinit

    def plotinit(self):
        """ Set up the figure and do initial plots.

        Updates the following attributes:

          self.artists
        """
        wa,fl,er = self.wa, self.fl, self.er
        if self.continuum is not None:
            co = self.continuum

        # axis for spectrum & continuum
        a0 = self.fig.add_axes((0.05,0.1,0.9,0.6))
        self.ax = a0
        a0.set_autoscale_on(0)
        # axis for residuals
        a1 = self.fig.add_axes((0.05,0.75,0.9,0.2),sharex=a0)
        a1.set_autoscale_on(0)
        a1.axhline(0,color='k',alpha=0.7, zorder=99)
        a1.axhline(1,color='k',alpha=0.7, zorder=99)
        a1.axhline(-1,color='k',alpha=0.7, zorder=99)
        a1.axhline(2,color='k',linestyle='dashed',zorder=99)
        a1.axhline(-2,color='k',linestyle='dashed',zorder=99)
        m0, = a1.plot([0],[0],'.r',marker='.', mec='none', lw=0, mew=0, ms=6, alpha=0.5)
        a1.set_ylim(-4, 4)
        a0.axhline(0, color='0.7')
        if self.continuum is not None:
            a0.plot(wa, co, color='0.7', lw=1, ls='dashed')
        self.artists['fl'], = a0.plot(wa, fl, 'b', lw=0.5,
                                      linestyle='steps-mid')
        a0.plot(wa, er, lw=0.5, color='orange')
        m1, = a0.plot([0], [0], 'r', alpha=0.7)
        m2, = a0.plot([0], [0], 'o', mfc='None',mew=1, ms=8, mec='r', picker=5,
                      alpha=0.7)
        a0.set_xlim(min(wa), max(wa))
        good = (er > 0) & ~np.isnan(fl) & ~np.isinf(fl)
        ymax = 2 * np.abs(np.percentile(fl[good], 95))
        a0.set_ylim(-0.1*ymax, ymax)
        a0.text(0.9,0.9, 'z=%.2f' % self.redshift, transform=a0.transAxes)

        # for histogram
        trans = mtran.blended_transform_factory(a1.transAxes, a1.transData)
        hist, = a1.plot([], [], color='k', transform=trans)
        x = np.linspace(-3,3)
        a1.plot(Gaussian(x,0,1,0.05), x, color='k', transform=trans, lw=0.5)

        if self.template is not None:
            trans = mtran.blended_transform_factory(a0.transData, a0.transAxes)
            a0.plot(self.wa, self.template/self.template.max(), '-c', lw=2,
                    alpha=0.5, transform=trans)

        self.fig.canvas.draw()
        self.artists.update(contpoints=m2, cont=m1, resid=m0, hist_left=hist)
开发者ID:bsipocz,项目名称:Barak,代码行数:53,代码来源:fitcont.py

示例11: zoom_effect

def zoom_effect(ax_zoomed, ax_origin, xlims = None, orientation='below', **kwargs):
    """
    ax_zoomed : zoomed axes
    ax_origin:  the main axes
    (xmin,xmax) : the limits of the colored area in both plot axes.

    connect ax1 & ax2. The x-range of (xmin, xmax) in both axes will
    be marked.  The keywords parameters will be used ti create
    patches.

    """
    if xlims is None:
        tt = ax_zoomed.transScale + (ax_zoomed.transLimits + ax_origin.transAxes)
        transform = blended_transform_factory(ax_origin.transData, tt)

        bbox_zoomed=ax_zoomed.bbox
        bbox_origin=TransformedBbox(ax_zoomed.viewLim, transform)
    else:
        transform_zoomed=blended_transform_factory(ax_zoomed.transData, ax_zoomed.transAxes)
        transform_origin=blended_transform_factory(ax_origin.transData, ax_origin.transAxes)
    
        bbox_zoomed=TransformedBbox(Bbox.from_extents(xlims[0], 0, xlims[1], 1), transform_zoomed)
        bbox_origin=TransformedBbox(Bbox.from_extents(xlims[0], 0, xlims[1], 1), transform_origin)

    prop_patches = kwargs.copy()
    prop_patches["ec"] = "none"
    prop_patches["alpha"] = 0.2

    if orientation=='below':
        loc1a=2
        loc2a=3
        loc1b=1
        loc2b=4
    elif orientation=='above':
        loc1a=3
        loc2a=2
        loc1b=4
        loc2b=1
    else:
        raise Exception("orientation '%s' not recognized" % orientation)

    c1, c2, bbox_zoomed_patch, bbox_origin_patch, p = \
        connect_bbox(bbox_zoomed, bbox_origin,
                     loc1a=loc1a, loc2a=loc2a, loc1b=loc1b, loc2b=loc2b,
                     prop_lines=kwargs, prop_patches=prop_patches)

    ax_zoomed.add_patch(bbox_zoomed_patch)
    ax_origin.add_patch(bbox_origin_patch)
    ax_origin.add_patch(c1)
    ax_origin.add_patch(c2)
    ax_origin.add_patch(p)

    return c1, c2, bbox_zoomed_patch, bbox_origin_patch, p
开发者ID:jvierstra,项目名称:genome-tools,代码行数:53,代码来源:connectors.py

示例12: setLabels

 def setLabels(self):
     """ Set plot attributes """
     self.ppm.axpp.set_title("Seismograms")
     if self.opts.filemode == "pkl":
         axstk = self.axstk
         trans = transforms.blended_transform_factory(axstk.transAxes, axstk.transAxes)
         axstk.text(1, 1.01, self.opts.pklfile, transform=trans, va="bottom", ha="right", color="k")
     axpp = self.ppm.axpp
     trans = transforms.blended_transform_factory(axpp.transAxes, axpp.transData)
     font = FontProperties()
     font.set_family("monospace")
     axpp.text(1.025, 0, " " * 8 + "qual= CCC/SNR/COH", transform=trans, va="center", color="k", fontproperties=font)
开发者ID:xlougeo,项目名称:aimbat,代码行数:12,代码来源:qualctrl.py

示例13: _buildTransform

def _buildTransform(current_axes):
    global _stlp_data_transform, _stlp_xlabel_transform, _stlp_ylabel_transform

    current_figure = current_axes.figure

    current_axes.axes.get_xaxis().set_visible(False)
    current_axes.axes.get_yaxis().set_visible(False)
#   pylab.box(False)

    data_figure_trans = current_axes.transData + current_figure.transFigure.inverted()

    pylab.xlim((_T_min, _T_max))
    pylab.ylim((_p_min, _p_max))

    identity_matrix = np.zeros((3, 3))
    for idx in range(3): identity_matrix[idx, idx] = 1

    # Create the affine matrix for the skew transform.  This only works in data coordinates.  We'll fix that later ...
    skew_matrix = np.copy(identity_matrix)
    skew_matrix[0, 1] = np.tan(45 * np.pi / 180)
    skew_transform = transforms.Affine2D(skew_matrix)

    # Create the logarithmic transform in the y.
    log_p_transform = transforms.blended_transform_factory(transforms.Affine2D(), LogScale(current_axes.yaxis, basey=10).get_transform())

    # The log transform shrinks everything to log(p) space, so define a scale factor to blow it back up to a reasonable size.
    p_bnd_trans = log_p_transform.transform(np.array([[0, _p_min], [0, _p_max]]))[:, 1]
    scale_factor = (_p_max - _p_min) / (p_bnd_trans[1] - p_bnd_trans[0])

    # Define the affine transform for the flip and another for the scale back to reasonable coordinates after the log transform.
    flip_transform = transforms.Affine2D.identity().scale(1, -1)
    preskew_scale_transform = transforms.Affine2D().translate(0, p_bnd_trans[1]).scale(1, scale_factor).translate(0, _p_min)
    postskew_move_transform = transforms.Affine2D().translate(0, _p_min)

    # Define a transform that basically does everything but the skew so we can figure out where the 1000 mb level is and skew around that line.
    prelim_data_transform = log_p_transform + flip_transform + preskew_scale_transform + data_figure_trans
    marker = prelim_data_transform.transform(np.array([[_T_min, 1000]]))[0, 1]

    # Add a translation to that marker point into the data-figure transform matrix.
    data_figure_trans += transforms.Affine2D().translate(0, -marker)

    # Define our skew transform in figure coordinates.
    figure_skew_transform = data_figure_trans + skew_transform + data_figure_trans.inverted()

    # Create our skew-T log-p transform matrix.  It does the log-p transform first, then the flip, then the scale, then the skew.
    _stlp_data_transform = log_p_transform + flip_transform + preskew_scale_transform + figure_skew_transform + current_axes.transData

    # Create a blended transform where the y axis is the log-p, but the x axis is the axes transform (for adding pressure labels and wind barbs).
    _stlp_xlabel_transform = transforms.blended_transform_factory(_stlp_data_transform, current_axes.transAxes)
    _stlp_ylabel_transform = transforms.blended_transform_factory(current_axes.transAxes, _stlp_data_transform)
    return
开发者ID:tsupinie,项目名称:research,代码行数:51,代码来源:plot_sounding.py

示例14: plotinit

    def plotinit(self):
        """ Set up the figure and do initial plots.

        Updates the following attributes:

          self.markers
        """
        wa,fl,er = [self.spec[k][0:-1:self.nbin] for k in 'wa fl er'.split()]
        if self.spec['co'] is not None:
            co = self.spec['co'][0:-1:self.nbin]
        # axis for spectrum & continuum
        a0 = self.fig.add_axes((0.05,0.1,0.9,0.6))
        a0.set_autoscale_on(0)
        # axis for residuals
        a1 = self.fig.add_axes((0.05,0.75,0.9,0.2),sharex=a0)
        a1.set_autoscale_on(0)
        a1.axhline(0,color='k',alpha=0.7, zorder=99)
        a1.axhline(1,color='k',alpha=0.7, zorder=99)
        a1.axhline(-1,color='k',alpha=0.7, zorder=99)
        a1.axhline(2,color='k',linestyle='dashed',zorder=99)
        a1.axhline(-2,color='k',linestyle='dashed',zorder=99)
        m0, = a1.plot([0],[0],'.r', ms=6, alpha=0.5)
        a1.set_ylim(-4, 4)
        a0.axhline(0, color='0.7')
        if self.spec['co'] is not None:
            a0.plot(wa,co, color='0.7', lw=1, ls='dashed')
        self.art_fl, = a0.plot(wa, fl, 'b', lw=0.5, linestyle='steps-mid')
        a0.plot(wa, er, lw=0.5, color='orange')
        m1, = a0.plot([0], [0], 'r', alpha=0.7)
        m2, = a0.plot([0], [0], 'o', mfc='None',mew=1, ms=8, mec='r', picker=5,
                      alpha=0.7)
        a0.set_xlim(min(wa), max(wa))
        good = (er > 0) & ~np.isnan(fl)
        ymin = -5 * np.median(er[good])
        ymax = 2 * sorted(fl[good])[int(good.sum()*0.95)]
        a0.set_ylim(ymin, ymax)
        a0.text(0.9,0.9, 'z=%.2f' % self.redshift, transform=a0.transAxes)

        # for histogram
        trans = mtran.blended_transform_factory(a1.transAxes, a1.transData)
        hist, = a1.plot([], [], color='k', transform=trans)
        x = np.linspace(-3,3)
        a1.plot(Gaussian(x,0,1,0.05), x, color='k', transform=trans, lw=0.5)

        if self.template is not None:
            trans = mtran.blended_transform_factory(a0.transData, a0.transAxes)                
            a0.plot(self.spec['wa'], self.template/self.template.max(), '-c', lw=2,
                    alpha=0.5, transform=trans)

        self.fig.canvas.draw()
        self.markers.update(contpoints=m2, cont=m1, resid=m0, hist_left=hist)
开发者ID:nhmc,项目名称:H2,代码行数:51,代码来源:fitcont.py

示例15: _set_lim_and_transforms

    def _set_lim_and_transforms(self):
        self.transAxes = BboxTransformTo(self.bbox)

        # Transforms the x and y axis separately by a scale factor
        # It is assumed that this part will have non-linear components
        self.transScale = TransformWrapper(IdentityTransform())

        # A (possibly non-linear) projection on the (already scaled)
        # data.  This one is aware of rmin
        self.transProjection = self.PolarTransform(self)

        # This one is not aware of rmin
        self.transPureProjection = self.PolarTransform(self, use_rmin=False)

        # An affine transformation on the data, generally to limit the
        # range of the axes
        self.transProjectionAffine = self.PolarAffine(self.transScale, self.viewLim)

        # The complete data transformation stack -- from data all the
        # way to display coordinates
        self.transData = self.transScale + self.transProjection + (self.transProjectionAffine + self.transAxes)

        # This is the transform for theta-axis ticks.  It is
        # equivalent to transData, except it always puts r == 1.0 at
        # the edge of the axis circle.
        self._xaxis_transform = (
            self.transPureProjection + self.PolarAffine(IdentityTransform(), Bbox.unit()) + self.transAxes
        )
        # The theta labels are moved from radius == 0.0 to radius == 1.1
        self._theta_label1_position = Affine2D().translate(0.0, 1.1)
        self._xaxis_text1_transform = self._theta_label1_position + self._xaxis_transform
        self._theta_label2_position = Affine2D().translate(0.0, 1.0 / 1.1)
        self._xaxis_text2_transform = self._theta_label2_position + self._xaxis_transform

        # This is the transform for r-axis ticks.  It scales the theta
        # axis so the gridlines from 0.0 to 1.0, now go from 0.0 to
        # 2pi.
        self._yaxis_transform = Affine2D().scale(np.pi * 2.0, 1.0) + self.transData
        # The r-axis labels are put at an angle and padded in the r-direction
        self._r_label1_position = ScaledTranslation(
            22.5, self._rpad, blended_transform_factory(Affine2D(), BboxTransformToMaxOnly(self.viewLim))
        )
        self._yaxis_text1_transform = (
            self._r_label1_position + Affine2D().scale(1.0 / 360.0, 1.0) + self._yaxis_transform
        )
        self._r_label2_position = ScaledTranslation(
            22.5, -self._rpad, blended_transform_factory(Affine2D(), BboxTransformToMaxOnly(self.viewLim))
        )
        self._yaxis_text2_transform = (
            self._r_label2_position + Affine2D().scale(1.0 / 360.0, 1.0) + self._yaxis_transform
        )
开发者ID:mferrero,项目名称:matplotlib,代码行数:51,代码来源:polar.py


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