def __init__(self, line, fig): gtk.Dialog.__init__(self, 'Line Properties') self.fig = fig self.line = line table = gtk.Table(3, 2) table.show() table.set_row_spacings(4) table.set_col_spacings(4) table.set_homogeneous(True) self.vbox.pack_start(table, gtk.TRUE, gtk.TRUE) row = 0 label = gtk.Label('linewidth') label.show() entry = gtk.Entry() entry.show() entry.set_text(str(line.get_linewidth())) self.entryLineWidth = entry table.attach(label, 0, 1, row, row + 1, xoptions=gtk.FALSE, yoptions=gtk.FALSE) table.attach(entry, 1, 2, row, row + 1, xoptions=gtk.TRUE, yoptions=gtk.FALSE) row += 1 self.rgbLine = colorConverter.to_rgb(self.line.get_color()) def set_color(button): rgb = get_color(self.rgbLine) if rgb is not None: self.rgbLine = rgb label = gtk.Label('color') label.show() button = gtk.Button(stock=gtk.STOCK_SELECT_COLOR) button.show() button.connect('clicked', set_color) table.attach(label, 0, 1, row, row + 1, xoptions=gtk.FALSE, yoptions=gtk.FALSE) table.attach(button, 1, 2, row, row + 1, xoptions=gtk.TRUE, yoptions=gtk.FALSE) row += 1 ## line styles label = gtk.Label('linestyle') label.show() thisStyle = line.get_linestyle() styles = [thisStyle] for key in lineStyles.keys(): if key == thisStyle: continue styles.append(key) self.menuLineStyle, self.menuLineStyleItemd = make_option_menu(styles) table.attach(label, 0, 1, row, row + 1, xoptions=gtk.FALSE, yoptions=gtk.FALSE) table.attach(self.menuLineStyle, 1, 2, row, row + 1, xoptions=gtk.TRUE, yoptions=gtk.FALSE) row += 1 ## marker label = gtk.Label('marker') label.show() keys = lineMarkers.keys() keys.append('None') marker = line.get_marker() if marker is None: marker = 'None' styles = [marker] for key in keys: if key == marker: continue styles.append(key) self.menuMarker, self.menuMarkerItemd = make_option_menu(styles) table.attach(label, 0, 1, row, row + 1, xoptions=gtk.FALSE, yoptions=gtk.FALSE) table.attach(self.menuMarker, 1, 2, row, row + 1, xoptions=gtk.TRUE, yoptions=gtk.FALSE) row += 1 self.add_button(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL) self.add_button(gtk.STOCK_APPLY, gtk.RESPONSE_APPLY) self.add_button(gtk.STOCK_OK, gtk.RESPONSE_OK)
def __init__(self, line, fig): gtk.Dialog.__init__(self, 'Line Properties') self.fig = fig self.line = line table = gtk.Table(3,2) table.show() table.set_row_spacings(4) table.set_col_spacings(4) table.set_homogeneous(True) self.vbox.pack_start(table, gtk.TRUE, gtk.TRUE) row = 0 label = gtk.Label('linewidth') label.show() entry = gtk.Entry() entry.show() entry.set_text(str(line.get_linewidth())) self.entryLineWidth = entry table.attach(label, 0, 1, row, row+1, xoptions=gtk.FALSE, yoptions=gtk.FALSE) table.attach(entry, 1, 2, row, row+1, xoptions=gtk.TRUE, yoptions=gtk.FALSE) row += 1 self.rgbLine = colorConverter.to_rgb(self.line.get_color()) def set_color(button): rgb = get_color(self.rgbLine) if rgb is not None: self.rgbLine = rgb label = gtk.Label('color') label.show() button = gtk.Button(stock=gtk.STOCK_SELECT_COLOR) button.show() button.connect('clicked', set_color) table.attach(label, 0, 1, row, row+1, xoptions=gtk.FALSE, yoptions=gtk.FALSE) table.attach(button, 1, 2, row, row+1, xoptions=gtk.TRUE, yoptions=gtk.FALSE) row += 1 ## line styles label = gtk.Label('linestyle') label.show() thisStyle = line.get_linestyle() styles = [thisStyle] for key in lineStyles.keys(): if key == thisStyle: continue styles.append(key) self.menuLineStyle, self.menuLineStyleItemd = make_option_menu(styles) table.attach(label, 0, 1, row, row+1, xoptions=gtk.FALSE, yoptions=gtk.FALSE) table.attach(self.menuLineStyle, 1, 2, row, row+1, xoptions=gtk.TRUE, yoptions=gtk.FALSE) row += 1 ## marker label = gtk.Label('marker') label.show() keys = lineMarkers.keys() keys.append('None') marker = line.get_marker() if marker is None: marker = 'None' styles = [marker] for key in keys: if key == marker: continue styles.append(key) self.menuMarker, self.menuMarkerItemd = make_option_menu(styles) table.attach(label, 0, 1, row, row+1, xoptions=gtk.FALSE, yoptions=gtk.FALSE) table.attach(self.menuMarker, 1, 2, row, row+1, xoptions=gtk.TRUE, yoptions=gtk.FALSE) row += 1 self.add_button(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL) self.add_button(gtk.STOCK_APPLY, gtk.RESPONSE_APPLY) self.add_button(gtk.STOCK_OK, gtk.RESPONSE_OK)
from xml.etree import ElementTree from matplotlib.axes._subplots import SubplotBase from matplotlib.cm import get_cmap from matplotlib.lines import lineStyles, lineMarkers import matplotlib.pyplot as plt from ..commonlib.collection_util import flatten, indices, XYRanges, zip_check, zip_shorten_latter from ..commonlib.option import map_option, option_or from ..commonlib.type_utils import check_cast, T, with_slots from ..commonlib.util import change_extension, ensure_dir, get_command_line, remove_str_end # TODO: add more styles if necessary # Solid, dashed with dots, dotted LINE_STYLES: Sequence[str] = ["-", "-.", ":"] assert all(l in lineStyles.keys() for l in LINE_STYLES) def _get_marker_styles() -> Sequence[str]: first_four = ( ".", "x", # triangle_up, "^", # pentagon "p") assert all(m in lineMarkers.keys() for m in first_four) return (*first_four, *(m for m in lineMarkers if m not in first_four)) _MARKER_STYLES: Sequence[str] = _get_marker_styles()