Python matplotlib.patches.Ellipse() Examples
The following are 30
code examples of matplotlib.patches.Ellipse().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
matplotlib.patches
, or try the search function
.
Example #1
Source File: tf_gmm_tools.py From tf-example-models with Apache License 2.0 | 7 votes |
def _plot_gaussian(mean, covariance, color, zorder=0): """Plots the mean and 2-std ellipse of a given Gaussian""" plt.plot(mean[0], mean[1], color[0] + ".", zorder=zorder) if covariance.ndim == 1: covariance = np.diag(covariance) radius = np.sqrt(5.991) eigvals, eigvecs = np.linalg.eig(covariance) axis = np.sqrt(eigvals) * radius slope = eigvecs[1][0] / eigvecs[1][1] angle = 180.0 * np.arctan(slope) / np.pi plt.axes().add_artist(pat.Ellipse( mean, 2 * axis[0], 2 * axis[1], angle=angle, fill=False, color=color, linewidth=1, zorder=zorder ))
Example #2
Source File: plot_grids.py From vnpy_crypto with MIT License | 6 votes |
def _make_ellipse(mean, cov, ax, level=0.95, color=None): """Support function for scatter_ellipse.""" from matplotlib.patches import Ellipse v, w = np.linalg.eigh(cov) u = w[0] / np.linalg.norm(w[0]) angle = np.arctan(u[1]/u[0]) angle = 180 * angle / np.pi # convert to degrees v = 2 * np.sqrt(v * stats.chi2.ppf(level, 2)) #get size corresponding to level ell = Ellipse(mean[:2], v[0], v[1], 180 + angle, facecolor='none', edgecolor=color, #ls='dashed', #for debugging lw=1.5) ell.set_clip_box(ax.bbox) ell.set_alpha(0.5) ax.add_artist(ell)
Example #3
Source File: utils.py From tf-example-models with Apache License 2.0 | 6 votes |
def _plot_gaussian(mean, covariance, color, zorder=0): """Plots the mean and 2-std ellipse of a given Gaussian""" plt.plot(mean[0], mean[1], color[0] + ".", zorder=zorder) if covariance.ndim == 1: covariance = np.diag(covariance) radius = np.sqrt(5.991) eigvals, eigvecs = np.linalg.eig(covariance) axis = np.sqrt(eigvals) * radius slope = eigvecs[1][0] / eigvecs[1][1] angle = 180.0 * np.arctan(slope) / np.pi plt.axes().add_artist(pat.Ellipse( mean, 2 * axis[0], 2 * axis[1], angle=angle, fill=False, color=color, linewidth=1, zorder=zorder ))
Example #4
Source File: tf_gmm.py From tf-example-models with Apache License 2.0 | 6 votes |
def plot_fitted_data(points, c_means, c_variances): """Plots the data and given Gaussian components""" plt.plot(points[:, 0], points[:, 1], "b.", zorder=0) plt.plot(c_means[:, 0], c_means[:, 1], "r.", zorder=1) for i in range(c_means.shape[0]): std = np.sqrt(c_variances[i]) plt.axes().add_artist(pat.Ellipse( c_means[i], 2 * std[0], 2 * std[1], fill=False, color="red", linewidth=2, zorder=1 )) plt.show() # PREPARING DATA # generating DATA_POINTS points from a GMM with COMPONENTS components
Example #5
Source File: triangle.py From AGNfitter with MIT License | 6 votes |
def error_ellipse(mu, cov, ax=None, factor=1.0, **kwargs): """ Plot the error ellipse at a point given its covariance matrix. """ # some sane defaults facecolor = kwargs.pop('facecolor', 'none') edgecolor = kwargs.pop('edgecolor', 'k') x, y = mu U, S, V = np.linalg.svd(cov) theta = np.degrees(np.arctan2(U[1, 0], U[0, 0])) ellipsePlot = Ellipse(xy=[x, y], width=2 * np.sqrt(S[0]) * factor, height=2 * np.sqrt(S[1]) * factor, angle=theta, facecolor=facecolor, edgecolor=edgecolor, **kwargs) if ax is None: ax = pl.gca() ax.add_patch(ellipsePlot) return ellipsePlot
Example #6
Source File: mpl_gui_selection.py From FRETBursts with GNU General Public License v2.0 | 6 votes |
def on_press(event): if event.inaxes != GSel.ax: return GSel.pressed = True GSel.xs, GSel.ys = event.xdata, event.ydata #print 'PRESS button=%d, x=%d, y=%d, xdata=%f, ydata=%f' % ( # event.button, event.x, event.y, event.xdata, event.ydata) if hasattr(GSel, 'r'): GSel.r.set_height(0); GSel.r.set_width(0) GSel.r.set_xy((GSel.xs,GSel.ys)) GSel.e.height = 0; GSel.e.width = 0 GSel.e.center = (GSel.xs,GSel.ys) else: GSel.r = Rectangle(xy=(GSel.xs,GSel.ys), height=0, width=0, fill=False, lw=2, alpha=0.6, color='blue') GSel.e = Ellipse(xy=(GSel.xs,GSel.ys), height=0, width=0, fill=False, lw=2, alpha=0.6, color='blue') GSel.ax.add_artist(GSel.r) GSel.r.set_clip_box(GSel.ax.bbox); GSel.r.set_zorder(10) GSel.ax.add_artist(GSel.e) GSel.e.set_clip_box(GSel.ax.bbox); GSel.e.set_zorder(10) GSel.fig.canvas.draw() GSel.id_motion = GSel.fig.canvas.mpl_connect('motion_notify_event', on_motion)
Example #7
Source File: gui_selection.py From FRETBursts with GNU General Public License v2.0 | 6 votes |
def on_press_draw(self): if 'r' in self.__dict__: self.r.set_height(0) self.r.set_width(0) self.r.set_xy((self.xs, self.ys)) self.e.height = 0 self.e.width = 0 self.e.center = (self.xs, self.ys) else: self.r = Rectangle(xy=(self.xs, self.ys), height=0, width=0, fill=False, lw=2, alpha=0.5, color='blue') self.e = Ellipse(xy=(self.xs, self.ys), height=0, width=0, fill=False, lw=2, alpha=0.6, color='blue') self.ax.add_artist(self.r) self.ax.add_artist(self.e) self.r.set_clip_box(self.ax.bbox) self.r.set_zorder(10) self.e.set_clip_box(self.ax.bbox) self.e.set_zorder(10)
Example #8
Source File: gmm_outlier.py From ad_examples with MIT License | 6 votes |
def make_ellipses(gmm, pl, colors): covariances = None for k in range(gmm.n_components): color = colors[k] # logger.debug("color: %s" % color) if gmm.covariance_type == 'full': covariances = gmm.covariances_[k][:2, :2] elif gmm.covariance_type == 'tied': covariances = gmm.covariances_[:2, :2] elif gmm.covariance_type == 'diag': covariances = np.diag(gmm.covariances_[k][:2]) elif gmm.covariance_type == 'spherical': covariances = np.eye(gmm.means_.shape[1]) * gmm.covariances_[k] # find the ellipse size and orientation w.r.t largest eigen value v, w = np.linalg.eigh(covariances) u = w[0] / np.linalg.norm(w[0]) # normalize direction of largest eigen value angle = np.arctan2(u[1], u[0]) # find direction of the vector with largest eigen value angle = 180 * angle / np.pi # convert to degrees v = 2. * np.sqrt(2.) * np.sqrt(v) ell = Ellipse(xy=gmm.means_[k, :2], width=v[0], height=v[1], angle=180 + angle, edgecolor=color, facecolor='none', linewidth=2) ell.set_clip_box(pl.bbox) # ell.set_alpha(0.5) # ell.set_facecolor('none') pl.add_artist(ell)
Example #9
Source File: canvas.py From CNNArt with Apache License 2.0 | 6 votes |
def set_selected(self, shape): self.deSelectShape() self.picked = True self.toggle_selector_ES.set_active(False) self.toggle_selector_RS.set_active(False) self.toggle_selector_LS.set_active(False) self.selectedShape = shape if type(self.selectedShape) is Rectangle or Ellipse: self.selectedShape.set_edgecolor('black') self.draw_idle() self.set_state(2) self.edit_selectedShape(self.selectedShape) elif type(self.selectedShape) is PathPatch: self.selectedShape.set_edgecolor('black') self.draw_idle() self.set_state(2) self.selectionChanged.emit(True)
Example #10
Source File: canvas.py From CNNArt with Apache License 2.0 | 6 votes |
def selectShape(self, event): self.deSelectShape() self.picked = True self.toggle_selector_ES.set_active(False) self.toggle_selector_RS.set_active(False) self.toggle_selector_LS.set_active(False) self.selectedShape = event.artist if type(self.selectedShape) is Rectangle or Ellipse: self.selectedShape.set_edgecolor('black') self.draw_idle() self.set_state(2) self.edit_selectedShape(self.selectedShape) elif type(self.selectedShape) is PathPatch: self.selectedShape.set_edgecolor('black') self.draw_idle() self.set_state(2) self.selectionChanged.emit(True)
Example #11
Source File: canvas.py From CNNArt with Apache License 2.0 | 6 votes |
def _edit_on_release(self, event): self.picked = False self.set_state(1) # turn off the rect animation property and reset the background self.to_draw.set_animated(False) try: canvas = self.to_draw.get_figure().canvas axes = self.to_draw.axes self.background = canvas.copy_from_bbox(self.selectedShape.axes.bbox) canvas.restore_region(self.background) axes.draw_artist(self.to_draw) axes.draw_artist(self._corner_handles.artist) axes.draw_artist(self._edge_handles.artist) axes.draw_artist(self._center_handle.artist) # blit just the redrawn area canvas.blit(axes.bbox) except: pass self.df = pandas.read_csv('Markings/marking_records.csv') if type(self.to_draw) is Rectangle or Ellipse: self.df.loc[self.selectind, 'artist'] = self.to_draw self.df.to_csv('Markings/marking_records.csv', index=False)
Example #12
Source File: canvas.py From CNNArt with Apache License 2.0 | 6 votes |
def ell_onselect(self, eclick, erelease): x1, y1 = eclick.xdata, eclick.ydata x2, y2 = erelease.xdata, erelease.ydata ell = Ellipse(xy=(min(x1, x2) + np.abs(x1 - x2) / 2, min(y1, y2) + np.abs(y1 - y2) / 2), width=np.abs(x1 - x2), height=np.abs(y1 - y2), alpha=.2, edgecolor=None) plist = np.ndarray.tolist(ell.get_path().vertices) plist = ', '.join(str(x) for x in plist) self.ax1.add_patch(ell) self.figure.canvas.draw() if self.mode == 1 or self.mode == 4 or self.mode == 7: onslice = 'Z %s' % (self.ind + 1) elif self.mode == 2 or self.mode == 5 or self.mode == 8: onslice = 'X %s' % (self.ind + 1) elif self.mode == 3 or self.mode == 6 or self.mode == 9: onslice = 'Y %s' % (self.ind + 1) self.df = pandas.read_csv('Markings/marking_records.csv') df_size = pandas.DataFrame.count(self.df) df_rows = df_size['artist'] self.df.loc[df_rows, 'artist'] = ell self.df.loc[df_rows, 'labelshape'] = 'ell' self.df.loc[df_rows, 'slice'] = onslice self.df.loc[df_rows, 'path'] = plist self.df.loc[df_rows, 'status'] = 0 self.df.to_csv('Markings/marking_records.csv', index=False)
Example #13
Source File: plot_grids.py From Splunking-Crime with GNU Affero General Public License v3.0 | 6 votes |
def _make_ellipse(mean, cov, ax, level=0.95, color=None): """Support function for scatter_ellipse.""" from matplotlib.patches import Ellipse v, w = np.linalg.eigh(cov) u = w[0] / np.linalg.norm(w[0]) angle = np.arctan(u[1]/u[0]) angle = 180 * angle / np.pi # convert to degrees v = 2 * np.sqrt(v * stats.chi2.ppf(level, 2)) #get size corresponding to level ell = Ellipse(mean[:2], v[0], v[1], 180 + angle, facecolor='none', edgecolor=color, #ls='dashed', #for debugging lw=1.5) ell.set_clip_box(ax.bbox) ell.set_alpha(0.5) ax.add_artist(ell)
Example #14
Source File: plot_utils.py From teachDeepRL with MIT License | 6 votes |
def draw_ellipse(position, covariance, ax=None, color=None, **kwargs): """Draw an ellipse with a given position and covariance""" ax = ax or plt.gca() covariance = covariance[0:2,0:2] position = position[0:2] # Convert covariance to principal axes if covariance.shape == (2, 2): U, s, Vt = np.linalg.svd(covariance) angle = np.degrees(np.arctan2(U[1, 0], U[0, 0])) width, height = 2 * np.sqrt(s) else: angle = 0 width, height = 2 * np.sqrt(covariance) # Draw the Ellipse for nsig in range(2, 3): ax.add_patch(Ellipse(position, nsig * width, nsig * height, angle, **kwargs, color=color))
Example #15
Source File: draw_sky2.py From Probabilistic-Programming-and-Bayesian-Methods-for-Hackers with MIT License | 6 votes |
def draw_sky( galaxies ): """adapted from Vishal Goklani""" size_multiplier = 45 fig = plt.figure(figsize=(10,10)) #fig.patch.set_facecolor("blue") ax = fig.add_subplot(111, aspect='equal') n = galaxies.shape[0] for i in xrange(n): _g = galaxies[i,:] x,y = _g[0], _g[1] d = np.sqrt( _g[2]**2 + _g[3]**2 ) a = 1.0/ ( 1 - d ) b = 1.0/( 1 + d) theta = np.degrees( np.arctan2( _g[3], _g[2])*0.5 ) ax.add_patch( Ellipse(xy=(x, y), width=size_multiplier*a, height=size_multiplier*b, angle=theta) ) ax.autoscale_view(tight=True) return fig
Example #16
Source File: dbscan.py From aggregation with Apache License 2.0 | 5 votes |
def avgEllipse(circles): avgX = sum([x for (x,y,h,w,r) in circles])/float(len(circles)) avgY = sum([y for (x,y,h,w,r) in circles])/float(len(circles)) avgHeight = sum([h for (x,y,h,w,r) in circles])/float(len(circles)) avgWidth = sum([w for (x,y,h,w,r) in circles])/float(len(circles)) avgRotation = sum([r for (x,y,h,w,r) in circles])/float(len(circles)) print ((avgX,avgY),avgHeight,avgWidth,avgRotation) return Ellipse((avgX,avgY),avgHeight,avgWidth,avgRotation)
Example #17
Source File: util.py From face-magnet with Apache License 2.0 | 5 votes |
def drawDef(dfeat, dy, dx, mindef=0.001, distr="father"): """ auxiliary funtion to draw recursive levels of deformation """ from matplotlib.patches import Ellipse pylab.ioff() if distr == "father": py = [0, 0, 2, 2] px = [0, 2, 0, 2] if distr == "child": py = [0, 1, 1, 2] px = [1, 2, 0, 1] ordy = [0, 0, 1, 1] ordx = [0, 1, 0, 1] x1 = -0.5 + dx x2 = 2.5 + dx y1 = -0.5 + dy y2 = 2.5 + dy if distr == "father": pylab.fill([x1, x1, x2, x2, x1], [y1, y2, y2, y1, y1], "r", alpha=0.15, edgecolor="b", lw=1) for l in range(len(py)): aux = dfeat[ordy[l], ordx[l], :].clip(-1, -mindef) wh = numpy.exp(-mindef / aux[0]) / numpy.exp(1) hh = numpy.exp(-mindef / aux[1]) / numpy.exp(1) e = Ellipse( xy=[(px[l] + dx), (py[l] + dy)], width=wh, height=hh, alpha=0.35) x1 = -0.75 + dx + px[l] x2 = 0.75 + dx + px[l] y1 = -0.76 + dy + py[l] y2 = 0.75 + dy + py[l] col = numpy.array([wh * hh] * 3).clip(0, 1) if distr == "father": col[0] = 0 e.set_facecolor(col) pylab.gca().add_artist(e) if distr == "father": pylab.fill([x1, x1, x2, x2, x1], [y1, y2, y2, y1, y1], "b", alpha=0.15, edgecolor="b", lw=1)
Example #18
Source File: test_axes.py From ImageFusion with MIT License | 5 votes |
def test_polar_coord_annotations(): # You can also use polar notation on a catesian axes. Here the # native coordinate system ('data') is cartesian, so you need to # specify the xycoords and textcoords as 'polar' if you want to # use (theta, radius) from matplotlib.patches import Ellipse el = Ellipse((0, 0), 10, 20, facecolor='r', alpha=0.5) fig = plt.figure() ax = fig.add_subplot(111, aspect='equal') ax.add_artist(el) el.set_clip_box(ax.bbox) ax.annotate('the top', xy=(np.pi/2., 10.), # theta, radius xytext=(np.pi/3, 20.), # theta, radius xycoords='polar', textcoords='polar', arrowprops=dict(facecolor='black', shrink=0.05), horizontalalignment='left', verticalalignment='baseline', clip_on=True, # clip to the axes bounding box ) ax.set_xlim(-20, 20) ax.set_ylim(-20, 20)
Example #19
Source File: spines.py From ImageFusion with MIT License | 5 votes |
def set_patch_line(self): """set the spine to be linear""" self._patch_type = 'line' # Behavior copied from mpatches.Ellipse:
Example #20
Source File: cluster.py From cmdbac with Apache License 2.0 | 5 votes |
def plot_cov_ellipse(cov, pos, nstd=2, ax=None, **kwargs): """ Plots an `nstd` sigma error ellipse based on the specified covariance matrix (`cov`). Additional keyword arguments are passed on to the ellipse patch artist. Parameters ---------- cov : The 2x2 covariance matrix to base the ellipse on pos : The location of the center of the ellipse. Expects a 2-element sequence of [x0, y0]. nstd : The radius of the ellipse in numbers of standard deviations. Defaults to 2 standard deviations. ax : The axis that the ellipse will be plotted on. Defaults to the current axis. Additional keyword arguments are pass on to the ellipse patch. Returns ------- A matplotlib ellipse artist """ def eigsorted(cov): vals, vecs = np.linalg.eigh(cov) order = vals.argsort()[::-1] return vals[order], vecs[:,order] if ax is None: ax = plt.gca() vals, vecs = eigsorted(cov) theta = np.degrees(np.arctan2(*vecs[:,0][::-1])) # Width and height are "full" widths, not radius width, height = 2 * nstd * np.sqrt(vals) ellip = Ellipse(xy=pos, width=width, height=height, angle=theta, **kwargs) ax.add_artist(ellip) return ellip,pos,width,height
Example #21
Source File: spines.py From CogAlg with MIT License | 5 votes |
def set_patch_line(self): """Set the spine to be linear.""" self._patch_type = 'line' self.stale = True # Behavior copied from mpatches.Ellipse:
Example #22
Source File: geom_dotplot.py From plotnine with GNU General Public License v2.0 | 5 votes |
def draw_group(data, panel_params, coord, ax, **params): data = coord.transform(data, panel_params) fill = to_rgba(data['fill'], data['alpha']) color = to_rgba(data['color'], data['alpha']) ranges = coord.range(panel_params) # For perfect circles the width/height of the circle(ellipse) # should factor in the dimensions of axes bbox = ax.get_window_extent().transformed( ax.figure.dpi_scale_trans.inverted()) ax_width, ax_height = bbox.width, bbox.height factor = ((ax_width/ax_height) * np.ptp(ranges.y)/np.ptp(ranges.x)) size = data.loc[0, 'binwidth'] * params['dotsize'] offsets = data['stackpos'] * params['stackratio'] if params['binaxis'] == 'x': width, height = size, size*factor xpos, ypos = data['x'], data['y'] + height*offsets elif params['binaxis'] == 'y': width, height = size/factor, size xpos, ypos = data['x'] + width*offsets, data['y'] circles = [] for xy in zip(xpos, ypos): patch = mpatches.Ellipse(xy, width=width, height=height) circles.append(patch) coll = mcoll.PatchCollection(circles, edgecolors=color, facecolors=fill) ax.add_collection(coll)
Example #23
Source File: spines.py From Computable with MIT License | 5 votes |
def __init__(self, axes, spine_type, path, **kwargs): """ - *axes* : the Axes instance containing the spine - *spine_type* : a string specifying the spine type - *path* : the path instance used to draw the spine Valid kwargs are: %(Patch)s """ super(Spine, self).__init__(**kwargs) self.axes = axes self.set_figure(self.axes.figure) self.spine_type = spine_type self.set_facecolor('none') self.set_edgecolor(rcParams['axes.edgecolor']) self.set_linewidth(rcParams['axes.linewidth']) self.axis = None self.set_zorder(2.5) self.set_transform(self.axes.transData) # default transform self._bounds = None # default bounds self._smart_bounds = False # Defer initial position determination. (Not much support for # non-rectangular axes is currently implemented, and this lets # them pass through the spines machinery without errors.) self._position = None assert isinstance(path, matplotlib.path.Path) self._path = path # To support drawing both linear and circular spines, this # class implements Patch behavior two ways. If # self._patch_type == 'line', behave like a mpatches.PathPatch # instance. If self._patch_type == 'circle', behave like a # mpatches.Ellipse instance. self._patch_type = 'line' # Behavior copied from mpatches.Ellipse: # Note: This cannot be calculated until this is added to an Axes self._patch_transform = mtransforms.IdentityTransform()
Example #24
Source File: canvas.py From CNNArt with Apache License 2.0 | 5 votes |
def mouse_release(self, event): if event.button == 1: if event.xdata is not None and event.ydata is not None: x = int(event.xdata) y = int(event.ydata) if self.mode > 3 and self.mode <= 6: try: pixel = self.total_mask[x, y, :] except: pixel = [0, 0, 0] pixel_color = matplotlib.colors.to_hex(pixel) color_hex = [] patch_color_df = pandas.read_csv('configGUI/patch_color.csv') count = patch_color_df['color'].count() for i in range(count): color_hex.append(matplotlib.colors.to_hex(patch_color_df.iloc[i]['color'])) try: ind = color_hex.index(str(pixel_color)) self.mask_class = patch_color_df.iloc[ind]['class'] except: pass if self.mask_class is not None and self.labelon: self.setToolTip(self.mask_class) if not self.labelon: self.setToolTip( 'Press Enter to choose label\nClick Rectangle or Ellipse to edit\nPress Delete to remove mark') else: if self.new_shape(): self.setToolTip(self.selectedshape_name) elif event.button == 2: self.wheel_clicked = False elif self.picked and event.button == 1: self._edit_on_release(event)
Example #25
Source File: canvas.py From CNNArt with Apache License 2.0 | 5 votes |
def _edit_on_press(self, event): self.pressEvent = event contains, attrd = self.selectedShape.contains(event) if not contains: return # draw everything but the selected rectangle and store the pixel buffer try: canvas = self.selectedShape.get_figure().canvas axes = self.selectedShape.axes self.to_draw.set_animated(True) canvas.draw() self.background = canvas.copy_from_bbox(self.selectedShape.axes.bbox) # canvas.restore_region(self.background) axes.draw_artist(self.to_draw) axes.draw_artist(self._corner_handles.artist) axes.draw_artist(self._edge_handles.artist) axes.draw_artist(self._center_handle.artist) # blit just the redrawn area canvas.blit(axes.bbox) except: pass self.df = pandas.read_csv('Markings/marking_records.csv') if type(self.to_draw) is Rectangle or Ellipse: self.df.loc[self.selectind, 'artist'] = self.to_draw self.df.to_csv('Markings/marking_records.csv', index=False)
Example #26
Source File: canvas.py From CNNArt with Apache License 2.0 | 5 votes |
def draw_shape(self, extents): if type(self.selectedShape) is Rectangle: x0, x1, y0, y1 = extents xmin, xmax = sorted([x0, x1]) ymin, ymax = sorted([y0, y1]) xlim = sorted(self.ax1.get_xlim()) ylim = sorted(self.ax1.get_ylim()) xmin = max(xlim[0], xmin) ymin = max(ylim[0], ymin) xmax = min(xmax, xlim[1]) ymax = min(ymax, ylim[1]) self.to_draw.set_x(xmin) self.to_draw.set_y(ymin) self.to_draw.set_width(xmax - xmin) self.to_draw.set_height(ymax - ymin) elif type(self.selectedShape) is Ellipse: x1, x2, y1, y2 = extents xmin, xmax = sorted([x1, x2]) ymin, ymax = sorted([y1, y2]) center = [x1 + (x2 - x1) / 2., y1 + (y2 - y1) / 2.] a = (xmax - xmin) / 2. b = (ymax - ymin) / 2. self.to_draw.center = center self.to_draw.width = 2 * a self.to_draw.height = 2 * b
Example #27
Source File: canvas.py From CNNArt with Apache License 2.0 | 5 votes |
def _rect_bbox(self): if type(self.selectedShape) is Rectangle: x0 = self.to_draw.get_x() y0 = self.to_draw.get_y() width = self.to_draw.get_width() height = self.to_draw.get_height() return x0, y0, width, height elif type(self.selectedShape) is Ellipse: x, y = self.to_draw.center width = self.to_draw.width height = self.to_draw.height return x - width / 2., y - height / 2., width, height
Example #28
Source File: spines.py From matplotlib-4-abaqus with MIT License | 5 votes |
def set_patch_line(self): """set the spine to be linear""" self._patch_type = 'line' # Behavior copied from mpatches.Ellipse:
Example #29
Source File: anchored_artists.py From Computable with MIT License | 5 votes |
def __init__(self, transform, width, height, angle, loc, pad=0.1, borderpad=0.1, prop=None, frameon=True, **kwargs): """ Draw an ellipse the size in data coordinate of the give axes. pad, borderpad in fraction of the legend font size (or prop) """ self._box = AuxTransformBox(transform) self.ellipse = Ellipse((0,0), width, height, angle) self._box.add_artist(self.ellipse) AnchoredOffsetbox.__init__(self, loc, pad=pad, borderpad=borderpad, child=self._box, prop=prop, frameon=frameon, **kwargs)
Example #30
Source File: venn.py From pyvenn with The Unlicense | 5 votes |
def draw_ellipse(fig, ax, x, y, w, h, a, fillcolor): e = patches.Ellipse( xy=(x, y), width=w, height=h, angle=a, color=fillcolor) ax.add_patch(e)