// This macro demonstrates how to draw a log-log plot.
// http://en.wikipedia.org/wiki/Log-log_plot

  requires("1.47r");
  n = 1000;
  x = newArray(n);
  y = newArray(n);
  y2 = newArray(n);
  y3 = newArray(n);
  for (i=0; i<n; i++) {
     v = 0.1+i*0.1;
     x[i] = v;
     y[i] = v;
     y2[i] = v*v;
     y3[i] = v*v*v;
  }
  Plot.create("Log-log Plot","X Axis","Y Axis");
  Plot.setLogScaleX();
  Plot.setLogScaleY();
  Plot.setLimits(0.1, n/10, 0.1, n/10);
  Plot.setFrameSize(500, 500);
  Plot.setLineWidth(2);
  Plot.setColor("blue");
  Plot.add("line", x, y);
  Plot.setColor("green");
  Plot.add("line", x, y2);
  Plot.setColor("red");
  Plot.add("line", x, y3);
  setJustification("right");
  x = 0.2;
  y = 0.07;
  Plot.setColor("black");
  Plot.addText("y = x^3", x, y);
  Plot.addText("y = x^2", x, y+0.04);
  Plot.addText("y = x", x, y+0.08);
  x += 0.01;
  y -= 0.01;
  Plot.setColor("red");
  Plot.drawNormalizedLine(x, y, x+0.1, y);
  Plot.setColor("green");
  Plot.drawNormalizedLine(x, y+0.04, x+0.1, y+0.04);
  Plot.setColor("blue");
  Plot.drawNormalizedLine(x, y+0.08, x+0.1, y+0.08);
  Plot.show();