Back: 3.2.1.3 Forcing square limits Forward: 3.2.3 gridxy     FastBack: 3. Graphics Up: 3.2 Plot limits and relatives FastForward: 4. Embedding Compiled Routines Inside Yorick         Top: Yorick: An Interpreted Language Contents: Table of Contents     About: About This Document

3.2.2 logxy

You may want to choose among log, semi-log, or ordinary linear scale axes. Use the logxy command:

 
logxy, 1, 1       // log-log plot
logxy, 1, 0       // semi-log plot, x logarithmic
logxy, 0, 1       // semi-log plot, y logarithmic
logxy, 0, 0       // linear axis scales

You can also omit the x or y flag to leave the scaling of that axis unchanged:

 
logxy, , 1

changes the y axis to a log scale, leaving the x axis scaling unchanged.

The flags returned by the limits function include the current logxy settings, if you need them in a program.

Zero or negative values in your data have no catastrophic effects with log axis scaling; Yorick takes the absolute value of your data and adds a very small offset before applying the logarithm function. As a side effect, you lose any indication of the sign of your data in a log plot. If you insist you need a way to get log axis scaling for oscillating data, write a function to treat negative points specially. For example, to draw positive-y portions solid and negative-y portions dashed, you might use a function like this:

 
func logplg(y, x)
{
  s = sum(y>=0.);  /* number of positive-y points */
  n = numberof(y);
  if (s) plg, max(y,0.), x, type="solid";
  if (s<n) plg, min(y,0.), x, type="dash";
}

You always have the option of plotting the logarithm of a function, instead of using log axes:

 
logxy,0,1; plg,y,x

plots the same curve as

 
logxy,0,0; plg,log(y),x

The log axis scaling merely changes the position of the ticks and their labels; the y axis ticks will look like a slide rule scale in the first case, but like an ordinary ruler in the second.


Back: 3.2.1.3 Forcing square limits Forward: 3.2.3 gridxy     FastBack: 3. Graphics Up: 3.2 Plot limits and relatives FastForward: 4. Embedding Compiled Routines Inside Yorick         Top: Yorick: An Interpreted Language Contents: Table of Contents     About: About This Document