• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python transforms.blended_transform_factory函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: _draw_labels

    def _draw_labels(self):
        """
        Draw x and y labels onto the figure
        """
        # This is very laboured. Should be changed when MPL
        # finally has a constraint based layout manager.
        figure = self.figure
        get_property = self.theme.themeables.property

        try:
            margin = get_property('axis_title_x', 'margin')
        except KeyError:
            pad_x = 5
        else:
            pad_x = margin.get_as('t', 'pt')

        try:
            margin = get_property('axis_title_y', 'margin')
        except KeyError:
            pad_y = 5
        else:
            pad_y = margin.get_as('r', 'pt')

        # Get the axis labels (default or specified by user)
        # and let the coordinate modify them e.g. flip
        labels = self.coordinates.labels({
            'x': self.layout.xlabel(self.labels),
            'y': self.layout.ylabel(self.labels)
        })

        # The first axes object is on left, and the last axes object
        # is at the bottom. We change the transform so that the relevant
        # coordinate is in figure coordinates. This way we take
        # advantage of how MPL adjusts the label position so that they
        # do not overlap with the tick text. This works well for
        # facetting with scales='fixed' and also when not facetting.
        # first_ax = self.axs[0]
        # last_ax = self.axs[-1]

        xlabel = self.facet.last_ax.set_xlabel(
            labels['x'], labelpad=pad_x)
        ylabel = self.facet.first_ax.set_ylabel(
            labels['y'], labelpad=pad_y)

        xlabel.set_transform(mtransforms.blended_transform_factory(
            figure.transFigure, mtransforms.IdentityTransform()))
        ylabel.set_transform(mtransforms.blended_transform_factory(
            mtransforms.IdentityTransform(), figure.transFigure))

        figure._themeable['axis_title_x'] = xlabel
        figure._themeable['axis_title_y'] = ylabel
开发者ID:jwhendy,项目名称:plotnine,代码行数:51,代码来源:ggplot.py


示例17: setAxes1

def setAxes1(axs, opts, provs, weststyle=False):
	axps, axhp, axhs, axll = axs
	axhp.set_title(opts.figtt)
	axhp.yaxis.set_major_formatter(nullfmt)
	axhs.xaxis.set_major_formatter(nullfmt)
	axhp.set_ylabel('P Histogram')
	axhs.set_xlabel('S Histogram')
	#axhp.grid()
	#axhs.grid()
	axps.grid()
	#print axhp.get_ylim()
	#print axhs.get_xlim()
	if opts.absdt:
		axps.set_xlabel('Absolute P Delay Time [s]')
		axps.set_ylabel('Absolute S Delay Time [s]')
	else:
		axps.set_xlabel('Relative P Delay Time [s]')
		axps.set_ylabel('Relative S Delay Time [s]')
	axps.set_xticks(opts.xticks)
	axps.set_yticks(opts.yticks)
	axhs.xaxis.set_label_position('top')
	if weststyle:
		axps.yaxis.set_label_position('right')
		axps.yaxis.set_ticks_position('right')
		axhs.yaxis.set_ticks_position('right')
		axhs.set_xlim(axhs.get_xlim()[::-1])
	# make legend
	if opts.physio:
		ax = axll
		n = len(provs)
		for i in range(n):
			ax.plot(0.04, -i, color='None', marker=opts.pmarker, mec=pidict[provs[i]][2], 
				ms=opts.pms, mew=opts.pmew, ls='None', alpha=1)
				#ms=opts.pms, mew=opts.pmew, ls='None', alpha=opts.alpha)
			ax.text(0.08, -i, pidict[provs[i]][1], va='center', ha='left', size=14)
			ax.axis([0,1,0.5-n,0.5])
		ax.yaxis.set_major_formatter(nullfmt)
		ax.xaxis.set_major_formatter(nullfmt)
		ax.set_xticks([])
		ax.set_yticks([])
	# label fig number
	if opts.lab is not None:
		lab = '(' + opts.lab + ')'
		if weststyle:
			trans = transforms.blended_transform_factory(ax.transAxes, ax.transAxes)
			ax.text(-0.06, 1.03, lab, transform=trans, va='bottom', ha='left', size=20, fontweight='bold')
		else: 
			trans = transforms.blended_transform_factory(axhp.transAxes, axhp.transAxes)
			axhp.text(-0.13, 1.03, lab, transform=trans, va='bottom', ha='left', size=20, fontweight='bold')
开发者ID:ehparker,项目名称:pysmo,代码行数:49,代码来源:ttpairs.py


示例18: line_to_axis

