def get_circle_points_list(x, y, circles): poly_data_points = [] # x , y e' il primo punto cell retta # per generare i secondi punti della circonferenza uso circle point_circle = circle.circle(x, y, 1.0) second_points = point_circle.generate_circle_points(NUMOFCIRCLEPOINTS) #print len(second_points) for pi in second_points: l = line.line2d() l.set_two_point([x, y], pi) ref_quadrant = get_quadrant_respect_to(pi, [x, y]) #print "quadrant: ", ref_quadrant closet_point = [x, y] closet_point_min_d = float("inf") for cir in circles: int_points = circle.line_circle_intersection(cir, l) selected_point = [x, y] min_distance = float("inf") for ip in int_points: if (get_quadrant_respect_to(ip, [x, y]) == ref_quadrant): d = point_distance(ip, [x, y]) if (d > 0.0): if (d < min_distance): min_distance = d selected_point = ip d = point_distance(selected_point, [x, y]) if d > 0.0: if (d < closet_point_min_d): closet_point_min_d = d closet_point = selected_point if point_distance(closet_point, [x, y]) > 0.0: poly_data_points.append(closet_point) return poly_data_points
def _render_on_subplot(self, subplot): """ TESTS:: sage: matrix_plot(random_matrix(RDF, 50), cmap='jet') """ options = self.options() cmap = get_cmap(options.pop('cmap', None)) origin = options['origin'] norm = options['norm'] if norm == 'value': import matplotlib norm = matplotlib.colors.NoNorm() if options['subdivisions']: subdiv_options = options['subdivision_options'] if isinstance(subdiv_options['boundaries'], (list, tuple)): rowsub, colsub = subdiv_options['boundaries'] else: rowsub = subdiv_options['boundaries'] colsub = subdiv_options['boundaries'] if isinstance(subdiv_options['style'], (list, tuple)): rowstyle, colstyle = subdiv_options['style'] else: rowstyle = subdiv_options['style'] colstyle = subdiv_options['style'] if rowstyle is None: rowstyle = dict() if colstyle is None: colstyle = dict() # Make line objects for subdivisions from line import line2d lim = self.get_minmax_data() # First draw horizontal lines representing row subdivisions for y in rowsub: l = line2d([(lim['xmin'], y - 0.5), (lim['xmax'], y - 0.5)], **rowstyle)[0] l._render_on_subplot(subplot) for x in colsub: l = line2d([(x - 0.5, lim['ymin']), (x - 0.5, lim['ymax'])], **colstyle)[0] l._render_on_subplot(subplot) if hasattr(self.xy_data_array, 'tocoo'): # Sparse matrix -- use spy opts = options.copy() for opt in [ 'vmin', 'vmax', 'norm', 'origin', 'subdivisions', 'subdivision_options', 'colorbar', 'colorbar_options' ]: del opts[opt] if origin == 'lower': subplot.spy(self.xy_data_array.tocsr()[::-1], **opts) else: subplot.spy(self.xy_data_array, **opts) else: opts = dict(cmap=cmap, interpolation='nearest', aspect='equal', norm=norm, vmin=options['vmin'], vmax=options['vmax'], origin=origin, zorder=options.get('zorder', None)) image = subplot.imshow(self.xy_data_array, **opts) if options.get('colorbar', False): colorbar_options = options['colorbar_options'] from matplotlib import colorbar cax, kwds = colorbar.make_axes_gridspec( subplot, **colorbar_options) cb = colorbar.Colorbar(cax, image, **kwds) if origin == 'upper': subplot.xaxis.tick_top() elif origin == 'lower': subplot.xaxis.tick_bottom() subplot.xaxis.set_ticks_position( 'both') #only tick marks, not tick labels
def _render_on_subplot(self, subplot): """ TESTS:: sage: matrix_plot(random_matrix(RDF, 50), cmap='jet') Graphics object consisting of 1 graphics primitive """ options = self.options() cmap = get_cmap(options.pop('cmap',None)) origin=options['origin'] norm=options['norm'] if norm=='value': import matplotlib norm=matplotlib.colors.NoNorm() if options['subdivisions']: subdiv_options=options['subdivision_options'] if isinstance(subdiv_options['boundaries'], (list, tuple)): rowsub,colsub=subdiv_options['boundaries'] else: rowsub=subdiv_options['boundaries'] colsub=subdiv_options['boundaries'] if isinstance(subdiv_options['style'], (list, tuple)): rowstyle,colstyle=subdiv_options['style'] else: rowstyle=subdiv_options['style'] colstyle=subdiv_options['style'] if rowstyle is None: rowstyle=dict() if colstyle is None: colstyle=dict() # Make line objects for subdivisions from line import line2d lim=self.get_minmax_data() # First draw horizontal lines representing row subdivisions for y in rowsub: l=line2d([(lim['xmin'],y-0.5), (lim['xmax'],y-0.5)], **rowstyle)[0] l._render_on_subplot(subplot) for x in colsub: l=line2d([(x-0.5, lim['ymin']), (x-0.5, lim['ymax'])], **colstyle)[0] l._render_on_subplot(subplot) if hasattr(self.xy_data_array, 'tocoo'): # Sparse matrix -- use spy opts=options.copy() for opt in ['vmin', 'vmax', 'norm', 'origin','subdivisions','subdivision_options', 'colorbar','colorbar_options']: del opts[opt] if origin=='lower': subplot.spy(self.xy_data_array.tocsr()[::-1], **opts) else: subplot.spy(self.xy_data_array, **opts) else: opts = dict(cmap=cmap, interpolation='nearest', aspect='equal', norm=norm, vmin=options['vmin'], vmax=options['vmax'], origin=origin,zorder=options.get('zorder',None)) image=subplot.imshow(self.xy_data_array, **opts) if options.get('colorbar', False): colorbar_options = options['colorbar_options'] from matplotlib import colorbar cax,kwds=colorbar.make_axes_gridspec(subplot,**colorbar_options) cb=colorbar.Colorbar(cax,image, **kwds) if origin=='upper': subplot.xaxis.tick_top() elif origin=='lower': subplot.xaxis.tick_bottom() subplot.xaxis.set_ticks_position('both') #only tick marks, not tick labels
def _render_on_subplot(self, subplot): """ TESTS:: sage: matrix_plot(random_matrix(RDF, 50), cmap='jet') """ options = self.options() cmap = get_cmap(options.pop("cmap", None)) origin = options["origin"] norm = options["norm"] if norm == "value": import matplotlib norm = matplotlib.colors.NoNorm() if options["subdivisions"]: subdiv_options = options["subdivision_options"] if isinstance(subdiv_options["boundaries"], (list, tuple)): rowsub, colsub = subdiv_options["boundaries"] else: rowsub = subdiv_options["boundaries"] colsub = subdiv_options["boundaries"] if isinstance(subdiv_options["style"], (list, tuple)): rowstyle, colstyle = subdiv_options["style"] else: rowstyle = subdiv_options["style"] colstyle = subdiv_options["style"] if rowstyle is None: rowstyle = dict() if colstyle is None: colstyle = dict() # Make line objects for subdivisions from line import line2d lim = self.get_minmax_data() # First draw horizontal lines representing row subdivisions for y in rowsub: l = line2d([(lim["xmin"], y - 0.5), (lim["xmax"], y - 0.5)], **rowstyle)[0] l._render_on_subplot(subplot) for x in colsub: l = line2d([(x - 0.5, lim["ymin"]), (x - 0.5, lim["ymax"])], **colstyle)[0] l._render_on_subplot(subplot) if hasattr(self.xy_data_array, "tocoo"): # Sparse matrix -- use spy opts = options.copy() for opt in [ "vmin", "vmax", "norm", "origin", "subdivisions", "subdivision_options", "colorbar", "colorbar_options", ]: del opts[opt] if origin == "lower": subplot.spy(self.xy_data_array.tocsr()[::-1], **opts) else: subplot.spy(self.xy_data_array, **opts) else: opts = dict( cmap=cmap, interpolation="nearest", aspect="equal", norm=norm, vmin=options["vmin"], vmax=options["vmax"], origin=origin, zorder=options.get("zorder", None), ) image = subplot.imshow(self.xy_data_array, **opts) if options.get("colorbar", False): colorbar_options = options["colorbar_options"] from matplotlib import colorbar cax, kwds = colorbar.make_axes_gridspec(subplot, **colorbar_options) cb = colorbar.Colorbar(cax, image, **kwds) if origin == "upper": subplot.xaxis.tick_top() elif origin == "lower": subplot.xaxis.tick_bottom() subplot.xaxis.set_ticks_position("both") # only tick marks, not tick labels