Scripting > Plotting Basics


Changing Plot Component Attributes

Not all Plot Component attributes are visible by default, and setting the attribute may not make that attribute visible.  Often it is necessary to set the visibility of the attribute by calling setAttributeVisible(Constants.TRUE).  Reading a flow data set from a DSS file, plotting the data set, setting the minor Y grid color to black and making it display are illustrated in the example below.

Example: Plotting DSS Data

 

from hec.script import *

from hec.script.Constants import TRUE, FALSE

theFile = HecDss.open(“myFile.dss”)                                       # open myFile.dss

thePath = “/BASIN/LOC/FLOW/01NOV2002/1HOUR/OBS/”

flowDataSet = theFile.get(thePath)                                           # read a path name

thePlot = Plot.newPlot()                                                          # create the plot

thePlot.addData(flowDataSet)                                                  # add the flow data set to the plot

thePlot.showPlot()                                                                  # show the plot

viewport0=thePlot.getViewport(0)                                            # get the first viewport

viewport0.setMinorGridYColor(“black”)                                    # set the viewport’s minor Y grid to black

viewport0.setMinorGridYVisible(TRUE)                                    # tell the minor Y grid to display