def timeExample4(netPlot, plotNumber): """Time series chart passing the time (from Netplot.GetTimeNowString()) and the y value""" plotConfig = PlotConfig() plotConfig.plotName="Plot 0" plotConfig.xAxisName="The X axis" plotConfig.yAxisName="Y axis (Plot0)" plotConfig.enableLines=1 plotConfig.enableShapes=1 plotConfig.enableAutoScale=1 plotConfig.maxAgeSeconds=5 netPlot.setPlotType('time', title="%d: TIME chart using Netplot.GetTimeNowString()." % (plotNumber) ) netPlot.addPlot(plotConfig) plotConfig.plotName="Plot 1" #Add a new Y Axis plotConfig.yAxisName="Y Axis (Plot1)" netPlot.addPlot(plotConfig) #Update first plot i=0 while i<10: netPlot.addTimePlotValue(0, NetPlot.GetTimeNowString(), float(1.395*random.randint(0,10) ) ) i=i+1 time.sleep(0.1) netPlot.update()
def timeExample4(netPlot, plotNumber): """Time series chart passing the time (from Netplot.GetTimeNowString()) and the y value""" plotConfig = PlotConfig() plotConfig.plotName = "Plot 0" plotConfig.xAxisName = "The X axis" plotConfig.yAxisName = "Y axis (Plot0)" plotConfig.enableLines = 1 plotConfig.enableShapes = 1 plotConfig.enableAutoScale = 1 plotConfig.maxAgeSeconds = 5 netPlot.setPlotType( 'time', title="%d: TIME chart using Netplot.GetTimeNowString()." % (plotNumber)) netPlot.addPlot(plotConfig) plotConfig.plotName = "Plot 1" #Add a new Y Axis plotConfig.yAxisName = "Y Axis (Plot1)" netPlot.addPlot(plotConfig) #Update first plot i = 0 while i < 10: netPlot.addTimePlotValue(0, NetPlot.GetTimeNowString(), float(1.395 * random.randint(0, 10))) i = i + 1 time.sleep(0.1) netPlot.update()
def timeExample3(netPlot, plotNumber): """Two plots on a time series chart with different Y axis""" plotConfig = PlotConfig() plotConfig.plotName = "Plot 0" plotConfig.xAxisName = "The X axis" plotConfig.yAxisName = "Y axis (Plot0)" plotConfig.enableLines = 1 plotConfig.enableShapes = 1 plotConfig.enableAutoScale = 1 #plotConfig.minScaleValue=0 #plotConfig.maxScaleValue=10000 plotConfig.maxAgeSeconds = 5 netPlot.setPlotType( 'time', title= "%d: TIME chart, two traces with different linear Y scales, both autoscaled" % (plotNumber)) netPlot.addPlot(plotConfig) plotConfig.plotName = "Plot 1" #Add a new Y Axis plotConfig.yAxisName = "Y Axis (Plot1)" netPlot.addPlot(plotConfig) i = 0 while i < 10: netPlot.addPlotValues( [random.randint(1000, 10000), random.randint(10, 100)]) i = i + 1
def timeExample2(netPlot, plotNumber, timePeriod=0.01): """Three plots on a time series chart with the same Y axis.""" plotConfig = PlotConfig() plotConfig.xAxisName="The X axis" plotConfig.yAxisName="The Y axis (Plot0)" plotConfig.enableLines=1 plotConfig.enableShapes=1 plotConfig.enableAutoScale=0 plotConfig.minScaleValue=-5 plotConfig.maxScaleValue=5 netPlot.setPlotType('time', title="%d: TIME chart, multiple plots, same Y scale" % (plotNumber) ) #Uncomment this to remove the Legend on the chart #netPlot.setChartLegendEnabled(0) for plotName in ["Sine","Cosine","Tangent"]: plotConfig.plotName=plotName netPlot.addPlot(plotConfig) #We only want one Y axis so null plot axis names plotConfig.xAxisName="" plotConfig.yAxisName="" x=0.01 while x< 25: netPlot.addPlotValues([sin(x), cos(x), tan(x)]) x=x+0.1 time.sleep(timePeriod)
def timeExample2(netPlot, plotNumber, timePeriod=0.01): """Three plots on a time series chart with the same Y axis.""" plotConfig = PlotConfig() plotConfig.xAxisName = "The X axis" plotConfig.yAxisName = "The Y axis (Plot0)" plotConfig.enableLines = 1 plotConfig.enableShapes = 1 plotConfig.enableAutoScale = 0 plotConfig.minScaleValue = -5 plotConfig.maxScaleValue = 5 netPlot.setPlotType('time', title="%d: TIME chart, multiple plots, same Y scale" % (plotNumber)) #Uncomment this to remove the Legend on the chart #netPlot.setChartLegendEnabled(0) for plotName in ["Sine", "Cosine", "Tangent"]: plotConfig.plotName = plotName netPlot.addPlot(plotConfig) #We only want one Y axis so null plot axis names plotConfig.xAxisName = "" plotConfig.yAxisName = "" x = 0.01 while x < 25: netPlot.addPlotValues([sin(x), cos(x), tan(x)]) x = x + 0.1 time.sleep(timePeriod)
def xyExample1(netPlot, plotNumber): """two plots with different linear Y scales""" plotConfig0 = PlotConfig() plotConfig0.plotName = "Plot 0" plotConfig0.xAxisName = "The X axis name" plotConfig0.yAxisName = "Y axis (Plot 0)" plotConfig0.enableLines = 1 plotConfig0.enableShapes = 1 plotConfig0.enableAutoScale = 1 plotConfig0.enableZeroOnXAxis = 0 plotConfig0.enableZeroOnYAxis = 0 netPlot.setPlotType( 'xy', title= "%d: XY chart, two traces with different linear Y scales, both autoscaled" % (plotNumber)) netPlot.addPlot(plotConfig0) plotConfig1 = PlotConfig() plotConfig1.plotName = "Plot 1" plotConfig1.yAxisName = "Y axis (Plot 1)" plotConfig1.enableLines = 1 plotConfig1.enableShapes = 1 plotConfig1.enableAutoScale = 1 plotConfig1.enableZeroOnXAxis = 0 plotConfig1.enableZeroOnYAxis = 0 netPlot.addPlot(plotConfig1) i = 0 while i < 10: netPlot.addXYPlotValues(0, random.randint(-90, -70), random.randint(130, 150)) netPlot.addXYPlotValues(1, random.randint(-60, -50), random.randint(75, 80)) i = i + 1
def xyExample1(netPlot, plotNumber): """two plots with different linear Y scales""" plotConfig0 = PlotConfig() plotConfig0.plotName="Plot 0" plotConfig0.xAxisName="The X axis name" plotConfig0.yAxisName="Y axis (Plot 0)" plotConfig0.enableLines=1 plotConfig0.enableShapes=1 plotConfig0.enableAutoScale=1 plotConfig0.enableZeroOnXAxis=0 plotConfig0.enableZeroOnYAxis=0 netPlot.setPlotType('xy', title="%d: XY chart, two traces with different linear Y scales, both autoscaled" % (plotNumber) ) netPlot.addPlot(plotConfig0) plotConfig1 = PlotConfig() plotConfig1.plotName="Plot 1" plotConfig1.yAxisName="Y axis (Plot 1)" plotConfig1.enableLines=1 plotConfig1.enableShapes=1 plotConfig1.enableAutoScale=1 plotConfig1.enableZeroOnXAxis=0 plotConfig1.enableZeroOnYAxis=0 netPlot.addPlot(plotConfig1) i=0 while i<10: netPlot.addXYPlotValues(0,random.randint(-90,-70), random.randint(130,150)) netPlot.addXYPlotValues(1,random.randint(-60,-50), random.randint(75,80)) i=i+1
def cachedPlot(netPlot, plotNumber): """XY plot with log Y scale but in this case we send the data for all the points to be plotted and then use the update command to plot them all quickly.""" plotConfig0 = PlotConfig() plotConfig0.plotName="Plot 0" plotConfig0.xAxisName="The X axis name" plotConfig0.yAxisName="Log Y axis" plotConfig0.enableLines=1 plotConfig0.enableShapes=0 plotConfig0.enableAutoScale=False plotConfig0.minScaleValue=0 plotConfig0.maxScaleValue=1 netPlot.setPlotType('xy', title="%d: Cached, fast XY chart with log Y scale" % (plotNumber) ) netPlot.addPlot(plotConfig0) #These must be called after the plot type is added #Enables cached operation, update() will draw all plot points netPlot.enableCache(True) #Not printing status messages may speed up plotting if CPU bound netPlot.enableStatusMessages(False) while True: netPlot.replot(0) for v in range(1,100): netPlot.addXYPlotValues(0,v, random.random()) #Update. plot values will be sent now as the NetPlot cache is enabled netPlot.update() return
def cachedPlot(netPlot, plotNumber): """XY plot with log Y scale but in this case we send the data for all the points to be plotted and then use the update command to plot them all quickly.""" plotConfig0 = PlotConfig() plotConfig0.plotName = "Plot 0" plotConfig0.xAxisName = "The X axis name" plotConfig0.yAxisName = "Log Y axis" plotConfig0.enableLines = 1 plotConfig0.enableShapes = 0 plotConfig0.enableAutoScale = False plotConfig0.minScaleValue = 0 plotConfig0.maxScaleValue = 1 netPlot.setPlotType('xy', title="%d: Cached, fast XY chart with log Y scale" % (plotNumber)) netPlot.addPlot(plotConfig0) #These must be called after the plot type is added #Enables cached operation, update() will draw all plot points netPlot.enableCache(True) #Not printing status messages may speed up plotting if CPU bound netPlot.enableStatusMessages(False) while True: netPlot.replot(0) for v in range(1, 100): netPlot.addXYPlotValues(0, v, random.random()) #Update. plot values will be sent now as the NetPlot cache is enabled netPlot.update() return
def timeExample5(netPlot, plotNumber): """Time series chart passing the time and the y value""" plotConfig = PlotConfig() plotConfig.plotName = "Plot 0" plotConfig.xAxisName = "The X axis" plotConfig.yAxisName = "Y axis (Plot0)" plotConfig.enableLines = 1 plotConfig.enableShapes = 1 plotConfig.enableAutoScale = 1 plotConfig.maxAgeSeconds = 5 netPlot.setPlotType( 'time', title="%d: TIME chart, passing the time and the y value (cached)." % (plotNumber)) netPlot.addPlot(plotConfig) plotConfig.plotName = "Plot 1" #Add a new Y Axis plotConfig.yAxisName = "Y Axis (Plot1)" netPlot.addPlot(plotConfig) #We enable cache on this plot. Therefore #data won't be sent until the netPlot.update() method is called. netPlot.enableCache(True) t1 = datetime.now() #Update first plot i = 0 while i < 10: netPlot.addTimePlotValue(0, t1, float(1.395 * random.randint(0, 10))) t1 = t1 + timedelta(seconds=60 * 60 * 24 * 365) i = i + 1 t2 = datetime.now() t2 = t2 + timedelta(seconds=10000) #Update second plot i = 0 while i < 10: netPlot.addTimePlotValue(1, t2, float(1.395 * random.randint(0, 10))) t2 = t2 + timedelta(seconds=60 * 60 * 24 * 365) i = i + 1 netPlot.update()
def timeExample5(netPlot, plotNumber): """Time series chart passing the time and the y value""" plotConfig = PlotConfig() plotConfig.plotName="Plot 0" plotConfig.xAxisName="The X axis" plotConfig.yAxisName="Y axis (Plot0)" plotConfig.enableLines=1 plotConfig.enableShapes=1 plotConfig.enableAutoScale=1 plotConfig.maxAgeSeconds=5 netPlot.setPlotType('time', title="%d: TIME chart, passing the time and the y value (cached)." % (plotNumber) ) netPlot.addPlot(plotConfig) plotConfig.plotName="Plot 1" #Add a new Y Axis plotConfig.yAxisName="Y Axis (Plot1)" netPlot.addPlot(plotConfig) #We enable cache on this plot. Therefore #data won't be sent until the netPlot.update() method is called. netPlot.enableCache(True) t1 = datetime.now() #Update first plot i=0 while i<10: netPlot.addTimePlotValue(0, t1, float(1.395*random.randint(0,10) ) ) t1=t1+timedelta(seconds=60*60*24*365) i=i+1 t2 = datetime.now() t2=t2+timedelta(seconds=10000) #Update second plot i=0 while i<10: netPlot.addTimePlotValue(1, t2, float(1.395*random.randint(0,10) ) ) t2=t2+timedelta(seconds=60*60*24*365) i=i+1 netPlot.update()
def timeExample3(netPlot, plotNumber): """Two plots on a time series chart with different Y axis""" plotConfig = PlotConfig() plotConfig.plotName="Plot 0" plotConfig.xAxisName="The X axis" plotConfig.yAxisName="Y axis (Plot0)" plotConfig.enableLines=1 plotConfig.enableShapes=1 plotConfig.enableAutoScale=1 #plotConfig.minScaleValue=0 #plotConfig.maxScaleValue=10000 plotConfig.maxAgeSeconds=5 netPlot.setPlotType('time', title="%d: TIME chart, two traces with different linear Y scales, both autoscaled" % (plotNumber) ) netPlot.addPlot(plotConfig) plotConfig.plotName="Plot 1" #Add a new Y Axis plotConfig.yAxisName="Y Axis (Plot1)" netPlot.addPlot(plotConfig) i=0 while i<10: netPlot.addPlotValues([random.randint(1000,10000),random.randint(10,100)]) i=i+1
def barExample(netPlot, plotNumber): """Bar chart example""" plotConfig0 = PlotConfig() plotConfig0.plotName = "Plot 0" plotConfig0.xAxisName = "The X axis" plotConfig0.yAxisName = "The Y axis" plotConfig0.enableAutoScale = 1 #plotConfig0.minScaleValue=1 #plotConfig0.maxScaleValue=10000 #log axis not currently supported on Bar charts netPlot.setPlotType('bar', title="%d: BAR chart" % (plotNumber)) netPlot.addPlot(plotConfig0) i = 0 while i < 10: netPlot.addPlotValues([random.randint(1000, 10000)]) i = i + 1
def barExample(netPlot, plotNumber): """Bar chart example""" plotConfig0 = PlotConfig() plotConfig0.plotName="Plot 0" plotConfig0.xAxisName="The X axis" plotConfig0.yAxisName="The Y axis" plotConfig0.enableAutoScale=1 #plotConfig0.minScaleValue=1 #plotConfig0.maxScaleValue=10000 #log axis not currently supported on Bar charts netPlot.setPlotType('bar', title="%d: BAR chart" % (plotNumber)) netPlot.addPlot(plotConfig0) i=0 while i<10: netPlot.addPlotValues([random.randint(1000,10000)]) i=i+1
def xyExample2(netPlot, plotNumber): """XY plot with log Y scale""" plotConfig0 = PlotConfig() plotConfig0.plotName="Plot 0" plotConfig0.xAxisName="The X axis name" plotConfig0.yAxisName="Log Y axis" plotConfig0.enableLines=1 plotConfig0.enableShapes=1 plotConfig0.enableLogYAxis=1 plotConfig0.minScaleValue=1E-10 plotConfig0.maxScaleValue=1E-2 netPlot.setPlotType('xy', title="%d: XY chart with log Y scale" % (plotNumber) ) netPlot.addPlot(plotConfig0) netPlot.addXYPlotValues(0,-50, 1E-9) netPlot.addXYPlotValues(0,-55, 1E-7) netPlot.addXYPlotValues(0,-60, 1E-6) netPlot.addXYPlotValues(0,-70, 1E-5) netPlot.addXYPlotValues(0,-80, 1E-4) netPlot.addXYPlotValues(0,-90, 1E-3)
def xyExample2(netPlot, plotNumber): """XY plot with log Y scale""" plotConfig0 = PlotConfig() plotConfig0.plotName = "Plot 0" plotConfig0.xAxisName = "The X axis name" plotConfig0.yAxisName = "Log Y axis" plotConfig0.enableLines = 1 plotConfig0.enableShapes = 1 plotConfig0.enableLogYAxis = 1 plotConfig0.minScaleValue = 1E-10 plotConfig0.maxScaleValue = 1E-2 netPlot.setPlotType('xy', title="%d: XY chart with log Y scale" % (plotNumber)) netPlot.addPlot(plotConfig0) netPlot.addXYPlotValues(0, -50, 1E-9) netPlot.addXYPlotValues(0, -55, 1E-7) netPlot.addXYPlotValues(0, -60, 1E-6) netPlot.addXYPlotValues(0, -70, 1E-5) netPlot.addXYPlotValues(0, -80, 1E-4) netPlot.addXYPlotValues(0, -90, 1E-3)
def timeExample1(netPlot, plotNumber): """Single plot on a time series chart""" plotConfig = PlotConfig() plotConfig.plotName="Plot 0" plotConfig.xAxisName="The X axis" plotConfig.yAxisName="The Y axis (Plot0)" plotConfig.enableLines=1 plotConfig.enableShapes=1 plotConfig.enableAutoScale=0 plotConfig.minScaleValue=0 plotConfig.maxScaleValue=10000 plotConfig.maxAgeSeconds=5 plotConfig.tickCount=1000 netPlot.setPlotType('time', title="%d: TIME chart, single plot" % (plotNumber) ) #Uncomment this to remove the Legend on the chart #netPlot.setChartLegendEnabled(0) netPlot.addPlot(plotConfig) i=0 while i< 10: netPlot.addPlotValues([random.randint(1000,10000)]) i=i+1
def timeExample1(netPlot, plotNumber): """Single plot on a time series chart""" plotConfig = PlotConfig() plotConfig.plotName = "Plot 0" plotConfig.xAxisName = "The X axis" plotConfig.yAxisName = "The Y axis (Plot0)" plotConfig.enableLines = 1 plotConfig.enableShapes = 1 plotConfig.enableAutoScale = 0 plotConfig.minScaleValue = 0 plotConfig.maxScaleValue = 10000 plotConfig.maxAgeSeconds = 5 plotConfig.tickCount = 1000 netPlot.setPlotType('time', title="%d: TIME chart, single plot" % (plotNumber)) #Uncomment this to remove the Legend on the chart #netPlot.setChartLegendEnabled(0) netPlot.addPlot(plotConfig) i = 0 while i < 10: netPlot.addPlotValues([random.randint(1000, 10000)]) i = i + 1
def xyExample3(netPlot, plotNumber): """XY chart with 2 lin and 2 log Y scales""" plotConfig0 = PlotConfig() plotConfig0.plotName = "Plot 0" plotConfig0.xAxisName = "The X axis name" plotConfig0.yAxisName = "Log Y axis (Plot 0)" plotConfig0.enableLines = 1 plotConfig0.enableShapes = 1 plotConfig0.enableLogYAxis = 1 plotConfig0.minScaleValue = 1E-10 plotConfig0.maxScaleValue = 1E-2 netPlot.setPlotType('xy', title="%d: XY chart with 2 lin and 2 log Y scales" % (plotNumber)) netPlot.addPlot(plotConfig0) plotConfig1 = PlotConfig() plotConfig1.plotName = "Plot 1" plotConfig1.yAxisName = "Y axis (Plot 1)" plotConfig1.enableLines = 1 plotConfig1.enableShapes = 1 plotConfig1.enableAutoScale = 1 plotConfig1.enableZeroOnXAxis = 0 plotConfig1.enableZeroOnYAxis = 0 netPlot.addPlot(plotConfig1) plotConfig2 = PlotConfig() plotConfig2.plotName = "Plot 2" plotConfig2.yAxisName = "Y axis (Plot 2)" plotConfig2.enableLines = 1 plotConfig2.enableShapes = 1 plotConfig2.enableAutoScale = 1 plotConfig2.enableZeroOnXAxis = 0 plotConfig2.enableZeroOnYAxis = 0 netPlot.addPlot(plotConfig2) plotConfig3 = PlotConfig() plotConfig3.plotName = "Plot 3" plotConfig3.yAxisName = "Log Y axis (Plot 3)" plotConfig3.enableLines = 1 plotConfig3.enableShapes = 1 plotConfig3.enableLogYAxis = 1 plotConfig3.minScaleValue = 1E-10 plotConfig3.maxScaleValue = 1E-2 netPlot.addPlot(plotConfig3) netPlot.addXYPlotValues(0, -50, 1E-9) netPlot.addXYPlotValues(0, -55, 1E-7) netPlot.addXYPlotValues(0, -60, 1E-6) netPlot.addXYPlotValues(0, -70, 1E-5) netPlot.addXYPlotValues(0, -80, 1E-4) netPlot.addXYPlotValues(0, -90, 1E-3) netPlot.addXYPlotValues(1, -10, 10) netPlot.addXYPlotValues(1, -9, 12) netPlot.addXYPlotValues(1, -8, 14) netPlot.addXYPlotValues(1, -7, 16) netPlot.addXYPlotValues(1, -6, 18) netPlot.addXYPlotValues(1, -5, 20) netPlot.addXYPlotValues(2, -35, 10) netPlot.addXYPlotValues(2, -95, 12) netPlot.addXYPlotValues(2, -85, 14) netPlot.addXYPlotValues(2, -75, 16) netPlot.addXYPlotValues(2, -65, 18) netPlot.addXYPlotValues(2, -55, 20) netPlot.addXYPlotValues(3, 1, 1E-9) netPlot.addXYPlotValues(3, 2, 1E-7) netPlot.addXYPlotValues(3, 3, 1E-6) netPlot.addXYPlotValues(3, 4, 1E-5) netPlot.addXYPlotValues(3, 5, 1E-4) netPlot.addXYPlotValues(3, 6, 1E-3)
def xyExample3(netPlot, plotNumber): """XY chart with 2 lin and 2 log Y scales""" plotConfig0 = PlotConfig() plotConfig0.plotName="Plot 0" plotConfig0.xAxisName="The X axis name" plotConfig0.yAxisName="Log Y axis (Plot 0)" plotConfig0.enableLines=1 plotConfig0.enableShapes=1 plotConfig0.enableLogYAxis=1 plotConfig0.minScaleValue=1E-10 plotConfig0.maxScaleValue=1E-2 netPlot.setPlotType('xy', title="%d: XY chart with 2 lin and 2 log Y scales" % (plotNumber) ) netPlot.addPlot(plotConfig0) plotConfig1 = PlotConfig() plotConfig1.plotName="Plot 1" plotConfig1.yAxisName="Y axis (Plot 1)" plotConfig1.enableLines=1 plotConfig1.enableShapes=1 plotConfig1.enableAutoScale=1 plotConfig1.enableZeroOnXAxis=0 plotConfig1.enableZeroOnYAxis=0 netPlot.addPlot(plotConfig1) plotConfig2 = PlotConfig() plotConfig2.plotName="Plot 2" plotConfig2.yAxisName="Y axis (Plot 2)" plotConfig2.enableLines=1 plotConfig2.enableShapes=1 plotConfig2.enableAutoScale=1 plotConfig2.enableZeroOnXAxis=0 plotConfig2.enableZeroOnYAxis=0 netPlot.addPlot(plotConfig2) plotConfig3 = PlotConfig() plotConfig3.plotName="Plot 3" plotConfig3.yAxisName="Log Y axis (Plot 3)" plotConfig3.enableLines=1 plotConfig3.enableShapes=1 plotConfig3.enableLogYAxis=1 plotConfig3.minScaleValue=1E-10 plotConfig3.maxScaleValue=1E-2 netPlot.addPlot(plotConfig3) netPlot.addXYPlotValues(0,-50, 1E-9) netPlot.addXYPlotValues(0,-55, 1E-7) netPlot.addXYPlotValues(0,-60, 1E-6) netPlot.addXYPlotValues(0,-70, 1E-5) netPlot.addXYPlotValues(0,-80, 1E-4) netPlot.addXYPlotValues(0,-90, 1E-3) netPlot.addXYPlotValues(1,-10, 10) netPlot.addXYPlotValues(1,-9, 12) netPlot.addXYPlotValues(1,-8, 14) netPlot.addXYPlotValues(1,-7, 16) netPlot.addXYPlotValues(1,-6, 18) netPlot.addXYPlotValues(1,-5, 20) netPlot.addXYPlotValues(2,-35, 10) netPlot.addXYPlotValues(2,-95, 12) netPlot.addXYPlotValues(2,-85, 14) netPlot.addXYPlotValues(2,-75, 16) netPlot.addXYPlotValues(2,-65, 18) netPlot.addXYPlotValues(2,-55, 20) netPlot.addXYPlotValues(3,1, 1E-9) netPlot.addXYPlotValues(3,2, 1E-7) netPlot.addXYPlotValues(3,3, 1E-6) netPlot.addXYPlotValues(3,4, 1E-5) netPlot.addXYPlotValues(3,5, 1E-4) netPlot.addXYPlotValues(3,6, 1E-3)