def xyplot(x, y, xlabel="x axis", ylabel="y axis", title="title", legend="legend", color="red", symbol=None, gridy=1, gridx=0): """ xyplot(x,y,xlabel="x axis", ylabel="y axis", title = "title", legend = "legend", color = "red", symbol = None, gridy = 1, gridx = 0): uses vista's graphing capabilities to draw a simple line plot between x and y """ ds = DefaultDataSet('', x, y) crv1 = CurveFactory.createCurve(ds, AxisAttr.BOTTOM, AxisAttr.LEFT, legend) crv1.attributes._drawLines = 1 cc = cmap[color] if not cc: crv1.foregroundColor = Color.red else: crv1.foregroundColor = cc if symbol: crv1.drawSymbol = 1 crv1.symbol = symMap[symbol] leg = Legend() li1 = LegendItem(crv1) pl = Plot() pl.add(crv1) laxis = pl.getAxis(AxisAttr.LEFT) if laxis: laxis.setAxisLabel(ylabel) baxis = pl.getAxis(AxisAttr.BOTTOM) if baxis: baxis.setAxisLabel(xlabel) pl.add(leg) pl.addTitle(title) if gridy: pl.addGrid(AxisAttr.LEFT) if gridx: pl.addGrid(AxisAttr.BOTTOM) return pl
def addXYCurveToPlot(plot, x, y, color="red", legend="", symbol=None): """ xycurve(x,y,color = "red", symbol = None): uses vista's graphing capabilities to draw a simple line plot between x and y """ ds = DefaultDataSet('', x, y) crv1 = CurveFactory.createCurve(ds, AxisAttr.BOTTOM, AxisAttr.LEFT, legend) crv1.attributes._drawLines = 1 cc = cmap[color] if not cc: crv1.foregroundColor = Color.red else: crv1.foregroundColor = cc if symbol: crv1.drawSymbol = 1 crv1.symbol = symMap[symbol] leg = Legend() li1 = LegendItem(crv1) plot.add(crv1)
def addXYCurveToPlot(plot,x,y,color = "red", legend="", symbol = None): """ xycurve(x,y,color = "red", symbol = None): uses vista's graphing capabilities to draw a simple line plot between x and y """ ds = DefaultDataSet('',x,y) crv1 = CurveFactory.createCurve(ds,AxisAttr.BOTTOM, AxisAttr.LEFT, legend) crv1.attributes._drawLines = 1 cc = cmap[color] if not cc: crv1.foregroundColor = Color.red else: crv1.foregroundColor = cc if symbol: crv1.drawSymbol = 1 crv1.symbol = symMap[symbol] leg = Legend() li1 = LegendItem(crv1) plot.add(crv1)
def xyplot(x,y, xlabel="x axis", ylabel="y axis", title = "title", legend = "legend", color = "red", symbol = None, gridy = 1, gridx = 0): """ xyplot(x,y,xlabel="x axis", ylabel="y axis", title = "title", legend = "legend", color = "red", symbol = None, gridy = 1, gridx = 0): uses vista's graphing capabilities to draw a simple line plot between x and y """ ds = DefaultDataSet('',x,y) crv1 = CurveFactory.createCurve(ds,AxisAttr.BOTTOM, AxisAttr.LEFT, legend) crv1.attributes._drawLines = 1 cc = cmap[color] if not cc: crv1.foregroundColor = Color.red else: crv1.foregroundColor = cc if symbol: crv1.drawSymbol = 1 crv1.symbol = symMap[symbol] leg = Legend() li1 = LegendItem(crv1) pl = Plot() pl.add(crv1) laxis = pl.getAxis(AxisAttr.LEFT) if laxis: laxis.setAxisLabel(ylabel) baxis = pl.getAxis(AxisAttr.BOTTOM) if baxis: baxis.setAxisLabel(xlabel) pl.add(leg) pl.addTitle(title) if gridy: pl.addGrid(AxisAttr.LEFT) if gridx: pl.addGrid(AxisAttr.BOTTOM) return pl
g2.filterBy('BOTH') amplsb = [] for i in range(3): chan = repr(i+1) amplsb.append(getAmplitude("00"+chan+"_0", g2)); # do alternative CHAN g2 = g.clone() g2.filterBy('DMS\+CHAN') # escape + character in reg exp amplsc = [] for i in range(3): chan = repr(i+1) amplsc.append(getAmplitude("00"+chan+"_0", g2)); # ds_both = DefaultDataSet('stage profiles (BOTH)',[1,2,3],amplsb); ds_chan = DefaultDataSet('stage profiles (CHAN)',[1,2,3],amplsc); crv_both = CurveFactory.createCurve(DefaultReference(ds_both),AxisAttr.BOTTOM, AxisAttr.LEFT, 'stage profile (BOTH)') crv_chan = CurveFactory.createCurve(DefaultReference(ds_chan),AxisAttr.BOTTOM, AxisAttr.LEFT, 'stage profile (CHAN)') crv_both.lineThickness=2; crv_both.foregroundColor=Color.blue; crv_both.drawLines=1; crv_chan.lineThickness=2; crv_chan.foregroundColor=Color.green; crv_chan.drawLines=1; crv_both.symbol.foregroundColor=Color.blue crv_chan.symbol.foregroundColor=Color.green legend = Legend(); legend.add(LegendItem(crv_both)); legend.add(LegendItem(crv_chan)); plot = Plot(); plot.add(crv_both); plot.add(crv_chan); plot.addLegend(legend, AxisAttr.LEFT) plot.addTitle("Stage Profiles BOTH vs CHAN"); plot.getAxis(AxisAttr.BOTTOM).setDCRange(0,4); plot.getAxis(AxisAttr.LEFT).setDCRange(5.,6.5);
# open the first file , filter for station+stage and get the first reference g1 = opendss(file1) g1.filterBy(station+'/STAGE'); ref1 = DataReference.create(g1[0],tw) # get the second reference from second file. Again filter by station+stage and get the # first reference. Not clean but that's not the context of the example here... g2 = opendss(file2) g2.filterBy(station+'/stage'); ref2 = DataReference.create(g2[0],tw) # initialize an empty plot plot0 = Plot(); # create a legend for both curves l1text= 'STAGE at ' +station + ' (DWR-OSP-DMS+1C) (Base Case)' l2text= 'STAGE at ' +station+ ' (DWR-OSP-DMS+1C) (Pump Case)' # create a curve for the first data reference c1 = CurveFactory.createCurve(ref1, AxisAttr.BOTTOM, AxisAttr.LEFT, l1text); # create a curve for the second data reference c2 = CurveFactory.createCurve(ref2, AxisAttr.BOTTOM, AxisAttr.LEFT, l2text); # add the curves to the plot plot0.add(c1); plot0.add(c2); # add the title to the plot plot0.addTitle('DSM2: Water Level at ' + station) # for b/w plots endorn one curve with symbols # get the attribute for the first curve attr1 = c1.getAttributes(); # set it to draw the symbol attr1._drawSymbol = 1 # draw a symbol once every 5 data points attr1._dataPerSymbol=5 # set the symbol to be drawn a circle with fill, same foreground color and size 2
g2.filterBy('BOTH') amplsb = [] for i in range(3): chan = repr(i + 1) amplsb.append(getAmplitude("00" + chan + "_0", g2)) # do alternative CHAN g2 = g.clone() g2.filterBy('DMS\+CHAN') # escape + character in reg exp amplsc = [] for i in range(3): chan = repr(i + 1) amplsc.append(getAmplitude("00" + chan + "_0", g2)) # ds_both = DefaultDataSet('stage profiles (BOTH)', [1, 2, 3], amplsb) ds_chan = DefaultDataSet('stage profiles (CHAN)', [1, 2, 3], amplsc) crv_both = CurveFactory.createCurve(DefaultReference(ds_both), AxisAttr.BOTTOM, AxisAttr.LEFT, 'stage profile (BOTH)') crv_chan = CurveFactory.createCurve(DefaultReference(ds_chan), AxisAttr.BOTTOM, AxisAttr.LEFT, 'stage profile (CHAN)') crv_both.lineThickness = 2 crv_both.foregroundColor = Color.blue crv_both.drawLines = 1 crv_chan.lineThickness = 2 crv_chan.foregroundColor = Color.green crv_chan.drawLines = 1 crv_both.symbol.foregroundColor = Color.blue crv_chan.symbol.foregroundColor = Color.green legend = Legend() legend.add(LegendItem(crv_both)) legend.add(LegendItem(crv_chan)) plot = Plot() plot.add(crv_both)