Scripting > Plotting Basics


G2dDialog Class

G2dDialog objects are the dialog that plots display in. G2dDialog methods are decribed below.


G2dDialog Methods

Method

Returns

Description

addData(DataContainer dc)

None

Add the DataContainer specified by dc to the plot. Must be called before showPlot().  Do not use this if a PlotLayout object is used on this plot.

applyTemplate(string templateFile)

None

Apply the given template to this plot

configurePlotLayout()

None

Display the “Configure Plot Layout” dialog for this plot

configurePlotLayout(PlotLayout layout)

None

Configures the plot layout for this plot according to the specified PlotLayout object.  If this method is used, do not use the addData() method with the same plot.

close()

None

Closes the plot

configurePlotTypes()

None

Display the configure plot types dialog

copyToClipboard()

None

Copy the plot to the system clipboard

defaultPlotProperties()

None

Display the default plot properties dialog

exportProperties()

None

Allows you to save the properties of the plot to a disk.

exportProperties(string templateName)

None

Allows you to save the properties of the plot to the file specified by templateName.

getCurve(HecMath ilenam)

G2dLine

Return the G2dLine for the DataSet specified by dataSet

getCurve(string dssPath)

G2dLine

Return the G2dLine for the path specified in dssPath

getHeight()

integer

Return the height of the dialog in screen coordinates.

getLegendLabel(DataContainer dc)

G2dLabel

Return the legend label object for the specified data container.

getLocation()

Point

Return the location of the dialog in screen coordinates1.

getPlotTitle()

G2dTitle

Return the title for the G2dDialog

getPlotTitleText()

string

Return the text of the title for the G2dDialog

getSize()

Dimension

Return the dimensions of the dialog in screen coordinates.

getViewport(HecMath ilenam)

 

Viewport

Return the Viewport that contains the curve specified by dataSet

getViewport(integer viewportIndex)

Viewport

Return the viewport at index specified by viewportIndex

getViewport(string dataSetPath)

Viewport

Return the Viewport that contains the curve specified by dataSetPath

getWidth()

Integer

Return the width of the dialog in screen coordinates.

hide()

None

Hide the dialog

iconify()

None

Minimize (iconify) the dialog

isPlotTitleVisible()

0/1

Return the visibility state of the title of this plot.

maximize()

None

Maximize the dialog

minimize()

None

Minimize (iconify) the dialog

newPlotLayout()

PlotLayout

Return a PlotLayout object that can be used to configure the layout of this plot.

plotProperties()

None

Display the plot properties dialog for this plot

print()

None

Display the print dialog for this plot

printMultiple()

None

Display the print multiple dialog for this plot

printPreview()

None

Display the print preview dialog for this plot

printToDefault()

None

Prints using the printer defaults such as page format and printer. This method does not display the printer dialog for user interaction.

repaint()

None

Forces the plot to be refreshed.

restore()

None

Restore the dialog from a minimized or maximized state

saveAs()

None

Display the saveAs dialog for this plot

saveToJpeg(string ilename)

None

Save the plot to the Jpeg file specified by fileName

saveToJpeg(string ilename, integer quality)

None

Save the plot to the Jpeg file specified by filename, with the specified quality2.

saveToMetafile(string filename)

None

Save the plot to the Windows Meta file specified by filename

saveToPng(string ilename)

None

Save the plot to the Portable Network Graphics file specified by filename

saveToPostscript(string ilename)

None

Save the plot to the PostScript file specified by filename

setLegendBackgound(string color)

None

Sets the background color of the legend.

setLegendLabelText(DataContainer dc, string text)

None

Sets the legend label text

setLegendLocation(string location)

None

Sets the location of the legend3.

setLocation(integer x,integer y)

None

Sets the location of the dialog in screen coordinates1.

setPlotTitleText(string text)

None

Sets the text of the title for this plot

setPlotTitleVisible(0/1 state)

None

Sets the visibility of the title for this plot

setSize(integer width, integer height)

None

Sets the size of the dialog in screen coordinates.

setVisible(0/1 visible)

None

Makes the plot visible

showPlot()

None

Show the dialog

stayOpen()

None

Keeps the plot on the screen for batch mode only

tabulate()

HecDataTableFrame

Display the table view of this plot

 

1 The coordinate system used is a graphics coordinate system, where X increases to the right and Y increases downward from the origin (0,0) which is located in the top left corner of the display. Locations set or retrieved refer to the top left corner of the plot in reference to this coordinate system.

2 The specified quality is limited to an effective range of 0 – 100, inclusive.  Higher qualities produce larger files and take longer to generate.  The saveToJpeg(fileName) call currently produces the same results as saveToJpeg(fileName, 75).

3 Valid legend locations are “Right” and “Bottom”.

 

Example: Plot Dialog

from hec.script import *                                                        # for Plot class

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.get(thePath)                                          # read a path name

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

thePlot.addData(flowDataSet)                                                # add flow data container

thePlot.showPlot()                                                                # show the plot

thePlot.setLocation(50,50)                                                     # moves plot to 50,50