''' Created on May 15, 2017 @author: Bart ''' from serializable import Serializable class Plot(Serializable): def __init__(self, datasets, title=None, x=None, y=None, legend=None): self.title = title if x == None: x = Axis() self.x = x if y == None: y = Axis() self.y = y if legend == None: # we set legend to true in case of a multiplot where all legend entries are defined legend = len(datasets) > 1 and all(map(lambda d : d.legend, datasets)) self.legend = legend self.datasets = datasets class DataSet(Serializable): def __init__(self, datapoints, color=None, linestyle=None, legend=None): self.color = color self.linestyle = linestyle self.datapoints = datapoints self.legend = legend class DataPoint(Serializable): def __init__(self, x, y): self.x = x self.y = y class Color: # enumeration of all colors BLUE, GREEN, RED, CYAN, MAGENTA, YELLOW, BLACK, WHITE = ("blue", "green", "red", "cyan", "magenta", "yellow", "black", "white") class LineStyle: # enumeration of all line styles SOLID, DASHED, DASHDOT, DOTTED, PIXEL, POINT, CIRCLE, STAR, PLUS, X = ("solid", "dashed", "dashdot", "dotted", "pixel", "point", "circle", "star", "plus", "x") class Axis(Serializable): def __init__(self, name=None, unit=None, lim_low=None, lim_high=None): if not name: name = "" self.name = name if not unit: unit = "" self.unit = unit self.lim_low = lim_low self.lim_high = lim_high class XAxis(Axis): pass class YAxis(Axis): pass