def build_color_table(colorL, ncol=6, show_full_name=False, hex_only=False): start_table() for i, c in enumerate(colorL): if i == 0: start_row() hexstr = getValidHexStr(c, c) start_cell(bgcolor=hexstr) c_best = get_best_gray_text(hexstr)[0] if not hex_only: add_text(c, color=c_best, br=True) if show_full_name: c_full = VERY_SHORT_NAME_DICT[c] add_text(c_full, color=c_best, br=True) add_text(hexstr, color=c_best, br=False) end_cell() if i % ncol == ncol - 1: end_row() start_row() if i % ncol != ncol - 1: end_row() end_table()
def build_color_table( colorL, ncol=6, show_full_name=False, hex_only=False ): start_table() for i,c in enumerate(colorL): if i == 0: start_row() hexstr = getValidHexStr(c, c) start_cell(bgcolor=hexstr) c_best = get_best_gray_text( hexstr )[0] if not hex_only: add_text(c, color=c_best, br=True) if show_full_name: c_full = VERY_SHORT_NAME_DICT[c] add_text(c_full, color=c_best, br=True) add_text(hexstr, color=c_best, br=False) end_cell() if i % ncol == ncol-1: end_row() start_row() if i % ncol != ncol-1: end_row() end_table()
def add_to_secondary_y(self, data_sheetname, xcol, ycol2L, showMarker2L=None, showLine2L=None, lineThk2L=None, lineStyle2L=None, color2L=None, label2L=None): """ Add new curves to primary y axis """ if ycol2L is None: return # self.color2L will always be None 1st time through if self.color2L is None: self.color2L = [] self.label2L = [] self.showMarker2L = [] self.markerType2L = [] self.showLine2L = [] self.lineThk2L = [] self.lineStyle2L = [] self.markerHtWd2L = [] self.ycol2L = [] self.xcol2L = [] self.ycol2_DataSheetNameL = [] # Fill attribute lists with input list values for i,ycol in enumerate(ycol2L): self.ycol2L.append( ycol ) self.xcol2L.append( xcol ) self.ycol2_DataSheetNameL.append( data_sheetname ) # See if there's an input color c_inp = get_ith_value( color2L, i, None ) c_palette = self.get_next_color() c = getValidHexStr( c_inp, c_palette) self.color2L.append( c ) self.markerType2L.append( self.get_next_symbol_type() ) self.label2L.append( get_ith_value( label2L, i, None ) ) if len(self.showMarker2L): self.showMarker2L.append( get_ith_value( showMarker2L, i, self.showMarker2L[-1] ) ) else: self.showMarker2L.append( get_ith_value( showMarker2L, i, True ) ) if len(self.showLine2L): self.showLine2L.append( get_ith_value( showLine2L, i, self.showLine2L[-1] ) ) else: self.showLine2L.append( get_ith_value( showLine2L, i, True ) ) # first get number into line thickness if len(self.lineThk2L): # remember that this holds strings like: "2.5mm" self.lineThk2L.append( get_ith_value( lineThk2L, i, self.lineThk2L[-1][:-2] ) ) else: self.lineThk2L.append( get_ith_value( lineThk2L, i, 0.8 ) ) # then convert to mm try: v = float(self.lineThk2L[-1]) self.markerHtWd2L.append("%gmm"%(v*3,)) self.lineThk2L[-1] = "%gmm"%v except: self.markerHtWd2L.append("%2.4mm") self.lineThk2L[-1] = "0.8mm" # Set line style to solid unless otherwise indicated if len(self.lineStyle2L): self.lineStyle2L.append( get_ith_value( lineStyle2L, i, self.lineStyle2L[-1] ) ) else: self.lineStyle2L.append( get_ith_value( lineStyle2L, i, 0 ) ) # include all y curves (primary and secondary) in set_of_line_styles self.set_of_line_styles.update( set(self.lineStyle2L) ) self.set_of_line_styles.discard(0) # Make sure that 0 does not appear
def add_to_secondary_y(self, data_sheetname, xcol, ycol2L, showMarker2L=None, showLine2L=None, lineThk2L=None, lineStyle2L=None, color2L=None, label2L=None): """ Add new curves to primary y axis """ if ycol2L is None: return # self.color2L will always be None 1st time through if self.color2L is None: self.color2L = [] self.label2L = [] self.showMarker2L = [] self.markerType2L = [] self.showLine2L = [] self.lineThk2L = [] self.lineStyle2L = [] self.markerHtWd2L = [] self.ycol2L = [] self.xcol2L = [] self.ycol2_DataSheetNameL = [] # Fill attribute lists with input list values for i, ycol in enumerate(ycol2L): self.ycol2L.append(ycol) self.xcol2L.append(xcol) self.ycol2_DataSheetNameL.append(data_sheetname) # See if there's an input color c_inp = get_ith_value(color2L, i, None) c_palette = self.get_next_color() c = getValidHexStr(c_inp, c_palette) self.color2L.append(c) self.markerType2L.append(self.get_next_symbol_type()) self.label2L.append(get_ith_value(label2L, i, None)) if len(self.showMarker2L): self.showMarker2L.append( get_ith_value(showMarker2L, i, self.showMarker2L[-1])) else: self.showMarker2L.append(get_ith_value(showMarker2L, i, True)) if len(self.showLine2L): self.showLine2L.append( get_ith_value(showLine2L, i, self.showLine2L[-1])) else: self.showLine2L.append(get_ith_value(showLine2L, i, True)) # first get number into line thickness if len(self.lineThk2L ): # remember that this holds strings like: "2.5mm" self.lineThk2L.append( get_ith_value(lineThk2L, i, self.lineThk2L[-1][:-2])) else: self.lineThk2L.append(get_ith_value(lineThk2L, i, 0.8)) # then convert to mm try: v = float(self.lineThk2L[-1]) self.markerHtWd2L.append("%gmm" % (v * 3, )) self.lineThk2L[-1] = "%gmm" % v except: self.markerHtWd2L.append("%2.4mm") self.lineThk2L[-1] = "0.8mm" # Set line style to solid unless otherwise indicated if len(self.lineStyle2L): self.lineStyle2L.append( get_ith_value(lineStyle2L, i, self.lineStyle2L[-1])) else: self.lineStyle2L.append(get_ith_value(lineStyle2L, i, 0)) # include all y curves (primary and secondary) in set_of_line_styles self.set_of_line_styles.update(set(self.lineStyle2L)) self.set_of_line_styles.discard( 0) # Make sure that 0 does not appear