Ticket #3392: matplotlib-sage.3.patch

File matplotlib-sage.3.patch, 11.1 kB (added by jason, 5 months ago)

Apply instead of above

  • a/sage/plot/axes.py

    old new  
    245245        return oppaxis, step, tslminor, tslmajor  
    246246 
    247247    def _draw_axes(self, subplot, axes, xmin, xmax, ymin, ymax, x_axis_ypos, y_axis_xpos): 
    248         from matplotlib import patches 
     248        from matplotlib import lines 
    249249        if isinstance(axes, (list, tuple)) and len(axes) == 2 and \ 
    250250        (axes[0] in [True, False]) and (axes[1] in [True, False]):  
    251251            self.__draw_x_axis = axes[0] 
    252252            self.__draw_y_axis = axes[1] 
    253253            #draw the x-axes? 
    254254            if self.__draw_x_axis: 
    255                 subplot.add_line(patches.lines.Line2D([xmin, xmax], [x_axis_ypos, x_axis_ypos], 
     255                subplot.add_line(lines.Line2D([xmin, xmax], [x_axis_ypos, x_axis_ypos], 
    256256                                 color=self.__color, linewidth=float(self.__linewidth))) 
    257257            #draw y axis line? 
    258258            if self.__draw_y_axis: 
    259                 subplot.add_line(patches.lines.Line2D([y_axis_xpos, y_axis_xpos],[ymin, ymax], 
     259                subplot.add_line(lines.Line2D([y_axis_xpos, y_axis_xpos],[ymin, ymax], 
    260260                                  color=self.__color, linewidth=float(self.__linewidth))) 
    261261        else: #draw them both 
    262             subplot.add_line(patches.lines.Line2D([xmin, xmax], [x_axis_ypos, x_axis_ypos], 
     262            subplot.add_line(lines.Line2D([xmin, xmax], [x_axis_ypos, x_axis_ypos], 
    263263                             color=self.__color, linewidth=float(self.__linewidth))) 
    264             subplot.add_line(patches.lines.Line2D([y_axis_xpos, y_axis_xpos],[ymin, ymax], 
     264            subplot.add_line(lines.Line2D([y_axis_xpos, y_axis_xpos],[ymin, ymax], 
    265265                              color=self.__color, linewidth=float(self.__linewidth))) 
    266266 
    267267    def _draw_axes_labels(self, subplot, axes_labels, xmin, xmax, ymin, ymax, xstep, ystep, x_axis_ypos, y_axis_xpos, pad=0.2): 
     
    310310        xlabel : "where the xlabel is drawn"  
    311311 
    312312        """ 
    313         from matplotlib import patches 
     313        from matplotlib import lines 
    314314        xmin = float(xmin); xmax=float(xmax); ymin=float(ymin); ymax=float(ymax) 
    315315        yspan = ymax - ymin 
    316316        xspan = xmax - xmin 
     
    338338            s = self._format_tick_string(x) 
    339339            subplot.text(x, xlabel, s, fontsize=int(self.__fontsize), horizontalalignment="center",  
    340340                        color=self.__tick_label_color, verticalalignment="top") 
    341             subplot.add_line(patches.lines.Line2D([x, x], [x_axis_ypos, x_axis_ypos + xltheight], 
     341            subplot.add_line(lines.Line2D([x, x], [x_axis_ypos, x_axis_ypos + xltheight], 
    342342                        color=self.__color, linewidth=float(self.__linewidth))) 
    343343 
    344344        #now draw the x-axis minor tick marks 
    345345        for x in xtslminor: 
    346             subplot.add_line(patches.lines.Line2D([x, x], [x_axis_ypos, x_axis_ypos + xstheight], 
     346            subplot.add_line(lines.Line2D([x, x], [x_axis_ypos, x_axis_ypos + xstheight], 
    347347                        color=self.__color, linewidth=float(self.__linewidth))) 
    348348 
    349349        #the y-axis ticks and labels 
     
    354354            s = self._format_tick_string(y) 
    355355            subplot.text(ylabel, y, s, fontsize=int(self.__fontsize), verticalalignment="center", 
    356356                        color=self.__tick_label_color, horizontalalignment="right") 
    357             subplot.add_line(patches.lines.Line2D([y_axis_xpos, y_axis_xpos + yltheight], [y, y], 
     357            subplot.add_line(lines.Line2D([y_axis_xpos, y_axis_xpos + yltheight], [y, y], 
    358358                    color=self.__color, linewidth=float(self.__linewidth))) 
    359359             
    360360        #now draw the x-axis minor tick marks 
    361361        for y in ytslminor: 
    362             subplot.add_line(patches.lines.Line2D([y_axis_xpos, y_axis_xpos + ystheight], [y, y], 
     362            subplot.add_line(lines.Line2D([y_axis_xpos, y_axis_xpos + ystheight], [y, y], 
    363363                color=self.__color, linewidth=float(self.__linewidth))) 
    364364 
    365365        # now draw the x and y axis labels 
     
    375375        Draw a frame around a graphic at the given 
    376376        (scaled out) x and y min and max values. 
    377377        """ 
    378         from matplotlib import patches 
     378        from matplotlib import lines 
    379379        #border horizontal axis: 
    380380        #bottom: 
    381         subplot.add_line(patches.lines.Line2D([xmins, xmaxs], [ymins, ymins], 
     381        subplot.add_line(lines.Line2D([xmins, xmaxs], [ymins, ymins], 
    382382                                        color=self.__color, linewidth=float(self.__linewidth))) 
    383383        #top: 
    384         subplot.add_line(patches.lines.Line2D([xmins, xmaxs], [ymaxs, ymaxs], 
     384        subplot.add_line(lines.Line2D([xmins, xmaxs], [ymaxs, ymaxs], 
    385385                                        color=self.__color, linewidth=float(self.__linewidth))) 
    386386        #border vertical axis: 
    387387        #left: 
    388         subplot.add_line(patches.lines.Line2D([xmins, xmins], [ymins, ymaxs], 
     388        subplot.add_line(lines.Line2D([xmins, xmins], [ymins, ymaxs], 
    389389                                        color=self.__color, linewidth=float(self.__linewidth))) 
    390390        #right: 
    391         subplot.add_line(patches.lines.Line2D([xmaxs, xmaxs], [ymins, ymaxs], 
     391        subplot.add_line(lines.Line2D([xmaxs, xmaxs], [ymins, ymaxs], 
    392392                                        color=self.__color, linewidth=float(self.__linewidth))) 
    393393 
    394394 
     
    403403        centered axes with no tick marks. 
    404404 
    405405        """ 
    406         from matplotlib import patches 
     406        from matplotlib import lines 
    407407        xmin = float(xmin); xmax=float(xmax); ymin=float(ymin); ymax=float(ymax) 
    408408        yspan = ymax - ymin 
    409409        xspan = xmax - xmin 
     
    431431        #these are the centered axes, like in regular plot, but with no ticks 
    432432        if axes_with_no_ticks: 
    433433            #the x axis line 
    434             subplot.add_line(patches.lines.Line2D([xmins, xmaxs], [x_axis_ypos, x_axis_ypos], 
     434            subplot.add_line(lines.Line2D([xmins, xmaxs], [x_axis_ypos, x_axis_ypos], 
    435435                                            color=self.__color, linewidth=float(self.__linewidth))) 
    436436 
    437437            #the y axis line 
    438             subplot.add_line(patches.lines.Line2D([y_axis_xpos, y_axis_xpos],[ymins, ymaxs], 
     438            subplot.add_line(lines.Line2D([y_axis_xpos, y_axis_xpos],[ymins, ymaxs], 
    439439                                            color=self.__color, linewidth=float(self.__linewidth))) 
    440440            
    441441        #the x-axis ticks and labels 
     
    447447 
    448448        #now draw the x-axis minor tick marks 
    449449        for x in xtslminor: 
    450             subplot.add_line(patches.lines.Line2D([x, x], [ymins, xstheight + ymins], 
     450            subplot.add_line(lines.Line2D([x, x], [ymins, xstheight + ymins], 
    451451                        color=self.__color, linewidth=float(self.__linewidth))) 
    452             subplot.add_line(patches.lines.Line2D([x, x], [ymaxs, ymaxs - xstheight], 
     452            subplot.add_line(lines.Line2D([x, x], [ymaxs, ymaxs - xstheight], 
    453453                        color=self.__color, linewidth=float(self.__linewidth))) 
    454454 
    455455 
     
    462462             
    463463        #now draw the x-axis minor tick marks 
    464464        for y in ytslminor: 
    465             subplot.add_line(patches.lines.Line2D([xmins, ystheight + xmins], [y, y], 
     465            subplot.add_line(lines.Line2D([xmins, ystheight + xmins], [y, y], 
    466466                color=self.__color, linewidth=float(self.__linewidth))) 
    467             subplot.add_line(patches.lines.Line2D([xmaxs, xmaxs - ystheight], [y, y], 
     467            subplot.add_line(lines.Line2D([xmaxs, xmaxs - ystheight], [y, y], 
    468468                color=self.__color, linewidth=float(self.__linewidth))) 
    469469 
    470470    def _adjustments_for_frame(self, xmin, xmax, ymin, ymax): 
     
    501501        the ith row and jth column of the matrix. 
    502502 
    503503        """ 
    504         from matplotlib import patches 
     504        from matplotlib import lines 
    505505        xmax = int(xmax) 
    506506        ymax = int(ymax) 
    507507 
     
    558558                         horizontalalignment="center", verticalalignment="top") 
    559559            subplot.text(xr, -2*xlabel + ymaxs, s, fontsize=int(self.__fontsize), 
    560560                         horizontalalignment="center", verticalalignment="top") 
    561             subplot.add_line(patches.lines.Line2D([xr, xr], [ymins, xstheight + ymins], 
     561            subplot.add_line(lines.Line2D([xr, xr], [ymins, xstheight + ymins], 
    562562                        color=self.__color, linewidth=float(self.__linewidth))) 
    563             subplot.add_line(patches.lines.Line2D([xr, xr], [ymaxs, ymaxs - xstheight], 
     563            subplot.add_line(lines.Line2D([xr, xr], [ymaxs, ymaxs - xstheight], 
    564564                        color=self.__color, linewidth=float(self.__linewidth))) 
    565565                     
    566566        #the y-axis ticks and labels 
     
    571571                         verticalalignment="center", horizontalalignment="right") 
    572572            subplot.text(-2*ylabel + xmaxs, yr, s, fontsize=int(self.__fontsize),  
    573573                         verticalalignment="center", horizontalalignment="left") 
    574             subplot.add_line(patches.lines.Line2D([xmins, ystheight + xmins], [yr, yr], 
     574            subplot.add_line(lines.Line2D([xmins, ystheight + xmins], [yr, yr], 
    575575                color=self.__color, linewidth=float(self.__linewidth))) 
    576             subplot.add_line(patches.lines.Line2D([xmaxs, xmaxs - ystheight], [yr, yr], 
     576            subplot.add_line(lines.Line2D([xmaxs, xmaxs - ystheight], [yr, yr], 
    577577                color=self.__color, linewidth=float(self.__linewidth))) 
    578578 
    579579class GridLines(SageObject): 
     
    799799        xlines, ylines = new_gridlines 
    800800 
    801801        # draw the grid lines 
    802         from matplotlib import patches 
     802        from matplotlib import lines 
    803803        # horizontal lines 
    804804        for (yval, ykwds) in ylines: 
    805805            subplot.add_line( 
    806                     patches.lines.Line2D(points[0],[yval,yval],**ykwds) 
     806                    lines.Line2D(points[0],[yval,yval],**ykwds) 
    807807                    ) 
    808808        # vertical lines 
    809809        for (xval, xkwds) in xlines: 
    810810            subplot.add_line( 
    811                     patches.lines.Line2D([xval,xval],points[1],**xkwds) 
     811                    lines.Line2D([xval,xval],points[1],**xkwds) 
    812812                    ) 
    813813 
    814814    def _get_ticks_locations(self, interval, ticks="major"): 
  • a/sage/plot/plot.py

    old new  
    20592059        This implicitly calls this function: 
    20602060            sage: line([(1,2), (3,-4), (2, 5), (1,2)]) 
    20612061        """ 
    2062         import matplotlib.patches as patches 
     2062        import matplotlib.lines as lines 
    20632063        options = dict(self.options()) 
    20642064        del options['alpha'] 
    20652065        del options['thickness'] 
    20662066        del options['rgbcolor'] 
    2067         p = patches.lines.Line2D(self.xdata, self.ydata, **options) 
     2067        p = lines.Line2D(self.xdata, self.ydata, **options) 
    20682068        options = self.options() 
    20692069        a = float(options['alpha']) 
    20702070        p.set_alpha(a)