Sets the range for the left and/or right y-axes.


plotSetYRange(&myPlot, y_min, y_max)
plotSetYRange(&myPlot, y_min, y_max[, tic_interval, first_labeled])
  • &myPlot (struct pointer) – A plotControl structure pointer.

  • y_min (scalar, or 2x1 vector) – minimum limit of the y-axis.

  • y_max (scalar, or 2x1 vector) – maximum limit of the y-axis.

  • tic_interval (scalar) – Optional input, the distance between y-axis tick labels.

  • first_labeled (scalar) – Optional input, the value of the first y value on which to place a tick label.


Basic example

// Declare plotControl structure
struct plotControl myPlot;

// Initialize plotControl structure
myPlot = plotGetDefaults("scatter");

// Set left y-axis to to range from 0 to 2
plotSetYRange(&myPlot, 0, 2);

// Create and plot data using our y-range
x = rndu(100, 1);
y = rndu(100, 1);

plotScatter(myPlot, x, y);

Set the range for the left and right y-axes

x = seqa(-3, 0.1, 61);
y = x.^2 ~ sin(x);

struct plotControl plt;
plt = plotGetDefaults("xy");

plotSetWhichYAxis(&plt, "left" $| "right");

// Set the left y-axis range to between -5 and +15,
// and the right y-axis to between -2 and +2
plotSetYRange(&plt, -5|-2, 15|2);

plotXY(plt, x, y);



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 Tools > Preferences > Graphics menu.