plotSetYLabel#
Purpose#
Controls the settings for the y-axis label on a graph.
Format#
- plotSetYLabel(&myPlot, label[, font[, fontSize[, fontColor]]])#
- Parameters:
&myPlot (struct pointer) – A
plotControl
structure pointer.label (string) – the new label or labels. If you are using more than one y-axis, the first element of the 2x1 label string array will set the label for the left y-axis and the second element will set the label for the right y-axis. This may contain HTML for the creation of Greek letters, mathematical symbols and text formatting.
font (string) – Optional argument, font or font family name.
fontSize (scalar) – Optional argument, font size in points.
fontColor (string) – Optional argument, named color or RGB value.
Examples#
Example 1: Basic usage#
// Declare plotControl structure
struct plotControl myPlot;
// Initialize plotControl structure
myPlot = plotGetDefaults("hist");
// Set the y-axis label, label font, font size and color
plotSetYLabel(&myPlot, "Time (sec)", "verdana", 10, "black");
// Create data
x = rndn(1e5, 1);
// Plot a histogram of the x data spread over 50 bins
plotHist(myPlot, x, 50);
Example 2: Setting both Y-axes#
// Create with different Y-ranges
x = seqa(1, 1, 5);
y = { 98 1.5,
92 0.9,
97 1.3,
94 2.1,
95 2.4 };
// Declare plotControl structure
struct plotControl myPlot;
// Initialize plotControl structure
myPlot = plotGetDefaults("xy");
// Set the first curve to use the left y-axis and the second curve to use the right
plotSetWhichYAxis(&myPlot, "left" $| "right");
// Set the left and right y-axis labels
plotSetYLabel(&myPlot, "Number of subjects"$|"Percent classified");
// Plot the data
plotXY(myPlot, x, y);
Example 3: HTML#
You may add Greek letters, mathematical symbols, subscript and superscript to your axis labels using HTML. To add HTML to a label, you need to wrap the text to be interpreted as HTML in HTML tags.
label_string = "<html>β</html>";
plotSetYLabel(&myPlot, label_string);
The code above will add the letter \(\beta\) to the y-axis label. The HTML 'sup'
tag will create superscript and the 'sub'
tag will create subscript. For example:
label_string = "<html>σ<sup>2</sup></html>";
plotSetYLabel(&myPlot, label_string);
will add \(\sigma^2\) to your y-axis label. While,
label_string = "<html>Y<sub>t-1</sub></html>";
plotSetYLabel(&myPlot, label_string);
will create \(Y_{t-1}\)
Example 4: Latex#
You can use Latex to add equations to axis labels. Note that double-backslashes must be used as shown below.
// Tell GAUSS to interpret the axis label text as Latex
plotSetTextInterpreter(&myPlot, "Latex", "axes");
// Add Latex axis label.
plotSetYLabel(&myPlot, "\\sqrt{\\lambda}");
The code above will add \(\sqrt{\lambda}\) to your y-axis label.
Remarks#
Note
This function sets an attribute in a plotControl
structure. It does not
affect an existing graph, or a new graph drawn using the default
settings that are accessible from the
menu.
The axis updated by this function is determined by the value previously specified by plotSetActiveY()
. The accepted values are "left"
(default), "right"
, and "both"
.
Future calls to plotSetActiveY()
will not retroactively change the values of a previously modified axis.
See also
Functions plotSetActiveX()
, plotSetXLabel()
, plotSetXTicInterval()
, plotSetXTicLabel()
, plotSetZLabel()
, plotSetLinePen()
, plotSetGridPen()