Changeset 87cc73a in sasview for src/sas/qtgui/PlotUtilities.py


Ignore:
Timestamp:
Jan 11, 2017 9:31:58 AM (7 years ago)
Author:
Piotr Rozyczko <rozyczko@…>
Branches:
ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc
Children:
db5cd8d
Parents:
b46f285
Message:

Added Modify Plot Properties functionality. SASVIEW-169

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/qtgui/PlotUtilities.py

    r9290b1a r87cc73a  
    11import sys 
    22import numpy 
    3  
     3from collections import OrderedDict 
     4 
     5SHAPES = OrderedDict([ 
     6        ('Circle' , 'o'), 
     7        ('Point' , '.'), 
     8        ('Pixel' , ','), 
     9        ('Triangle Down' , 'v'), 
     10        ('Triangle Up' , '^'), 
     11        ('Triangle Left' , '<'), 
     12        ('Triangle Right' , '>'), 
     13        ('Octagon' , '8'), 
     14        ('Square' , 's'), 
     15        ('Pentagon' , 'p'), 
     16        ('Star' , '*'), 
     17        ('Hexagon1' , 'h'), 
     18        ('Hexagon2' , 'H'), 
     19        ('Cross +' , 'p'), 
     20        ('Cross X ' , 'x'), 
     21        ('Diamond' , 'D'), 
     22        ('Thin Diamond' , 'd'), 
     23        ('Line' , '-'), 
     24        ('Dash' , '--'), 
     25        ('Vline' , 'vline'), 
     26        ('Step' , 'step'), 
     27]) 
     28 
     29COLORS = OrderedDict([ 
     30        ('Blue', 'b'), 
     31        ('Green', 'g'), 
     32        ('Red', 'r'), 
     33        ('Cyan', 'c'), 
     34        ('Magenta', 'm'), 
     35        ('Yellow', 'y'), 
     36        ('Black', 'k'), 
     37        ('Custom', 'x'), 
     38]) 
    439 
    540def build_matrix(data, qx_data, qy_data): 
     
    5792        if loop >= max_loop:  # this protects never-ending loop 
    5893            break 
    59         image = fillup_pixels(image=image, weights=weights) 
     94        image = fillupPixels(image=image, weights=weights) 
    6095        loop += 1 
    6196 
     
    108143    return x_bins, y_bins 
    109144 
    110 def fillup_pixels(image=None, weights=None): 
     145def fillupPixels(image=None, weights=None): 
    111146    """ 
    112147    Fill z values of the empty cells of 2d image matrix 
     
    221256    return (lo, hi) 
    222257 
     258def getValidColor(color): 
     259    ''' 
     260    Returns a valid matplotlib color 
     261    ''' 
     262 
     263    if color is not None: 
     264        # Check if it's an int 
     265        if isinstance(color, int): 
     266            # Check if it's within the range 
     267            if 0 <= color <=6: 
     268                color = COLORS.values()[color] 
     269        # Check if it's an RGB string 
     270        elif isinstance(color, str): 
     271            # Assure the correctnes of the string 
     272            assert(color[0]=="#" and len(color) == 7) 
     273            import string 
     274            assert(all(c in string.hexdigits for c in color[1:])) 
     275        else: 
     276            raise AttributeError 
     277 
     278    return color 
Note: See TracChangeset for help on using the changeset viewer.