histplot


The histplot function computes the histogram of an array and graphs it as a stepped line plot. This is an efficient non-class equivalent to using several lines of script to create a histogram, calculate the binning parameters, and plot it. The histogram object is computed internally and is not available to the script.

This function creates a new plot window and returns a CPlotView object and a CPlot object for the plot and the plot series it creates. These objects can be used to enhance or add to the plot or extract plot data for further analysis.

Syntax

CPlotView, CPlot = histplot( t )

CPlotView, CPlot = histplot( t, sLabelX )

CPlotView, CPlot = histplot( t, sLabelX, sLabelY )

CPlotView, CPlot = histplot( t, sLabelX, sLabelY, sCaption )

CPlotView, CPlot = histplot( t, sLabelX, sLabelY, sCaption, sWindowTitle )

bullet.gif    t is a 1-dimensional array containing the values to plot as a histogram.

bullet.gif    sLabelX is an optional label for the x axis.

bullet.gif    sLabelY is an optional label for the y axis.

bullet.gif    sCaption is an optional plot caption.

bullet.gif    sWindowTitle is an optional plot window title.

bullet.gif    Parameters that are nil or missing to the right adopt default values.

Return values:

bullet.gif    CPlotView is returned as a new CPlotView object attached to the plot window. It is nil on failure.

bullet.gif    CPlot is returned as a new CPlot object attached to the current plot series. It is nil on failure.

Remarks

This function creates a quick plot using just one line of code. The returned values of V and P provide access to the plot window and plotted data. You can also change the plot properties including the marker attributes, labels, scaling, and others using commands such as Series Attributes and Plot Attributes.

Only the first argument, the array to plot as a histogram, is required. If you want to use the other arguments, you must include a nil placeholder to fill any holes between the arguments.

Examples

The script below plots the histogram of random Guassian deviates. Since none of the optional parameters is used, only the array needs to be specified. The plot will show a Gaussian distribution with noise. The greater the number of deviates computed, the lower the statistical noise.

x = gaussdev( 10000, 1000, 33 )

-- 10,000 deviates with mean = 1000 and sdev = 33

histplot( x )

-- create the histogram and plot it

Related Topics

plot, scatter, line, connect, stepline, CPlotView class, CHistogram class, Plotting Functions


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