Scripting > Plotting Basics


AxisMarker Class

AxisMarker objects hold complete descriptions of marker lines to be added to viewports.  AxisMarker objects have fields that are settable by the user to create marker lines of various styles.  New AxisMarker objects are created by calls to AxisMarker() (e.g. myMarker = AxisMarker() ).

 

AxisMarker fields are described below.

 

AxisMarker Fields

Field

Type

Description

Default

axis

string

“X” or “Y”

“Y”

fillColor

string

Color of the filled area

“black”

fillPattern

string

Pattern of the filled area

“solid”

fillStyle

string

Specifies whether the filled area is to be above or below the marker line, or to not fill at all

“none”

labelAlignment

string

Specifies whether the label text is to appear left justified, right justified or centered

“left”

labelColor

string

Color of the label text

“black”

labelFont

string

The font to use for the label 1.

None

labelPosition

string

Specifies whether the label text is to appear above, below, or in the center of the marker line

“above”

labelText

string

Text to appear with marker line

“”

lineColor

string

Color of the marker line

“black”

lineStyle

string

Style of the marker line

“solid”

lineWidth

floating point

Width of the marker line

1.0

value

string

Location of marker on axis (e.g. “712.5” or “23Aug2003 1015”)

“0”

 

1 Fonts are specified as name[,style[,size]] where style is Plain, Bold, Italic, or Bold Italic (e.g. “Arial,BoldItalic,12”, “Lucida Console,Plain,10”).

 

The script in the example below reads a data set from a DSS file, plots that data set, sets the Viewport’s background to light gray and adds a marker line on the Y axis.

 

Example: Viewport Class

 

from hec.script import *                                                            # for Plot class

from hec.script.Constants import TRUE, FALSE

from hec.heclib.dss import *                                                      # for DSS class

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

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

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

thePlot = Plot.newPlot()                                                             # create a new Plot

thePlot.addData(flowDataSet)                                                     # add the flow data

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

viewport0.setBackground(“lightgray”)                                         # set the Viewport’s # background to lightgray

viewport0.setBackgroundVisible(TRUE) # tell the Viewport to draw    # its background
marker = AxisMarker()                                                                   # create a new marker

marker.axis = “Y”                                                                      # set the axis

marker.value = “20000”                                                              # set the value

marker.labelText = “Damaging Flow”                                          # set the text

marker.labelColor = “red”                                                           # set the text color

marker.lineColor = “red”                                                             # set the line color

marker.fillColor = “red”                                                              # set the fill color

marker.fillType = “above”                                                           # set the fill type

maker.fillPattern = “diagonal cross”                                             # set the fill pattern

viewport0.addAxisMarker(marker)                                              # add the marker to the # viewport