Graph module

Table of Contents

class Graph.TProperty
class Graph.TAxis
class Graph.TAxes
class Graph.TGuiFormatSettings
class Graph.TPlotSettings
class Graph.TGuiSettings
Graph elements

Graph.Axes

Structure of class Graph.TAxes with axes settings. These settings are stored in the .grf file.

Graph.Property

Structure of class Graph.TProperty with global settings. These settings are stored in the users profile.

Graph.GuiFormatSettings

Structure of class Graph.TGuiFormatSettings with global formatting settings. Changes to these settings are not stored.

Graph.PlotSettings

Structure of class Graph.TPlotSettings with global plot settings. Changes to these settings are not stored.

Graph.GuiSettings

Structure of class Graph.TGuiSettings with global GUI settings. Changes to these settings are not stored.

Graph.VersionInfo

A tuple containing the five components of the version number of Graph: Major, Minor, Release, Build, and ReleaseLevel. All values except ReleaseLevel are integers; the release level is 'beta' or 'final'. The VersionInfo value corresponding to the Graph version 4.3 is (4, 3, 0, 384, 'final'). The components can also be accessed by name, so Graph.VersionInfo[0] is equivalent to Graph.VersionInfo.Major and so on.

Graph.Redraw()

Redraws the the graphing area.

Graph.Update()

Forces all graph elements, i.e. functions etc., to recalculate, redraw the plotting area and update the function list.

Graph.CreateAction(Caption, OnExecute, Hint="", ShortCut="", IconFile=None, OnUpdate=None, AddToToolBar=True)

Creates a new action with Caption as the shown text. Actions are used in the user interface, for example in the toolbar and menus. OnExecute is a function with the action as argument that is called when the action is triggered. Hint is an optional tooltip for the action. ShortCut is an optional shortcut as a text string, e.g. "Ctrl+Shift+C". IconFile is a file name for an image file that will be used as icon for the action. The file name can be a fully qualified path or a path relative to the Plugin directory. OnUpdate is an optional function with the action as argument that will be called when Graph is idle. This can be used to update the action, for example change its visibility state or enable/disable the action. AddToToolBar indicates if the action will be available to add to the toolbar by the user.

Graph.AddActionToMainMenu(Action)

Adds an action to the main menu unde the Plugin top menu.

Graph.AddActionToContextMenu(Action)

Adds an action to the context menu for the function list.

Graph.LoadDfmFile(FileName)

Load a DFM text file given by FileName usually created by Embarcadero Delphi or C++ Builder. A TForm object created from the file is returned.

Graph.LoadDefault()

Replaces the current coordinate system with the default settings. This is basically the same as selecting FileNew in the menu.

Graph.BeginMultiUndo()

Used to group several related changes in the undo stack, so they can be undone as one thing. Call EndMultiUndo() to end the grouping.

Graph.EndMultiUndo()

Used to end undo grouping started with BeginMultiUndo().

Graph.OnNew , Graph.OnLoad, Graph.OnSelect, Graph.OnClose, Graph.OnEdit, Graph.OnAnimate, Graph.OnDelete, Graph.OnAxesChanged, Graph.OnZoom, Graph.OnOptionsChanged, Graph.OnCustomFunctionsChanged, Graph.OnNewElem, Graph.OnChanged, Graph.OnMoved

ListSignatureDescription
OnNewFunction()Called after a new coordinate system is created.
OnLoadFunction()Called after a coordinate system is loaded from a file.
OnSelectFunction(Elem)Called when an element in the function list has been selected with the new element in Elem.
OnCloseFunction()Called when Graph is shutting down.
OnEditFunction(Elem) Called when the user wants to edit an element. The element to edit is given in Elem. If the function handles the edit it should return True to prevent Graph from handling it.
OnAnimateFunction(Data, Var, Value) When an animation is created this is called every time a frame is created. Data is the temporary data used for creating the animation. Var is the constant changed in every frame and Value is the new value of the constant.
OnDeleteFunction(Elem)Called when an element is about to be deleted.
OnAxesChangedFunction()Called when the axes settings have been changed.
OnZoomFunction()Called when the user has zoomed in out out.
OnOptionsChangedFunction()Called when the user has made changes in the Options dialog.
OnCustomFunctionsFunction()Called when the user has made changes to custom functions or constants.
OnNewElemFunction(Elem)Called when a new element has been created.
OnChangedFunction(Elem)Called when an element has been changed by the user.
OnMovedFunction(Elem)Called when the user has moved an element in the function list.

