HyperMath

Plotting - HyperMath

Plotting - HyperMath

Previous topic Next topic Expand/collapse all hidden text  

Plotting - HyperMath

Previous topic Next topic JavaScript is required for expanding text JavaScript is required for the print function  

HyperMath provides various utilities for two dimensional lines, scatter, and bar plot generation.

hmtoggle_plus1greyAddXAxis

Adds an x-axis to the active plot window.  This is only applicable for 2D plots.  Returns the new axis number.  This becomes the active axis in the window.

i = AddXAxis(r)

r

An optional two-element vector specifying the range of the axis.  Must be monotonically increasing.  Default range is as specified in plot preference if auto scale is chosen, else from zero to one.

i

The new x-axis number (1 based).

hmtoggle_plus1greyAddYAxis

Adds a y-axis to the active plot window.  This is only applicable for 2D plots.  Returns the new axis number.  This becomes the active axis in the window.

i = AddYAxis(r)

r

An optional two element vector specifying the range of the axis.  Must be monotonically increasing.  Default range is as specified in plot preference if auto scale is chosen, else from zero to one.

i

The new y-axis number (1 based).

hmtoggle_plus1greyChangeView

Changes the viewing angle of a 3-D plot.

b = ChangeView(s)

c

A string of either "iso", "top", "bottom", "front", "back", "left" or "right" .

b

True on success, otherwise false.

hmtoggle_plus1greyDeleteAllPlots

Deletes all plots.  It does nothing if no plots are present.

b = DeleteAllPlots()

b

True on success, otherwise false.

hmtoggle_plus1greyDeletePlot

Deletes the active or specified plot.

b = DeletePlot(h)

h

Handle to an existing plot.  If omitted it operates on the active plot.

b

True on success, otherwise false.

hmtoggle_plus1greyGetXRange

Returns the range of the x-axis of the active plot.

M = GetXRange()

M

Range of the x-axis (a vector).

hmtoggle_plus1greyGetYRange

Returns the range of the y-axis of the active plot.

M = GetYRange()

M

Range of the y-axis (a vector).

hmtoggle_plus1greyGetZRange

Returns the range of the z-axis of the active plot.

M = GetZRange()

M

Range of the z-axis (a vector).

hmtoggle_plus1greyGridOff

Hides the grid in the active plot window.  This is only applicable for 2D plots.  Returns true on success, false otherwise.

b = GridOff()

b

The status of the operation (a Boolean).

hmtoggle_plus1greyGridOn

Shows the grid in the active plot window.  This is only applicable for 2D plots.  Returns true on success, false otherwise.

b = GridOn()

b

The status of the operation (a Boolean).

hmtoggle_plus1greyHidePlot

Hides the active or specified plot from view.  If the plot is already hidden, then does nothing and returns true.

b = HidePlot(h)

h

Handle to an existing plot.  If omitted, it operates on the active plot.

b

True on success, otherwise false.

hmtoggle_plus1greyLegendOff

Hides the legend in the active plot window.  Returns true on success, false otherwise.

b = LegendOff()

b

The status of the operation (a Boolean).

hmtoggle_plus1greyLegendOn

Shows the legend in the active plot window.  Returns true on success, false otherwise.

b = LegendOn()

b

The status of the operation (a Boolean).

hmtoggle_plus1greyLegendPosition

Sets the location of the legend.

b = LegendPosition(s)

s

A string of the location. Valid locations include "upperright", "upperleft", "lowerright" or "lowerleft".

b

True on success, otherwise false.

hmtoggle_plus1greyPlotArea

Plots stacked areas on a 2-D plot on the active or a new window.

h = PlotArea(x,y)

x

A vector of the data to associate with the x- axis.

y

A vector or matrix of the data to associate with the y-axis.  If the data is a matrix, then each column is treated as the upper border of an area with subsequent areas stacked.  Hence, its number of rows must match the number of points in the x-vector.

h

A handle to the drawn plot window.

hmtoggle_plus1greyPlotBar

Plots vertical bars on an active plot window or on a new window.  The active plot window is the last drawn on or defined as one explicitly by SetPlot.  If no plot window exists, a new one is created.

h = PlotBar(x,y [,s])

h = PlotBar(x,y,p)

x

A vector of the data to associate with the horizontal axis.

y

A vector or matrix of the data to associate with the vertical axis.

s

An optional string indicating if a new plot window is to be created.  It can only be ‘new’.

p

An existing plot handle where the new data is added.

h

A handle to the drawn plot window.

If x and y are vectors, they must be of same length but can be in either row or column orientation.  However, if y is an m by n matrix it must have the same number of rows as x.  In this case, all entries in each row of y is grouped together to create m sets of n bars.

        x = [1,2,3]; y = [10,20,30];

        PlotBar(x,y);// Will plot three bars at the specified x values

 

        x = [1,2,3]; y = [10,20;11,21;12,22]

        PlotBar(x,y,’new’); // Will plot (in a new window)

        a pair of bars at each of the specified x values

hmtoggle_plus1greyPlotContour

Plots 2D contoured surface on a new window.

h = PlotContour(x,y,z)

x

A vector of the data to associate with the x- axis.

y

A vector of the data to associate with the y-axis.

z

A matrix of the data to associate with the (vertical) z-axis. Number of columns and rows must be equal to length of x and y.

h

A handle to the drawn plot window.

hmtoggle_plus1greyPlotContour3D

Plots 3D contoured surface on a new window.

h = PlotContour3D(x,y,z)

x

A vector of the data to associate with the x- axis.

y

A vector of the data to associate with the y-axis.

z

A matrix of the data to associate with the (vertical) z-axis. Number of columns and rows must be equal to length of x and y.

h

A handle to the drawn plot window.

hmtoggle_plus1greyPlotLine

Plots line curves on an active plot window or on a new window.  The active plot window is the last drawn on or defined as one explicitly by SetPlot.  If no plot window exists, a new one is created.

h = PlotLine(x,y [,s])

h = PlotLine(x,y,p)

x

A vector or matrix of the data to associate with the horizontal axis.

y

A vector or matrix of the data to associate with the vertical axis.

s

An optional string indicating if a new plot window is to be created.  It can only be ‘new’.

p

An existing plot handle where the new data is added.

h

A handle to the drawn plot window.

If x and y are vectors, they must be of same length but can be in either row or column orientation.  But, if they are a matrix, they must be of the same dimension.  In this case, each column from x and y is paired up to create a curve.

x = [1,2,3]; y = [10,20,30];

PlotLine(x,y);        // Will plot one line curve of y vs. x

 

x = [1,1;2,2;3,3]; y = [10,20;11,21;12,22]

PlotLine(x,y,’new’); // Will plot (in a new window) 2 line curves each made of a column pair from x and y

 

x = [1,2,3]; y = [1,2,3];

PlotLine(x,y,h); // Will plot on the first plot window

hmtoggle_plus1greyPlotLine3D

Plots 3D line curves on the active, specified or a new window.  The active plot window is the last drawn on or defined as one explicitly by SetPlot.  If no plot window exists or the active one is not a 3D plot, a new one is created. For each pair of the independent (x[i],y[i]) data points, the corresponding dependant data point is plotted.

hmtoggle_plus1greyPlotPolar

Plots phase and magnitude in polar coordinates on the active or a new window.  The active plot window is the last drawn on or defined as one explicitly by SetPlot.  If no plot window exists or the active one is not a polar plot, a new one is created.

You can plot a polar plot with a negative magitude; it's transformed by rotating PI from the original plot.

h = PlotPolar(p,m,[s])

h = PlotPolar(c,[s])

p

A vector of the phase angle data.  Imaginary parts are ignored.

m

A vector of the magnitude data.  Imaginary parts are ignored.  Must have length as p.

c

A vector of complex (in general) data.  The magnitudes and phase angles are automatically calculated.

s

An optional string indicating if a new plot window is to be created.  It can only be ‘new’.

h

A handle to the drawn plot window.

hmtoggle_plus1greyPlotScatter

Plots scatter curves on an active plot window or on a new window.  The active plot window is the last drawn on or defined as one explicitly by SetPlot. If no plot window exists, a new one is created.

h = PlotScatter(x,y [,s])

h = PlotScatter(x,y,p)

x

A vector or matrix of the data to associate with the horizontal axis.

y

A vector or matrix of the data to associate with the vertical axis.

s

An optional string indicating if a new plot window is to be created.  It can only be ‘new’.

p

An existing plot handle where the new data is added.

h

A handle to the drawn plot window.

If x and y are vectors, they must be of same length but can be in either row or column orientation.  But, if they are a matrix, they must be of the same dimension.  In such case, each column from x and y is paired up to create a curve.

        x = [1,2,3]; y = [10,20,30];

     PlotScatter(x,y);        // Will plot one scatter curve of y vs. x

 

     x = [1,1;2,2;3,3]; y = [10,20;11,21;12,22]

    PlotScatter(x,y,’new’); // Will plot (in a new window) 2 line curves each

     consisting of a column pair from x and y

 

hmtoggle_plus1greyPlotScatter3D

Plots 3D scatter curves on the active, specified or a new window.  The active plot window is the last drawn on or defined as one explicitly by SetPlot.  If no plot window exists or the active one is not a 3D plot, a new one is created. For each pair of the independent (x[i],y[i]) data points, the corresponding dependant data point is plotted.

h = PlotScatter3D(x,y,z [,s])

h = PlotScatter3D(x,y,z [,p])

x

A vector of the data to associate with the x- axis.

y

A vector of the data to associate with the y-axis.

z

A vector of the data to associate with the (vertical) z-axis. Its length is equal to the lengths of x and y.

s

An optional string indicating if a new plot window is to be created.  It can only be ‘new’.

p

An existing 3D plot handle where the new data will be added.

h

A handle to the drawn plot window.

u = [0:(PI/50):(2*PI)]

x=Sin(2*u).*(10.0 + 6*Cos(3*u))

y=Cos(2*u).*(10.0 + 6*Cos(3*u))

z=6*Sin(3*u)

PlotScatter3D(x,y,z)

hmtoggle_plus1greyPlotSurface3D

Plots 3D surface on a new window.  The active plot window is the last drawn on or defined as one explicitly by SetPlot.  If no plot window exists or the active one is not a 3D plot, a new one is created.

h = PlotSurface3D(x,y,z)

x

A vector of the data to associate with the x- axis.

y

A vector of the data to associate with the y-axis.

z

A matrix of the data to associate with the (vertical) z-axis. Number of columns and rows must be equal to length of x and y.

h

A handle to the drawn plot window.

hmtoggle_plus1greyPlotWaterfall3D

Plots waterfall surface on a new window.  The active plot window is the last drawn on or defined as one explicitly by SetPlot.  If no plot window exists or the active one is not a 3D plot, a new one is created.

h = PlotWaterfall3D(x,y,z)

x

A vector of the data to associate with the x- axis.

y

A vector of the data to associate with the y-axis.  The lines are drawn for the constant values of this axis.

z

A matrix of the data to associate with the (vertical) z-axis. Number of columns and rows must be equal to length of x and y.

h

A handle to the drawn plot window.

hmtoggle_plus1greySetAreaColor

Sets the colors of active area plot.  Applicable for area plots only.  For color data outside the range, the color of nearest level is used.

b = SetAreaColor(c)

c

A RGB color matrix.  Each row corresponds to each area color, so there are 3 columns.  There must be at least as many colors as areas.

b

True on success, else false.

hmtoggle_plus1greySetContour

Sets the contour levels and colors of the active plot.  Applicable for contour plots only.  For color data outside the range, the color of the nearest level is used.

b = SetContour(L,c)

L

A vector of contour levels.  Must be monotonically increasing.

c

An RGB color matrix.  Each row corresponds to each contour level color, so there are three columns. There must be at least as many colors as contour levels.

b

True on success, otherwise false.

hmtoggle_plus1greySetLegend

Sets the legend text of the last drawn plot.  There are two forms.  The first form sets the legend for only the most recently drawn item (line, area or surface) on the plot.  The other form sets the legend for all the items on the plot.  Both return true on success, false otherwise.

b = SetLegend(s)

b = SetLegend(t)

s

A string.

t

A table of strings.  The naming order corresponds to the order the items were added to the plot.

b

The status of the operation (a Boolean).

hmtoggle_plus1greySetLineColor

Sets the line color of the last drawn 2D/3D line.

b = SetLineColor(c)

c

An RGB color vector [R, G, B] with R,G,B a value between 0 and 255.

b

True on success, otherwise false. SetLineColor can fail if the new color is not in the current colormap used.

Example

M = [0 : 0.01:10];

C1 = Sin(M);

C2 = Cos(M);
C3 = C1 + C2;
 
RED_COLOR = [255, 0, 0];
GREEN_COLOR = [0, 255, 0];
BLUE_COLOR = [0, 0, 255];
BLACK_COLOR = [0, 0, 0];
WHITE_COLOR = [255, 255, 255];
 
PlotLine(M, C1);
SetLineColor(BLUE_COLOR);
 
PlotLine(M, C2);
SetLineColor(GREEN_COLOR);
 
PlotLine(M, C3);
SetLineColor(RED_COLOR);

hmtoggle_plus1greySetLineStyle

Sets the line style of line plot.  Returns true on success, false otherwise.

b = SetLineStyle(i, j, b)

i

An integer among the values 0 (no line) to 5.

j

An integer representing the line number in the order drawn, starting with 1.  If omitted, the last drawn line is used.

b

The status of the operation (a Boolean).

hmtoggle_plus1greySetLineWidth

Sets the line width of line in active plot.  Returns true on success, false otherwise.

b = SetLineWidth(i,j)

i

An integer for the width among the values 1 to 4

j

An integer representing the line number in the order drawn, starting with 1.  If omitted, uses the last drawn line

b

The status of the operation (a Boolean).

hmtoggle_plus1greySetMarkerColor

Sets the marker color of the last drawn 2D/3D line.  If the marker is not visible, it draws the default marker.

b = SetMarkerColor(c)

c

An RGB color vector.

b

True on success, otherwise false.

hmtoggle_plus1greySetMarkerStyle

Sets the marker style of the active line or scatter plot.  Returns true on success, false otherwise.

b = SetMarkerStyle(i, j)

i

An integer from zero to 9, with zero meaning no marker.

j

An integer representing the line number in the order drawn, starting with 1. If omitted, uses the last drawn line.

b

The status of the operation (a Boolean).

hmtoggle_plus1greySetNumXTicks

Sets the number of tics displayed in the x-axis.  For polar plot, it applies to the angular ticks.  Returns true on success, false otherwise.

b = SetNumXTicks(n)

n

The number of ticks.

b

The status of the operation (a Boolean).

hmtoggle_plus1greySetNumYTicks

Sets the number of tics displayed in the y-axis.  For polar plot, it applies to the radial axis ticks.  Returns true on success, false otherwise.

b = SetNumYTicks(n)

n

The number of ticks.

b

The status of the operation (a Boolean).

hmtoggle_plus1greySetNumZTicks

Sets the number of tics displayed in the z-axis.  Returns true on success, false otherwise.

b = SetNumZTicks(n)

n

The number of ticks.

b

The status of the operation (a Boolean).

hmtoggle_plus1greySetPlot

Sets the plot window specified by the handle to be the active plot.  Any new plot created is drawn on this, unless a new window creation is specifically requested.  Returns true on success, false otherwise.

b = SetPlot(h)

h

Handle to an existing plot.  It is obtained from a previous plot command.

b

The status of the operation (a Boolean).

hmtoggle_plus1greySetSurfaceColor3D

Sets the surface color of last drawn 3D surface plot.

b = SetSurfaceColor3D(c)

c

An RGB color vector.

b

True on success, otherwise false.

hmtoggle_plus1greySetTitle

Sets the title of the active plot window.  Returns true on success, false otherwise.

b = SetTitle(s)

s

A string.

b

The status of the operation (a Boolean).

hmtoggle_plus1greySetXAxis

Sets the i-th x-axis of the active plot window to be the active axis.  This is only applicable for 2D plots.  Any subsequent new plot in the active window are drawn on this x-axis.  This is useful when there are multiple x-axes and a new plot is to be created on a specified one. Returns a true on success, false otherwise.

b = SetXAxis(i)

i

A positive integer specifying the axis number.  Axes are numbered in the order created.

b

The status of the operation (a Boolean).

hmtoggle_plus1greySetXGridDivision

Set the grids per division of the active x-axis. Returns true on success, false otherwise.

b = SetXGridDivision(d)

d

An non-negative integer specifying the grids per division of the active x-axis.

b

The status of the operation (a Boolean).

hmtoggle_plus1greySetXLabel

Sets the label for the active x-axis of the active plot window.  Returns true on success, false otherwise.

b = SetXLabel(s)

s

A string for the label name.

b

The status of the operation (a Boolean).

hmtoggle_plus1greySetXRange

Sets the range of the active x-axis.  Returns true on success, false otherwise.

b = SetXRange(r)

r

A two element vector specifying the range of the axis.  Must be monotonically increasing.

b

The status of the operation (a Boolean).

hmtoggle_plus1greySetXScale

Sets the x-axis scale type.

b = SetXScale(s)

s

A string of type. Valid types include "linear","log","db10" and "db20".

b

True on success, otherwise false.

hmtoggle_plus1greySetYAxis

Sets the i-th y-axis of the active plot window to be the active axis.  This is only applicable for 2D plots.  Any subsequent new plot in the active window are drawn on this y-axis.  This is useful when there are multiple y-axes and a new plot is to be created on a specified one. Returns true on success, false otherwise.

b = SetYAxis(i)

i

A positive integer specifying the axis number.  Axes are numbered in the order created.

b

The status of the operation (a Boolean).

hmtoggle_plus1greySetYGridDivision

Set the grids per division of the active y-axis. Returns true on success, false otherwise.

b = SetYGridDivision(d)

d

An non-negative integer specifying the grids per division of the active y-axis.

b

The status of the operation (a Boolean).

hmtoggle_plus1greySetYLabel

Sets the label for the active y-axis of the active plot window.  Returns true on success, false otherwise.

b = SetYLabel(s)

s

A string for the label name.

b

The status of the operation (a Boolean).

hmtoggle_plus1greySetYRange

Sets the range of the active y-axis.  Returns true on success, false otherwise.

b = SetYRange(r)

r

A two element vector specifying the range of the axis.  Must be monotonically increasingly.

b

The status of the operation (a Boolean).

hmtoggle_plus1greySetYScale

Sets the y-axis scale type.

b = SetYScale(s)

s

A string of type. Valid types include "linear","log","db10" and "db20".

b

True on success, otherwise false.

hmtoggle_plus1greySetZGridDivision

Set the grids per division of the active y-axis. Returns true on success, false otherwise.

b = SetZGridDivision(d)

d

An non-negative integer specifying the grids per division of the active z-axis.

b

The status of the operation (a Boolean).

hmtoggle_plus1greySetZLabel

Sets the label for the active z-axis of the active plot window.  Returns true on success, false otherwise.

b = SetZLabel(s)

s

A string.

b

The status of the operation (a Boolean).

hmtoggle_plus1greySetZRange

Sets the range of the active z-axis.  Returns true on success, false otherwise.

b = SetZRange(r)

r

A two-element vector specifying the range of the axis.  Must be monotonically increasingly.

b

The status of the operation (a Boolean).

hmtoggle_plus1greySetZScale

Sets the y-axis scale type.

b = SetZScale(s)

s

A string of type. Valid types include "linear","log","db10" and "db20".

b

True on success, otherwise false.

hmtoggle_plus1greyShowPlot

Shows the active or specified plot in view.  If the plot is already shown, then this does nothing and returns true.

b = ShowPlot(h)

h

Handle to an existing plot. If omitted, it operates on the active plot.

b

True on success, otherwise false.