Ticket #9491: trac-9491-contour-alpha.patch

File trac-9491-contour-alpha.patch, 2.6 KB (added by jason, 9 years ago)
  • sage/plot/contour_plot.py

    # HG changeset patch
    # User Jason Grout <jason-sage@creativetrax.com>
    # Date 1279032277 25200
    # Node ID 3d26f4ce24cdd6ed77476768c2cf815c26fdb6ad
    # Parent  e54053c166c7b830562f39d51cc24ba518b67344
    #9491: Add opacity argument to contour plotting
    
    diff -r e54053c166c7 -r 3d26f4ce24cd sage/plot/contour_plot.py
    a b  
    120120                'linestyles':'the style of the lines to be plotted',
    121121                'labels':'show line labels or not',
    122122                'label_options':'a dictionary of options for the labels',
    123                 'zorder':'The layer level in which to draw'}
     123                'zorder':'The layer level in which to draw',
     124                'opacity':'The opacity of the plot'}
    124125
    125126    def _repr_(self):
    126127        """
     
    147148        from sage.rings.integer import Integer
    148149        options = self.options()
    149150        fill = options['fill']
     151        opacity = options.get('opacity', None)
    150152        contours = options['contours']
    151153        if options.has_key('cmap'):
    152154            cmap = get_cmap(options['cmap'])
     
    168170        CSF=None
    169171        if fill:
    170172            if contours is None:
    171                 CSF=subplot.contourf(self.xy_data_array, cmap=cmap, extent=(x0,x1,y0,y1))
     173                CSF=subplot.contourf(self.xy_data_array, cmap=cmap, extent=(x0,x1,y0,y1), alpha=opacity)
    172174            else:
    173                 CSF=subplot.contourf(self.xy_data_array, contours, cmap=cmap, extent=(x0,x1,y0,y1),extend='both')
     175                CSF=subplot.contourf(self.xy_data_array, contours, cmap=cmap, extent=(x0,x1,y0,y1),extend='both', alpha=opacity)
    174176
    175177        linewidths = options.get('linewidths',None)
    176178        if isinstance(linewidths, (int, Integer)):
     
    180182        linestyles = options.get('linestyles',None)
    181183        if contours is None:
    182184            CS = subplot.contour(self.xy_data_array, cmap=cmap, extent=(x0,x1,y0,y1),
    183                                  linewidths=linewidths, linestyles=linestyles)
     185                                 linewidths=linewidths, linestyles=linestyles, alpha=opacity)
    184186        else:
    185187            CS = subplot.contour(self.xy_data_array, contours, cmap=cmap, extent=(x0,x1,y0,y1),
    186                             linewidths=linewidths, linestyles=linestyles)
     188                            linewidths=linewidths, linestyles=linestyles, alpha=opacity)
    187189        if options.get('labels', False):
    188190            label_options = options['label_options']
    189191            label_options['fontsize'] = int(label_options['fontsize'])