Graph.Eval(Expression [, Trigonometry])

Evaluates Expression, which is a string with an expression like "sin(0.3)+3^2.5". The expression is evaluated using real numbers only and the result is returned as a floating point number. Trigonometry can be Graph.Radian or Graph.Degree. If Trigonometry is not specified, the value in Graph.Axes.Trigonometry will be used. The function will raise the exception Graph.EFuncError if an error occurs.

Graph.EvalComplex(Expression [, Trigonometry])

The same as Eval() except that this function evaluates using complex numbers, and a complex number is returned.

Graph.SaveAsImage(FileName [, FileType, Width, Height])

Saves the current coordinate system as an image file, where FileName specifies the file name. If given FileType specifies the file type, which can be Enhanced Metafile (1), Scalable Vector Graphics (2), Bitmap (3), PNG (4), JPEG (5) or PDF (6). If FileType is not specified, the format will be guessed from the extension in the file name. Width and Height specifies the resolution of the image file. If they are left out, the same resolution as shown on the screen will be used.

Graph.Selected

This is the currently selected item in the function list. Don't try to change this. Instead you can change Graph.FunctionList.Selected.

Graph.Constants

This is the interface to the Custom functions/constants dialog. The index is the name of the constant or function. The value is a tuple where the first element is either a numeric value or a text defining the function or constant. The rest of the elements in the tuple are the parameters to the function. A constant does not have any parameters. For example a constant R=8.314472 can be created as Graph.Constants["R"] = (8.314472,) A custom function as sinc(x)=sin(x)/x can be created as Graph.Constants["sinc"] = ("sin(x)/x", "x")

Graph.CustomFunctions

This can be used to create custom functions implemented in Python. CustomFunctions is a dictionary where the key is the function name and the value is the Python function. For example the function sinc(x)=sin(x)/x can be implemented in Python like this: Graph.CustomFunctions["sinc"] = lambda x: math.sin(x)/x

Graph.FunctionList

This is a list of Graph.TGraphElem elements which are plotted by Graph. It is the same list that is shown in the GUI. To plot an element, you just add it to the list. To make sure the undo functionality works, you should not change an element already in the list. Instead you should replace the old element in the list with a new element. Graph.FunctionList.Selected can be used to read and set the selected element in the GUI.

Graph.PluginData

PluginData is a dictionary like object where a plugin can store data. The data is stored in the .grf file. Graph itself does not use this, it is only for use by plugins Every plugin should use a unique value as key in the PluginData dictionary. The value assigned should be a tuple, which may contain anything that can be passed to xmlrpc, e.g. tuples, lists, strings, numbers.

Graph.LoadFromFile(FileName, AddToRecent=True, ShowErrorMessages=True)

Loads a grf file from the file specified by FileName. If AddToRecent is True, the file name is added to the list of recent files in the File menu. If ShowErrorMessages is True, a dialog with error information is shown if a problem occur, else errors are ignored. The function returns True if the file was loaded without errors, else False is returned.

Graph.SaveToFile(FileName, Remember=True)

Saves the current data to a grf file specified by FileName. If Remember is True, Graph will remember the file name and use it when saving with FileSave.

Graph.Import(FileName)

Imports the content of a grf file specified by FileName into the current coordinate system, excluding axes settings. An exception is thrown on errors.

Graph.ImportPointSeries(FileName, Separator=0)

Imports the content of a text file as one or more point series. Separator indicates the separator used. It is usually ',', ' ', ';' or '\t'. If Separator is 0, the actual separator is auto detected from the content of the file. An exception is thrown on errors.