Python matplotlib.pyplot.Circle() Examples
The following are 30
code examples of matplotlib.pyplot.Circle().
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.pyplot
, or try the search function
.
Example #1
Source File: _helpers.py From quadpy with GNU General Public License v3.0 | 7 votes |
def plot(self, show_axes=False): import matplotlib.pyplot as plt ax = plt.gca() # change default range so that new disks will work ax.axis("equal") ax.set_xlim((-1.5, 1.5)) ax.set_ylim((-1.5, 1.5)) if not show_axes: ax.set_axis_off() disk1 = plt.Circle((0, 0), 1, color="k", fill=False) ax.add_artist(disk1) # The total area is used to gauge the disk radii. This is only meaningful for 2D # manifolds, not for the circle. What we do instead is choose the total_area # such that the sum of the disk radii equals pi. total_area = numpy.pi ** 3 / len(self.weights) plot_disks(plt, self.points, self.weights, total_area)
Example #2
Source File: visualize.py From Hands-on-Neuroevolution-with-Python with MIT License | 6 votes |
def _draw_maze_(maze_env, ax): """ The function to draw maze environment Arguments: maze_env: The maze environment configuration. ax: The figure axis instance """ # draw maze walls for wall in maze_env.walls: line = plt.Line2D((wall.a.x, wall.b.x), (wall.a.y, wall.b.y), lw=1.5) ax.add_line(line) # draw start point start_circle = plt.Circle((maze_env.agent.location.x, maze_env.agent.location.y), radius=2.5, facecolor=(0.6, 1.0, 0.6), edgecolor='w') ax.add_patch(start_circle) # draw exit point exit_circle = plt.Circle((maze_env.exit_point.x, maze_env.exit_point.y), radius=2.5, facecolor=(1.0, 0.2, 0.0), edgecolor='w') ax.add_patch(exit_circle)
Example #3
Source File: style_sheets_reference.py From python3_ios with BSD 3-Clause "New" or "Revised" License | 6 votes |
def plot_colored_circles(ax, prng, nb_samples=15): """Plot circle patches. NB: draws a fixed amount of samples, rather than using the length of the color cycle, because different styles may have different numbers of colors. """ for sty_dict, j in zip(plt.rcParams['axes.prop_cycle'], range(nb_samples)): ax.add_patch(plt.Circle(prng.normal(scale=3, size=2), radius=1.0, color=sty_dict['color'])) # Force the limits to be the same across the styles (because different # styles may have different numbers of available colors). ax.set_xlim([-4, 8]) ax.set_ylim([-5, 6]) ax.set_aspect('equal', adjustable='box') # to plot circles as circles return ax
Example #4
Source File: chicken.py From multimodal_varinf with MIT License | 6 votes |
def __init__(self,to_plot = True): self.state = np.array([0,0]) self.observation_shape = np.shape(self.get_state())[0] if to_plot: plt.ion() fig = plt.figure() ax1 = fig.add_subplot(111,aspect='equal') #ax1.axis('off') plt.xlim([-0.5,5.5]) plt.ylim([-0.5,5.5]) self.g1 = ax1.add_artist(plt.Circle((self.state[0],self.state[1]),0.1,color='red')) self.fig = fig self.ax1 = ax1 self.fig.canvas.draw() self.fig.canvas.flush_events()
Example #5
Source File: PlotMatplotlib.py From Grid2Op with Mozilla Public License 2.0 | 6 votes |
def _draw_topos_one_sub(self, fig, sub_id, buses_z, elements, bus_vect): fig, ax = fig res_sub = [] # I plot the buses for bus_id, z_bus in enumerate(buses_z): bus_color = '#ff7f0e' if bus_id == 0 else '#1f77b4' bus_circ = plt.Circle((z_bus.real, z_bus.imag), self.bus_radius, color=bus_color, fill=True) ax.add_artist(bus_circ) # i connect every element to the proper bus with the proper color for el_nm, dict_el in elements.items(): this_el_bus = bus_vect[dict_el["sub_pos"]] -1 if this_el_bus >= 0: color = '#ff7f0e' if this_el_bus == 0 else '#1f77b4' ax.plot([buses_z[this_el_bus].real, dict_el["z"].real], [ buses_z[this_el_bus].imag, dict_el["z"].imag], color=color, alpha=self.alpha_obj) return []
Example #6
Source File: PlotMatplotlib.py From Grid2Op with Mozilla Public License 2.0 | 6 votes |
def _draw_topos_one_sub(self, fig, sub_id, buses_z, elements, bus_vect): fig, ax = fig res_sub = [] # I plot the buses for bus_id, z_bus in enumerate(buses_z): bus_color = '#ff7f0e' if bus_id == 0 else '#1f77b4' bus_circ = plt.Circle((z_bus.real, z_bus.imag), self.bus_radius, color=bus_color, fill=True) ax.add_artist(bus_circ) # i connect every element to the proper bus with the proper color for el_nm, dict_el in elements.items(): this_el_bus = bus_vect[dict_el["sub_pos"]] -1 if this_el_bus >= 0: color = '#ff7f0e' if this_el_bus == 0 else '#1f77b4' ax.plot([buses_z[this_el_bus].real, dict_el["z"].real], [ buses_z[this_el_bus].imag, dict_el["z"].imag], color=color, alpha=self.alpha_obj) return []
Example #7
Source File: visualize.py From Hands-on-Neuroevolution-with-Python with MIT License | 6 votes |
def _draw_maze_(maze_env, ax): """ The function to draw maze environment Arguments: maze_env: The maze environment configuration. ax: The figure axis instance """ # draw maze walls for wall in maze_env.walls: line = plt.Line2D((wall.a.x, wall.b.x), (wall.a.y, wall.b.y), lw=1.5) ax.add_line(line) # draw start point start_circle = plt.Circle((maze_env.agent.location.x, maze_env.agent.location.y), radius=2.5, facecolor=(0.6, 1.0, 0.6), edgecolor='w') ax.add_patch(start_circle) # draw exit point exit_circle = plt.Circle((maze_env.exit_point.x, maze_env.exit_point.y), radius=2.5, facecolor=(1.0, 0.2, 0.0), edgecolor='w') ax.add_patch(exit_circle)
Example #8
Source File: test_figure.py From tensorboardX with MIT License | 6 votes |
def test_figure(self): writer = SummaryWriter() figure, axes = plt.figure(), plt.gca() circle1 = plt.Circle((0.2, 0.5), 0.2, color='r') circle2 = plt.Circle((0.8, 0.5), 0.2, color='g') axes.add_patch(circle1) axes.add_patch(circle2) plt.axis('scaled') plt.tight_layout() writer.add_figure("add_figure/figure", figure, 0, close=False) assert plt.fignum_exists(figure.number) is True writer.add_figure("add_figure/figure", figure, 1) assert plt.fignum_exists(figure.number) is False writer.close()
Example #9
Source File: pendulum.py From kusanagi with MIT License | 6 votes |
def __init__(self, pendulum_plant, refresh_period=(1.0/240), name='PendulumDraw'): super(PendulumDraw, self).__init__(pendulum_plant, refresh_period, name) l = self.plant.l m = self.plant.m self.mass_r = 0.05*np.sqrt(m) # distance to corner of bounding box self.center_x = 0 self.center_y = 0 # initialize the patches to draw the pendulum self.pole_line = plt.Line2D((self.center_x, 0), (self.center_y, l), lw=2, c='r') self.mass_circle = plt.Circle((0, l), self.mass_r, fc='y')
Example #10
Source File: visualize.py From Hands-on-Neuroevolution-with-Python with MIT License | 6 votes |
def _draw_maze_(maze_env, ax): """ The function to draw maze environment Arguments: maze_env: The maze environment configuration. ax: The figure axis instance """ # draw maze walls for wall in maze_env.walls: line = plt.Line2D((wall.a.x, wall.b.x), (wall.a.y, wall.b.y), lw=1.5) ax.add_line(line) # draw start point start_circle = plt.Circle((maze_env.agent.location.x, maze_env.agent.location.y), radius=2.5, facecolor=(0.6, 1.0, 0.6), edgecolor='w') ax.add_patch(start_circle) # draw exit point exit_circle = plt.Circle((maze_env.exit_point.x, maze_env.exit_point.y), radius=2.5, facecolor=(1.0, 0.2, 0.0), edgecolor='w') ax.add_patch(exit_circle)
Example #11
Source File: _helpers.py From quadpy with GNU General Public License v3.0 | 6 votes |
def plot(self, show_axes=False): import matplotlib.pyplot as plt ax = plt.gca() # change default range so that new disks will work plt.axis("equal") ax.set_xlim((-1.5, 1.5)) ax.set_ylim((-1.5, 1.5)) if not show_axes: ax.set_axis_off() disk1 = plt.Circle((0, 0), 1, color="k", fill=False) ax.add_artist(disk1) plot_disks(plt, self.points, self.weights, numpy.pi) return
Example #12
Source File: coil.py From freegs with GNU Lesser General Public License v3.0 | 6 votes |
def plot(self, axis=None, show=False): """ Plot the coil location, using axis if given The area of the coil is used to set the radius """ minor_radius = np.sqrt(self.area / np.pi) import matplotlib.pyplot as plt if axis is None: fig = plt.figure() axis = fig.add_subplot(111) circle = plt.Circle((self.R, self.Z), minor_radius, color='b') axis.add_artist(circle) return axis
Example #13
Source File: cartpole.py From kusanagi with MIT License | 5 votes |
def init_artists(self): plt.figure(self.name) # initialize the patches to draw the cartpole l = self.plant.l cart_xy = (self.center_x-0.5*self.cart_h, self.center_y-0.125*self.cart_h) self.cart_rect = plt.Rectangle(cart_xy, self.cart_h, 0.25*self.cart_h, facecolor='black') self.pole_line = plt.Line2D((self.center_x, 0), (self.center_y, l), lw=2, c='r') self.mass_circle = plt.Circle((0, l), self.mass_r, fc='y') self.ax.add_patch(self.cart_rect) self.ax.add_patch(self.mass_circle) self.ax.add_line(self.pole_line)
Example #14
Source File: step3.py From mexican-government-report with MIT License | 5 votes |
def plot_donut(df): """Generates a donut plot with the counts of 3 categories. Parameters ---------- df : pandas.DataFrame The DataFrame to be plotted. """ # We will only need 3 categories and 3 values. labels = ["Positivo", "Negativo", "Neutro"] positive = len(df[df["score"] > 0]) negative = len(df[df["score"] < 0]) neutral = len(df[df["score"] == 0]) values = [positive, negative, neutral] colors = ["green", "orange", "yellow"] explode = (0, 0, 0) # Explode a slice if required plt.rcParams["font.size"] = 18 plt.rcParams["legend.fontsize"] = 20 plt.pie(values, explode=explode, labels=None, colors=colors, autopct='%1.1f%%', shadow=False) # We draw a circle in the Pie chart to make it a donut chart. centre_circle = plt.Circle( (0, 0), 0.75, color="#5C0E10", fc="#5C0E10", linewidth=0) fig = plt.gcf() fig.gca().add_artist(centre_circle) plt.axis("equal") plt.legend(labels) plt.savefig("donut.png", facecolor="#5C0E10")
Example #15
Source File: via_fill.py From kicad_mmccoo with Apache License 2.0 | 5 votes |
def add_via_at_pt(board, net, pt, viadiameter): x,y = pt for xother,yother in added: if np.hypot(x-xother, y-yother) < viadiameter: #print("{},{} and {},{} have distance of {}".format(x,y,xother,yother,np.hypot(x-xother, y-yother))) return if showplot: ax.add_artist(plt.Circle((x,y), viadiameter/2)) create_via(board, net, (x,y)) added.append((x,y)) # this fun takes a bunch of lines and converts to a boundary with holes # seems like there'd be a standard way to do this. I haven't found it.
Example #16
Source File: multi_robot_plot.py From multi_agent_path_planning with MIT License | 5 votes |
def plot_robot(robot, timestep, radius=1, is_obstacle=False): if robot is None: return center = robot[:2, timestep] x = center[0] y = center[1] if is_obstacle: circle = plt.Circle((x, y), radius, color='aqua', ec='black') plt.plot(robot[0, :timestep], robot[1, :timestep], '--r',) else: circle = plt.Circle((x, y), radius, color='green', ec='black') plt.plot(robot[0, :timestep], robot[1, :timestep], 'blue') plt.gcf().gca().add_artist(circle)
Example #17
Source File: figures.py From ESAC-stats-2014 with BSD 2-Clause "Simplified" License | 5 votes |
def plot_venn_diagram(): fig, ax = plt.subplots(subplot_kw=dict(frameon=False, xticks=[], yticks=[])) ax.add_patch(plt.Circle((0.3, 0.3), 0.3, fc='red', alpha=0.5)) ax.add_patch(plt.Circle((0.6, 0.3), 0.3, fc='blue', alpha=0.5)) ax.add_patch(plt.Rectangle((-0.1, -0.1), 1.1, 0.8, fc='none', ec='black')) ax.text(0.2, 0.3, '$x$', size=30, ha='center', va='center') ax.text(0.7, 0.3, '$y$', size=30, ha='center', va='center') ax.text(0.0, 0.6, '$I$', size=30) ax.axis('equal')
Example #18
Source File: test_patches.py From coffeegrindsize with MIT License | 5 votes |
def test_patch_color_none(): # Make sure the alpha kwarg does not override 'none' facecolor. # Addresses issue #7478. c = plt.Circle((0, 0), 1, facecolor='none', alpha=1) assert c.get_facecolor()[0] == 0
Example #19
Source File: test_figure.py From coffeegrindsize with MIT License | 5 votes |
def test_add_artist(fig_test, fig_ref): fig_test.set_dpi(100) fig_ref.set_dpi(100) ax = fig_test.subplots() l1 = plt.Line2D([.2, .7], [.7, .7], gid='l1') l2 = plt.Line2D([.2, .7], [.8, .8], gid='l2') r1 = plt.Circle((20, 20), 100, transform=None, gid='C1') r2 = plt.Circle((.7, .5), .05, gid='C2') r3 = plt.Circle((4.5, .8), .55, transform=fig_test.dpi_scale_trans, facecolor='crimson', gid='C3') for a in [l1, l2, r1, r2, r3]: fig_test.add_artist(a) l2.remove() ax2 = fig_ref.subplots() l1 = plt.Line2D([.2, .7], [.7, .7], transform=fig_ref.transFigure, gid='l1', zorder=21) r1 = plt.Circle((20, 20), 100, transform=None, clip_on=False, zorder=20, gid='C1') r2 = plt.Circle((.7, .5), .05, transform=fig_ref.transFigure, gid='C2', zorder=20) r3 = plt.Circle((4.5, .8), .55, transform=fig_ref.dpi_scale_trans, facecolor='crimson', clip_on=False, zorder=20, gid='C3') for a in [l1, r1, r2, r3]: ax2.add_artist(a)
Example #20
Source File: figures.py From MachineLearning with BSD 3-Clause "New" or "Revised" License | 5 votes |
def plot_venn_diagram(): fig, ax = plt.subplots(subplot_kw=dict(frameon=False, xticks=[], yticks=[])) ax.add_patch(plt.Circle((0.3, 0.3), 0.3, fc='red', alpha=0.5)) ax.add_patch(plt.Circle((0.6, 0.3), 0.3, fc='blue', alpha=0.5)) ax.add_patch(plt.Rectangle((-0.1, -0.1), 1.1, 0.8, fc='none', ec='black')) ax.text(0.2, 0.3, '$x$', size=30, ha='center', va='center') ax.text(0.7, 0.3, '$y$', size=30, ha='center', va='center') ax.text(0.0, 0.6, '$I$', size=30) ax.axis('equal')
Example #21
Source File: test_offset.py From beziers.py with MIT License | 5 votes |
def not_a_test_offset(self): b = DotMap({ "closed": False, "nodes": [ {"x": 412.0, "y":500.0, "type":"line"}, {"x": 308.0, "y":665.0, "type":"offcurve"}, {"x": 163.0, "y":589.0, "type":"offcurve"}, {"x": 163.0, "y":504.0, "type":"curve"}, {"x": 163.0, "y":424.0, "type":"offcurve"}, {"x": 364.0, "y":321.0, "type":"offcurve"}, {"x": 366.0, "y":216.0, "type":"curve"}, {"x": 368.0, "y":94.0, "type":"offcurve"}, {"x": 260.0, "y":54.0, "type":"offcurve"}, {"x": 124.0, "y":54.0, "type":"curve"} ]}) path = BezierPath() path.activeRepresentation = GSPathRepresentation(path,b) import matplotlib.pyplot as plt fig, ax = plt.subplots() path.addExtremes() path.plot(ax) for n in path.asSegments(): p = n.tunniPoint if p: circle = plt.Circle((p.x, p.y), 1, fill=False, color="blue") ax.add_artist(circle) n.balance() path.translate(Point(5,5)) path.plot(ax, color="red") # o1 = path.offset(Point(10,10)) # o2 = path.offset(Point(-10,-10)) # o2.reverse() # o1.append(o2) # o1.plot(ax) plt.show()
Example #22
Source File: mpc_class.py From GP-MPC with MIT License | 5 votes |
def plot_eig(A, discrete=True): """ Plot eigenvelues # Arguments: A: System matrix (N x N). # Optional Arguments: discrete: If true the unit circle is added to the plot. # Returns: eigenvalues: Eigenvelues of the matrix A. """ eigenvalues, eigenvec = scipy.linalg.eig(A) fig,ax = plt.subplots() ax.axhline(y=0, color='k', linestyle='--') ax.axvline(x=0, color='k', linestyle='--') ax.scatter(eigenvalues.real, eigenvalues.imag) if discrete: ax.add_artist(plt.Circle((0,0), 1, color='g', alpha=.1)) plt.ylim([min(-1, min(eigenvalues.imag)), max(1, max(eigenvalues.imag))]) plt.xlim([min(-1, min(eigenvalues.real)), max(1, max(eigenvalues.real))]) plt.gca().set_aspect('equal', adjustable='box') fig.canvas.set_window_title('Eigenvalues of linearized system') plt.show() return eigenvalues
Example #23
Source File: grid.py From multimodal_varinf with MIT License | 5 votes |
def plot(self): self.g1.remove() self.g2.remove() self.p.remove() # replot self.g1 = self.ax1.add_artist(plt.Circle(self.ghost1+0.5,0.3,color='red')) self.g2 = self.ax1.add_artist(plt.Circle(self.ghost2+0.5,0.3,color='blue')) self.p = self.ax1.add_artist(plt.Circle(self.pacman +0.5,0.3,color='yellow')) self.fig.canvas.draw()
Example #24
Source File: count.py From Pic-Numero with MIT License | 5 votes |
def main(): numberOfImages = 11; # TODO: AUTOMATICALLY GET NUMBER OF IMAGES # Get number of images. Remeber to divide by 2 as for every relevant image, # theres also the comparison image. # if ".DS_Store" in os.listdir("Wheat_ROIs"): # numberOfImages = (len(os.listdir("Wheat_ROIs")) - 1)/2; # else: # numberOfImages = len(os.listdir("Wheat_ROIs"))/2; # For each ROI image in folder for i in tqdm.tqdm(range(1, numberOfImages+1)): # Load image filename = "../Wheat_ROIs/{:03d}_ROI.png".format(i); img = misc.imread(filename); img_gray = rgb2gray(img); # Detect blobs. See http://scikit-image.org/docs/dev/api/skimage.feature.html#skimage.feature.blob_doh # for function documentation blobs = blob_doh(img_gray, min_sigma=1, max_sigma=100, threshold=.01) # Display blobs on image and save image fig, ax = plt.subplots() plt.title("Number of Blobs Detected: {}".format(blobs.shape[0])) plt.grid(False) ax.imshow(img, interpolation='nearest') for blob in blobs: y, x, r = blob c = plt.Circle((x, y), r, color='red', linewidth=2, fill=False) ax.add_patch(c) fig.savefig("../Wheat_ROIs/{:03d}_Blob.png".format(i))
Example #25
Source File: gui_utils.py From segmentator with BSD 3-Clause "New" or "Revised" License | 5 votes |
def findVoxInHist(self, event): """Find voxel's location in histogram.""" self.press = event.xdata, event.ydata pixel_x = int(np.floor(event.xdata)) pixel_y = int(np.floor(event.ydata)) aoi = self.invHistVolume[:, :, self.sliceNr] # array of interest # Check rotation cyc_rot = self.cycRotHistory[self.cycleCount][1] if cyc_rot == 1: # 90 aoi = np.rot90(aoi, axes=(0, 1)) elif cyc_rot == 2: # 180 aoi = aoi[::-1, ::-1] elif cyc_rot == 3: # 270 aoi = np.rot90(aoi, axes=(1, 0)) # Switch x and y voxel to get linear index since not Cartesian!!! pixelLin = aoi[pixel_y, pixel_x] # ind2sub xpix = (pixelLin / self.nrBins) ypix = (pixelLin % self.nrBins) # Switch x and y for circle centre since back to Cartesian. circle_colors = [np.array([8, 48, 107, 255])/255, np.array([33, 113, 181, 255])/255] self.highlights[0].append(plt.Circle((ypix, xpix), radius=1, edgecolor=None, color=circle_colors[0])) self.highlights[1].append(plt.Circle((ypix, xpix), radius=5, edgecolor=None, color=circle_colors[1])) self.axes.add_artist(self.highlights[0][-1]) # small circle self.axes.add_artist(self.highlights[1][-1]) # large circle self.figure.canvas.draw()
Example #26
Source File: double_cartpole.py From kusanagi with MIT License | 5 votes |
def __init__(self, double_cartpole_plant, refresh_period=(1.0/240), name='DoubleCartpoleDraw'): super(DoubleCartpoleDraw, self).__init__(double_cartpole_plant, refresh_period, name) m1 = self.plant.m1 m2 = self.plant.m2 M = self.plant.M l1 = self.plant.l1 l2 = self.plant.l2 self.body_h = 0.5*np.sqrt(m1) self.mass_r1 = 0.05*np.sqrt(m2) # distance to corner of bounding box self.mass_r2 = 0.05*np.sqrt(M) # distance to corner of bounding box self.center_x = 0 self.center_y = 0 # initialize the patches to draw the cartpole self.body_rect = plt.Rectangle((self.center_x - 0.5*self.body_h, self.center_y - 0.125*self.body_h), self.body_h, 0.25*self.body_h, facecolor='black') self.pole_line1 = plt.Line2D((self.center_x, 0), (self.center_y, l1), lw=2, c='r') self.mass_circle1 = plt.Circle((0, l1), self.mass_r1, fc='y') self.pole_line2 = plt.Line2D((self.center_x, 0), (l1, l2), lw=2, c='r') self.mass_circle2 = plt.Circle((0, l1+l2), self.mass_r2, fc='y')
Example #27
Source File: plot.py From quadpy with GNU General Public License v3.0 | 5 votes |
def _plot_disks_helpers(plt, pts, radii, colors): for pt, radius, color in zip(pts, radii, colors): # highlight circle center plt.plot([pt[0]], [pt[1]], linestyle="None", marker=".", color=color) # Choose radius such that the sum of areas of the circles equals total_area. # Make sure to set the line width to 0, # <https://github.com/matplotlib/matplotlib/issues/17421>. circ = plt.Circle((pt[0], pt[1]), radius, color=color, alpha=0.5, linewidth=0) plt.gca().add_artist(circ)
Example #28
Source File: bezier_curve.py From RacingRobot with MIT License | 5 votes |
def main(show_animation): cp = demo_cp rx, ry, ryaw, rk = calcTrajectory(cp, 100) t = 0.8 x_target, y_target = bezier(t, cp) derivatives_cp = bezierDerivativesControlPoints(cp, 2) point = bezier(t, cp) dt = bezier(t, derivatives_cp[1]) ddt = bezier(t, derivatives_cp[2]) cu = curvature(dt[0], dt[1], ddt[0], ddt[1]) # Normalize derivative dt /= np.linalg.norm(dt, 2) tangent = np.array([point, point + dt]) normal = np.array([point, point + [- dt[1], dt[0]]]) # Radius of curvature r = 1 / cu curvature_center = point + np.array([- dt[1], dt[0]]) * r circle = plt.Circle(tuple(curvature_center), r, color=(0, 0.8, 0.8), fill=False, linewidth=1) if show_animation: # pragma: no cover fig, ax = plt.subplots() ax.plot(rx, ry, label="Bezier Path") ax.plot(cp.T[0], cp.T[1], '--o', label="Control Points") ax.plot(x_target, y_target, '--o', label="Target Point") ax.plot(tangent[:, 0], tangent[:, 1], label="Tangent") ax.plot(normal[:, 0], normal[:, 1], label="Normal") ax.add_artist(circle) ax.legend() ax.axis("equal") ax.grid(True) plt.show()
Example #29
Source File: figures.py From sklearn_pydata2015 with BSD 3-Clause "New" or "Revised" License | 5 votes |
def plot_venn_diagram(): fig, ax = plt.subplots(subplot_kw=dict(frameon=False, xticks=[], yticks=[])) ax.add_patch(plt.Circle((0.3, 0.3), 0.3, fc='red', alpha=0.5)) ax.add_patch(plt.Circle((0.6, 0.3), 0.3, fc='blue', alpha=0.5)) ax.add_patch(plt.Rectangle((-0.1, -0.1), 1.1, 0.8, fc='none', ec='black')) ax.text(0.2, 0.3, '$x$', size=30, ha='center', va='center') ax.text(0.7, 0.3, '$y$', size=30, ha='center', va='center') ax.text(0.0, 0.6, '$I$', size=30) ax.axis('equal')
Example #30
Source File: hive_plot.py From pynoddy with GNU General Public License v2.0 | 5 votes |
def plot_nodes(self, ax): '''Draws the nodes on the specified axis **Arguments**: - *ax* = the index of the axis to draw ''' assert ax < len(self.nodes), "This plot has only %d axes (starting from 0)" % len(self.nodes) for i,node in enumerate(self.nodes[ax]): #calculate normalized node value (between 0 and 1) if not self.node_positions is None: v = (self.node_positions[ax][node] - self.min_v[ax]) / float(self.max_v[ax] - self.min_v[ax]) else: v = i / float(self.max_v[ax]) #calculate radius (distance along axis) & angle r = self.internal_radius + v * self.axis_lengths[ax] theta = self.axis_theta(ax) #calculate coordinates x, y = get_cartesian(r, theta) #calculate node colour c = self.node_colormap[ax][node] #plot circle = plt.Circle(xy=(x,y), radius=self.dot_radius, color=c, linewidth=0) self.ax.add_patch(circle)