Ticket #2236: plot_fix_endpoints.patch

File plot_fix_endpoints.patch, 1.4 KB (added by jason, 2 years ago)
  • sage/plot/plot.py

    # HG changeset patch
    # User Jason Grout <jason-sage@creativetrax.com>
    # Date 1203547569 21600
    # Node ID 1748eee29fc9653c165e5db933934f9461c66a70
    # Parent  8d54924196479b30c9b98d6da95e7ec76fab00f3
    imported patch plot_fix_endpoints.patch
    
    diff -r 8d5492419647 -r 1748eee29fc9 sage/plot/plot.py
    a b  
    33213321    We can change the line style to one of '--' (dashed), '-.' (dash dot), 
    33223322    '-' (solid), 'steps', ':' (dotted): 
    33233323        sage: plot(sin(x), 0, 10, linestyle='-.') 
     3324 
     3325    TESTS: 
     3326    We do not randomize the endpoints: 
     3327        sage: p = plot(x, (x,-1,1)) 
     3328        sage: p[0].xdata[0] == -1 
     3329        True 
     3330        sage: p[0].xdata[-1] == 1 
     3331        True 
     3332         
    33243333    """ 
    33253334    def _reset(self): 
    33263335        o = self.options 
     
    34023411        exceptions = 0; msg='' 
    34033412        for i in range(plot_points): 
    34043413            xi = xmin + i*delta 
    3405             if i < plot_points: 
     3414            # Slightly randomize points except for the first and last 
     3415            if i > 0 and i < plot_points-1: 
    34063416                xi += delta*random.random() 
    34073417                if xi > xmax: 
    34083418                    xi = xmax 
    3409             else: 
     3419            elif i == plot_points-1:  
    34103420                xi = xmax  # guarantee that we get the last point. 
    34113421                 
    34123422            try: