Scripting > Plotting Basics


G2dLabel, G2dTitle, and AxisLabel Classes

G2dLabel, G2dTitle and AxisLabel methods are described below.

 

Label Methods

Method

Returns

Description

editProperties()

None

Display the Edit Properties Dialog for the label

getAlignmentString()

string

Return the text alignment for this label as a String

getBackground()

Color

Return the background color for the label1

getBackgroundString()

string

Return the background color for the label as a String1

getBorderStyleString()

string

Return the border style for this label as a string

getBorderWeight()

floating-point

Return the border weight for this label

getFillColor()

Color

Return the fill color for this label as a Color1

getFillColorString()

string

Return the fill color for this label as a string1

getFillPatternString()

string

Return the fill pattern for this label as a string1

getFontFamily()

string

Return the font family for the label

getFontSize()

integer

Return the font size for the label

getFontSizes()

tuple of 3 integers

Return the regular, tiny, min and max font sizes for this label

getFontString()

string

Return the font for the label as a string2.

getFontStyleString()

string

Return the font style for the label as a String

getForeground()

Color

Return the foreground color for the label

getForegroundString()

string

Return the foreground color for the label as a String

getIcon()

Icon

Return the Icon to display for this label

getIconPath()

string

Return the Icon path to display for this label

getRotation()

integer

Return the text rotation for this label

getSpacing()

integer

Return the spacing around this label

getText()

string

Return the text for the label

isBackgroundVisible()

0/1

Return whether the background is visible

isBorderVisible()

0/1

Return whether the border is visible

setAlignment(string 
alignment)

None

Set the text alignment for this label

setBackground(string 
colorString)

None

Set the background color for the label1

setBackgroundVisible(0/1 
state)

None

Set the background visibility for the label

setBorderColor(string 
colorString)

None

Set the border color for this label

setBorderStyle(string 
style)

None

Set the border style for this label

setBorderVisible(0/1 state)

None

Set the border visibility for this label

setBorderWeight(floating-
point weight)

None

Set the border weight for this label

setFillColor(string color)

None

Set the fill color for this label1

setFillPattern(string 
pattern)

None

Set the fill pattern for this label1

setFont(string font)

None

Set the font for the label2.

setFontFamily(string fam)

None

Set the font family for the label

setFontSize(integer sz)

None

Set the font size for the label

setFontSizes(integer sz, integer tiny, integer min, integer max)

None

Set the regular, tiny, min and max font sizes for this label

setFontStyle(string style)

None

Set the font style for the label

setForeground(string 
colorString)

None

Set the foreground color for the label

SetIcon(Icon icon)

None

Set the Icon to display for this label

SetIcon(string iconPath)

None

Set the Icon to display for this label

setRotation(integer 
rotation)

None

Set the text rotation for this label

setSpacing(integer space)

None

Set the spacing around this label

SetText(string text)

None

Set the text for the label

 

1 In the current version, fill color and background color are synonymous (e.g. fills are performed with the background color).  Future version may support separate fill and background colors.

2 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 creates a plot from a DSS data set and sets the Y1 axis label text to blue.

 

Example: Using AxisLabel Objects 
  

from hec.script import *                                                                       # for Plot class
from hec.heclib.dss import *                                                                 # for DSS class
thePlot = Plot.newPlot()                                                                        # create a Plot
dssFile = HecDss.open(“C:/mydb.dss”)                                                  # open the DSS file
flow = dssFile.get(“/BASIN/LOC/FLOW/01NOV2002/1HOUR/OBS/”)      # read a data set
thePlot.addData(flow)                                                                          # add the data set
thePlot.showPlot()                                                                               # show the plot
viewport0 = thePlot.getViewport(0)                                                       # get the first viewport
yaxislabel = viewport0.getAxisLabel("Y1")                                              # get the Y1 axis label
yaxislabel.setForeground(“blue”)                                                           # set the Y1 axis label text to blue