Scripting > Plotting Basics


Axis Class

Axis methods are described in the table below.

Axis Method

Method

Returns

Description

getLabel()

string

Return the Axis label

getMajorTic()

floating-point

Return the major tic interval for this Axis

getMinorTic()

floating-point

Return the minor tic interval for this Axis

getNumTicLabelLevels()

integer

Return the number of tic label levels for this Axis

getScaledLabel()

String

Return the label with scientific notation

getScaleMax()

floating-point

Return the maximum value for this Axis

getScaleMin()

floating-point

Return the minimum value for this Axis

getTicColor()

Color

Return the tic color

getTicColorString()

String

Return the Tic color as a String

getTicTextColor()

Color

Return the tic text color

getTicTextColorString()

String

Return the tic text color as a String

getViewMax()

floating-point

Return the maximum value for the (possibly) zoomed view for this Axis

getViewMin()

floating-point

Return the minimum value for the (possibly) zoomed view for this Axis

isComputingMajorTics()

0/1

Return if major tics are to be computed

isComputingMinorTics()

0/1

Return if minor tics are to be computed

isReversed()

0/1

Returns whether the Axis is reversed

 

1

 

.

setComputeMajorTics(0/1 state)

None

Set  whether to compute major tics

setComputeMinorTics(0/1 state)

None

Set  whether to compute minor tics

setLabel(string label)

None

Set the label of this Axis

setLinear()

None

 

setLogarithmic

None

 

setMajorTicInterval(floating-point interval)

None

Set the major tic interval for this Axis to interval

setMinorTicInterval(floating-point interval)

None

Set the minor tic interval for this Axis to interval

setNumTicLabelLevels(integer layers)

None

Set the maximum number of tic label layers to specified number. -1 is unrestricted. Used mostly for time series axis.

setReversed(0/1 state)

None

Set  the reversed state of the Axis

 

1

 

..

setScaleLimits(floating-point min, floating-point max)

None

Sets the minimum and maximum values for the axis (range of un-zoomed view)

setTicColor(String colorString)

None

Set the tic color to the color represented by colorString

setTicTextColor(String colorString)

None

Set the tic text color to the color represented by colorString

setViewLimits(floating-point min, floating-point max)

None

Zooms based on world coordinates

unZoom()

None

Returns the view to the full axis range.

zoomByFactor(floating-point factor)

None

Change the zoom scaling by the given factor

 

1 The coordinate system used is a graphics coordinate system with the origin (0,0) located at the top left corner of the display, with X increasing to the right and Y increasing downward. The reversed state is in respect to this coordinate system (i.e. Y is reversed if it increases upward).

 

The script in the example below reads a data set from a DSS file, adds that data set to a new Plot, and zooms in on the Y Axis.

 

Example: Using Axis 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

yaxis = viewport0.getAxis(“Y1”)                                                        # get the Y1 axis

yaxis.setScaleLimits(0., 25000.)                                                         # set the scale

yaxis.zoomByFactor(.”5”)                                                                 # zoom in