def line_to_axis(ax,x,y,xlabel=None,ylabel=None,fontsize=12):
    """
    Draw a line from a point x,y on to x and y axes ax.
    """
    v=ax.axis()

    if not (xlabel is None):
        ax.arrow(x,y,0,-(y-v[2])) # To x axis
        trans_x = transforms.blended_transform_factory(ax.transData, ax.transAxes)
        ax.text(x, -0.03, xlabel, transform=trans_x, fontsize=fontsize, va='center',ha='center')

    if not (ylabel is None):
        ax.arrow(x,y,-(x-v[0]),0.) # To y axis
        trans_y = transforms.blended_transform_factory(ax.transAxes, ax.transData)
        ax.text(-0.01, y, ylabel, transform=trans_y, fontsize=fontsize, va='center',ha='right')
开发者ID:ecollins,项目名称:TUP-neediness,代码行数:15,代码来源:engel_curves.py


示例19: _set_lim_and_transforms

    def _set_lim_and_transforms(self):
        """
        This is called once when the plot is created to set up all the
        transforms for the data, text and grids.
        """
        rot = 30

        # Get the standard transform setup from the Axes base class
        Axes._set_lim_and_transforms(self)

        # Need to put the skew in the middle, after the scale and limits,
        # but before the transAxes. This way, the skew is done in Axes
        # coordinates thus performing the transform around the proper origin
        # We keep the pre-transAxes transform around for other users, like the
        # spines for finding bounds
        self.transDataToAxes = self.transScale + \
            self.transLimits + transforms.Affine2D().skew_deg(rot, 0)

        # Create the full transform from Data to Pixels
        self.transData = self.transDataToAxes + self.transAxes

        # Blended transforms like this need to have the skewing applied using
        # both axes, in axes coords like before.
        self._xaxis_transform = (transforms.blended_transform_factory(
            self.transScale + self.transLimits,
            transforms.IdentityTransform()) +
            transforms.Affine2D().skew_deg(rot, 0)) + self.transAxes
开发者ID:DanHickstein,项目名称:matplotlib,代码行数:27,代码来源:skewt.py


示例20: delayDistPlotRun

def delayDistPlotRun(dtdict, sdfile, opts):	
	'Run delayDistPlot '
	tpfile = sdfile + '-topo'
	vals = loadtxt(tpfile, usecols=(1,2))
	dists = vals[:,0]
	topos = vals[:,1]

	dddict, dtmean, sdlist, ftag = delayDistGet(dtdict, sdfile, opts)

	fig = figure(figsize=(7, 8))
	ax0 = fig.add_subplot(2, 1, 1)
	ax1 = fig.add_subplot(2, 1, 2, sharex=ax0)
	subplots_adjust(left=.1, right=.95, bottom=.08, top=0.86, hspace=.08)
	rcParams['legend.fontsize'] = 9
	# plot topo
	ax = fig.add_axes([0.1, 0.92, 0.85, 0.065], sharex=ax0)
	axs = [ax0, ax1, ax]
	ax.plot(dists, topos, 'k-')
	zz = zeros(len(dists))
	ax.fill_between(dists, zz, topos, color='k', alpha=.3)
	tmin, tmax = min(topos), max(topos)
	dt = (tmax - tmin)*.2
	ax.set_ylim(tmin-dt, tmax+dt)
	ax.set_yticks([])
	ax.set_ylabel('Topo')
	# plot dt dist
	if opts.blackwhite:
		opts.randcol = False
	else:
		opts.randcol = True
	opts.pcol = 'k'
	opts.pms = 4
	opts.mcol = 'k'
	opts.msym = '+'
	opts.mms = 11
	opts.msym = '*'
	opts.mew = 2
	opts.alpha = .4
	if opts.blackwhite:
		opts.alpha = .2
		opts.alpha = .4

	opts.xlim = None
	opts.xlim = -100, sdlist[-1][1] + 100
	delayDistPlot(dddict, dtmean, sdlist, axs, opts)

	# indexing
	if opts.indexing is not None:
		#ax = ax0
		tt = '(' + opts.indexing + ')'
		trans = transforms.blended_transform_factory(ax.transAxes, ax.transAxes)
		#ax.text(-.05, 1.1, tt, transform=trans, va='center', ha='right', size=16)	
		ax.text(-.06, 1.1, tt, transform=trans, va='top', ha='right', size=16)	

	key = '-'.join(sdfile.split('/')[-1].split('.'))
	if opts.randcol:
		fignm = odir + 'ddline-rc-' + ftag + key + '.png'
	else:
		fignm = odir + 'ddline-kw-' + ftag + key + '.png'
	saveFigure(fignm, opts)
开发者ID:ehparker,项目名称:pysmo,代码行数:60,代码来源:ttvdist.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python transforms.interval_contains函数代码示例发布时间:2022-05-27
下一篇:
Python basemap.Basemap类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap