CPlotView Class Description


The CPlotView class displays 1-dimensional data as a plot. The CPlotView class leverages the richness and power of the Mira Plot Window and also can operate on existing Plot windows you attach to the script. Point data can be plotted from the following sources:

bullet.gif    An internal collection (matrix) of data points filled using the Add method. This protocol is the most general, providing any combination of moves, markers, and lines, with or without error bars.

bullet.gif    Equally spaced data stored in the rows of a CMatrix. These data can be plotted as a line plot or using symbols. The step values on the x axis are unit values, so this protocol is useful for plotting line graphs of image data.

bullet.gif    The rows and columns of a CImage.

bullet.gif    The rows and columns of a displayed image as outlined by the image cursor in a CImageView.

Executing Scripts from Plot Windows

The Execute Script menu command may be used to open and execute a script directly from a Mira Plot Window. When a script is executed from this command, it is automatically sent a CPlotView object named ParentPlotView and a CPlot object named ParentPlot. The ParentPlotView is a CPlotView object that provides access to the window's plot series and other class members. The ParentPlot is a CPlot object attached to the current image in the Plot Window. You can use these names directly in the script or you can rename them, like V = ParentPlotView and P = ParentPlot. A sample script call to be called from a Plot Window is provided named Execute from Plot Window test.lua.

Global Functions

The following functions are provided to expedite plotting of data when the values to be plotted are in arrays (indexed tables). The functions also can plot x error bars and y error bars. The non-class plotting functions are compared here. Also see the Connect, Line, Scatter, and StepLine commands in the CPlotView class.

connect

Creates a plot with markers in which line segments connect the markers.

connecterr

Creates a plot with markers and error bars in which line segments connect the markers.

histplot

Computes the histogram of a 1-dimensional array and plots it as a stepped line.

line

Creates a line plot that connects all points.

lineerr

Creates a line plot and error bars that connects all points.

scatter

Creates a scatter plot using markers.

scattererr

Creates a scatter plot and error bars using markers.

stepline

Creates a plot plot with a stepped line between points.

steplineerr

Creates a plot plot and error bars with a stepped line between points.

Usage

Construction

Object = attach_plotview()

Object = new_plotview()

Object = CPlotView:new()

Destruction

Object:delete()

CPlotView Topics

Plotting a Least Squares Fit

Creation - Non-class Functions

These functions are normally used to create and attach a new CPlotView object as an alternative to the class-based construction methods.

new_plotview

Creates a new instance of the CPlotView class.

attach_plotview

Creates a new CPlotView object attached to the top-most plot window on the Mira desktop. This is equivalent to the Attach class method.

attachlist_plotview

Creates a new CPlotView object attached to a plot window selected from a list of plot windows on the Mira desktop. This is equivalent to the AttachFromList class method.

GetTitle

Returns the title of the Mira Plot Window.

Construction and Destruction - Class Methods

new

Creates a new instance of a CPlotView object.

delete

Deletes the CPlotView object.

Attach

Attaches the top-most window (a Plot window) to the script and creates a new CPlotView object for it.

AttachFromList

Attaches a plot window selected from a list of plot windows on the Mira desktop and returns a new CPlotView object for it.

Close

Closes the CPlotView window.

Plotting Points

These methods work with an plot data that holds points for plotting. This array holds the x,y coordinates and optional errorbars.

Add

Adds an x,y pair and optional error bars to the plot data.

Count

Returns the number of points in the plot data.

Empty

Empties all point data from the plot data.

FindPoint

Returns the index of the point in the plot data nearest an x,y.

GetPlot

Returns a CPlot object for working with the points in a plot series.

GetPtX

Returns the x value of a point.

GetPtObs

Returns the y value of a point.

GetPtErrX

Returns the x errorbar value of a point.

GetPtErrY

Returns the y errorbar value of a point.

Remove

Deletes a point from the plot data.

Plotting Data Arrays

These methods plot the class data matrix into a new window, append an existing plot, or plot it as a new series in an existing window.

Connect

Create a connected plot with markers and line segments from two tables for the x and y values.

Line

Create a line plot with line segments between points from two tables for the x and y values.

Scatter

Create a scatter plot with markers from two tables for the x and y values.

StepLine

Create a stepped-line plot from two tables for the x and y values.

PlotConnected

Creates a connected plot with markers and connecting lines for points in the plot data.

PlotLine

Creates a line plot from points in the plot data. Markers are not drawn.

PlotScatter

Creates a scatter plot of markers from in the plot data.

PlotStepLine

Creates a stepped line plot from points in the plot data.

 

 

PlotPoints

Creates a plot from points in the plot data.

AddPoints

Adds the current series in an existing plot window into the class data matrix.

AddSeries

Adds the class data matrix to an existing plot window as a new plot series.

Plotting Images

These commands create plot data from the columns or rows of images and displayed images.

PlotImageCol

Plots a column from a CImage.

PlotImageRow

Plots a row from a CImage.

PlotCursorCol

Plots the column at the center of the image cursor for images displayed in a CImageView.

PlotCursorColAvg

Plots the averaged column inside the image cursor for images displayed in a CImageView.

PlotCursorColRange

Plots all columns inside the image cursor for images displayed in a CImageView.

PlotCursorRow

Plots the row at the center of the image cursor for images displayed in a CImageView.

PlotCursorRowAvg

Plots the averaged row inside the image cursor for images displayed in a CImageView.

PlotCursorRowRange

Plots all rows inside the image cursor for images displayed in a CImageView.

Working with Plot Series

These methods work with the plot series of the plot window.

CountSeries

Returns the number of plot series.

CountSeriesPoints

Returns the number of plotted points in a plot series.

GetIndex

Returns the index of the current plot series.

GetPlot

Returns a CPlot object for a plot series in the CPlotView object.

SetIndex

Sets the index of the current plot series.

SetDescription

Sets a description for a plot series.

GetDescription

Rereieves the description from a plot series.

Using the Internal Plot Matrix

These methods work with an external CMatrix as the data source for plotting. Each row of the matrix defines a different plot series. Within a row, each (column,value) pair defines an (x,y) value to be plotted. The "x" value is the integral column corresponding to To plot general points, us the non ,atrix methods, like Add, PlotPoints, and AddSeries.

NOTE: Matrix plotting is an old plotting protocol that is discouraged going forward. Support for the matrix plotting protcol and methods listed below will end in 2024.

AddMatrixRange

Appends a range or matrix rows to an existing plot as symbols.

AddMatrixRangeLine

Appends a range of matrix rows to an existing plot as lines.

PlotMatrix

Creates a scatter plot of all rows in a matrix.

PlotMatrixLine

Creates a line plot of all rows in a matrix.

PlotMatrixRange

Creates a multi-series scatter plot from a range of rows in a matrix.

PlotMatrixRangeLine

Creates a multi-series line plot from a range of rows in a matrix.

Related Topics

Script Classes

CPlot class

CImage class

CRect class

CMatrix class

CImageView

Comparison of non-Class Plotting Functions


Mira Pro x64 Script User's Guide, Copyright Ⓒ 2023 Mirametrics, Inc. All Rights Reserved.