def createMesh(self, color='w', opacity=0.15, silo=False): _colors = dict( w=(255, 255, 255, 255), k=(0, 0, 0, 255), gray=(175, 175, 175), ) if silo: v.AddPlot('Mesh', "mesh") else: v.AddPlot('Mesh', "Mesh") ma = v.MeshAttributes() ma.legendFlag = 0 ma.meshColor = _colors[color] ma.meshColorSource = ma.MeshCustom if (opacity < 1.): ma.opaqueMode = ma.On ma.opacity = opacity v.SetPlotOptions(ma) pname = v.GetPlotList().GetPlots(v.GetNumPlots() - 1).plotName if silo: plot = Plot(pname, 'mesh', ma) else: plot = Plot(pname, 'Mesh', ma) self.nonplots.append(plot) return plot
def createContour(self, varname, value, color=None, linewidth=None): """Generic creation of a single contour without a legend""" v.AddPlot('Contour', varname) ca = v.ContourAttributes() ca.contourMethod = ca.Value ca.contourValue = (value,) ca.colorType = ca.ColorBySingleColor if color is None: color = vrc.rcParams['contour.color'] if type(color) is str: color = vc.common_colors[color] ca.singleColor = color if linewidth is None: linewidth = vrc.rcParams['contour.linewidth'] ca.lineWidth = linewidth # turn off legend for 2D surf ca.legendFlag = 0 v.SetPlotOptions(ca) pname = v.GetPlotList().GetPlots(v.GetNumPlots()-1).plotName plot = Plot(pname, 'Contour', ca) self.plots.append(plot) return plot
def SetLegend(legendInfo): # set color box (i.e. position, size, font, etc.) legend = visit.GetAnnotationObject( visit.GetPlotList().GetPlots(0).plotName) # options I like to set legend.active = 1 legend.managePosition = 0 legend.position = (legendInfo.xlo, legendInfo.yhi) legend.xScale = legendInfo.xScale legend.yScale = legendInfo.yScale legend.orientation = legend.HorizontalBottom # VerticalRight, VerticalLeft, HorizontalTop, HorizontalBottom legend.controlTicks = 1 legend.numTicks = legendInfo.nTick legend.minMaxInclusive = 1 legend.drawLabels = legend.Values # None, Values, Labels, Both legend.numberFormat = legendInfo.valFormat legend.drawTitle = 0 legend.drawMinMax = 0 legend.fontHeight = legendInfo.fontHeight # other options legend.suppliedValues = (1, 2, 3, 4, 5) legend.suppliedLabels = ("A", "B", "C", "D", "E")
def write_plots(f): f.write('# Create plots\n') pL = visit.GetPlotList() activePlots = [] for i in range(visit.GetNumPlots()): plot = pL.GetPlots(i) if plot.activeFlag: activePlots = activePlots + [i] plotName = visit.PlotPlugins()[plot.plotType] visit.SetActivePlots(i) f.write('# Create plot %d\n' % (i + 1)) f.write('OpenDatabase("%s")\n' % plot.databaseName) f.write('AddPlot("%s", "%s", 0, 0)\n' % (plotName, plot.plotVar)) atts = eval("visit." + plotName + "Attributes(1)") defaultatts = eval("visit." + plotName + "Attributes()") if write_state_object_diffs(f, atts, defaultatts, "atts"): f.write('SetPlotOptions(atts)\n') else: f.write('#SetPlotOptions(atts)\n') opIndex = 0 for op in plot.operatorNames: f.write('AddOperator("%s", 0)\n' % op) opAtts = visit.GetOperatorOptions(opIndex) defaultAtts = eval("visit." + object_type(opAtts) + "()") if write_state_object_diffs(f, opAtts, defaultAtts, "opAtts"): f.write('SetOperatorOptions(opAtts)\n') else: f.write('#SetOperatorOptions(opAtts)\n') opIndex += 1 # Set the SIL restriction write_sil(f) f.write('\n') if len(activePlots) > 1: f.write('SetActivePlots(%s)\n\n' % str(activePlots)) visit.SetActivePlots(activePlots) elif len(activePlots) == 1: f.write('SetActivePlots(%d)\n\n' % activePlots[0]) visit.SetActivePlots(activePlots[0])
def createPseudocolor(self, varname, display_name=None, cmap=None, limits=None, linewidth=None, legend=True, alpha=False): """Generic creation of pseudocolor""" if display_name is None: display_name = vrc.renameScalar(varname) if "temperature" in display_name: display_name = display_name.replace("[K]", "[C]") print "defining alias: %s = %s"%(display_name, varname) v.DefineScalarExpression(display_name, "%s - 273.15"%varname) elif display_name != varname: print "defining alias: %s = %s"%(display_name, varname) v.DefineScalarExpression(display_name, varname) v.AddPlot('Pseudocolor', display_name) pa = v.PseudocolorAttributes() # limits if limits is None: limits = vrc.getLimits(varname) if limits is not None: min = limits[0] max = limits[1] if min is not None: pa.minFlag = 1 pa.min = min if max is not None: pa.maxFlag = 1 pa.max = max # opacity if alpha: pa.opacity = 0 pa.opacityType = pa.ColorTable # colormap if cmap is not None: reverse = cmap.endswith("_r") if reverse: cmap = cmap.strip("_r") pa.invertColorTable = 1 pa.colorTableName = cmap # linewidth for 2D if linewidth is None: linewidth = vrc.rcParams['pseudocolor.linewidth'] pa.lineWidth = linewidth # turn off legend for 2D surf if not legend: pa.legendFlag = 0 v.SetPlotOptions(pa) pname = v.GetPlotList().GetPlots(v.GetNumPlots()-1).plotName if legend: plot = Plot(pname, 'Pseudocolor', pa, display_name) else: plot = Plot(pname, 'Pseudocolor', pa) self.plots.append(plot) return plot
aa.axes2D.xAxis.tickMarks.minorSpacing = (kxhi - kxlo) / 16. aa.axes2D.xAxis.tickMarks.majorSpacing = (kxhi - kxlo) / 4. aa.axes2D.xAxis.grid = 1 aa.axes2D.yAxis.title.visible = 0 aa.axes2D.yAxis.label.visible = 0 aa.axes2D.yAxis.tickMarks.visible = 1 aa.axes2D.yAxis.tickMarks.majorMinimum = kylo aa.axes2D.yAxis.tickMarks.majorMaximum = kyhi aa.axes2D.yAxis.tickMarks.minorSpacing = (kyhi - kylo) / 16. aa.axes2D.yAxis.tickMarks.majorSpacing = (kyhi - kylo) / 4. aa.axes2D.yAxis.grid = 1 visit.SetAnnotationAttributes(aa) # colorbox setting legend = visit.GetAnnotationObject(visit.GetPlotList().GetPlots(0).plotName) legend.active = 1 legend.managePosition = 0 legend.position = (0.5, 0.08) legend.xScale = 1.2 legend.yScale = 0.4 legend.orientation = legend.HorizontalBottom # VerticalRight, VerticalLeft, HorizontalTop, HorizontalBottom legend.controlTicks = 1 legend.numTicks = 5 legend.minMaxInclusive = 1 legend.drawLabels = legend.Values # None, Values, Labels, Both legend.numberFormat = "%.2f" legend.drawTitle = 0 legend.drawMinMax = 0 legend.fontHeight = 0.08
def getResults(self): dbName0 = visit.GetPlotList().GetPlots(0).GetDatabaseName() metaData0 = visit.GetMetaData(dbName0) return (metaData0.GetMeshes(0).minSpatialExtents,metaData0.GetMeshes(0).maxSpatialExtents)