Class Graph.LogAxis

java.lang.Object
org.bzdev.graphs.Graph.Axis
org.bzdev.graphs.Graph.LogAxis
Enclosing class:
Graph

public static class Graph.LogAxis extends Graph.Axis
Class to provide a logarithmic axis. To produce logarithmic plots, the logarithm to base 10 of values must be used as the graph coordinate space coordinates. This can be done for the x coordinate, the y coordinate, or both. Thus, the coordinates for the values 1, 10.0, and 100.0 are 0.0, 1.0, and 2.0 respectively.

Creating a logarithmic axis requires the user to provide the following fields in a constructor:

  • the X coordinate in graph coordinate space for the start of an axis (which will be the logarithm to base 10 of a value when X uses a logarithmic scale).
  • the Y coordinate in graph coordinate space for the start of an axis (which will be the logarithm to base 10 of a value when Y uses a logarithmic scale).
  • The direction.
  • The length of the axis in graph coordinate space units (this will be the absolute value of the difference of the logarithms to base 10 of the starting and ending value for the axis when a logarithmic scale is used for the corresponding coordinate).
  • The tick increment. This determines the number of possible ticks per decade, represented by the decade [1.0, 10.0]. For whole numbers in this decade, there are 9 possible tick locations past the initial point as the value of the initial point is 1.0. By contrast, for a linear axis, there are 10 locations. The difference in the count is due to the linear case starting at 0.0 while the logarithmic case starts at 1.0. Valid values for the tick increment are:
    • 9.0. In this case, ticks occur at at powers of 10.
    • 1.0 divided by a positive integer m. In this case, when n is an integer in the range [1, 10], for a power of 10 multiplied by n, there will be multiple ticks between successive values when m is larger than 1.0. When m is 1.0, ticks occur at at powers of 10 multiplied by 2, 3, 4, 5, 6, 7, 8, 9, 10.
  • counterclockwise. This is a boolean value. When true, tick marks on the side of the axis corresponding to a counterclockwise rotation; when false, on the side corresponding to a clockwise rotation.
Note that the constructor does not include a tick base: this field is computed and passed to the constructor for the superclass of this class. Setting up tick marks is discussed in the documentation for Graph.TickSpec.

The methods Graph.Axis.setWidth(double), Graph.Axis.setColor(Color), Graph.Axis.setLabel(String), Graph.Axis.setLabelOffset(double), Graph.Axis.setFontParms(Graph.FontParms), and Graph.Axis.addTick(Graph.TickSpec) can be used as described in the documentation for the class Graph.Axis. For details on how to add ticks.

  • Constructor Details

    • LogAxis

      public LogAxis(double logStartX, double logStartY, Graph.Axis.Dir dir, double logLength, double tickIncr, boolean counterclockwise) throws IllegalArgumentException
      Constructor.
      Parameters:
      logStartX - the starting X position in graph coordinate space
      logStartY - the starting Y position in graph coordinate space
      dir - the direction of the axis
      logLength - the length of the axis in graph coordinate space
      tickIncr - the tick increment before a logarithm to base 10 is computed, for the range [1.0, 10.0], with legal values of either 9.0 or 1.0/n, where n is a positive integer
      counterclockwise - the angular direction to follow to reach a graph's labels and tick marks
      Throws:
      IllegalArgumentException - an input argument was not valid, most likely the tickIncr
  • Method Details

    • initialIndex

      public long initialIndex()
      Description copied from class: Graph.Axis
      Get the initial index. This is the index for the first tick that can be displayed.
      Overrides:
      initialIndex in class Graph.Axis
      Returns:
      the initial index
    • axisValue

      public double axisValue(long ind)
      Description copied from class: Graph.Axis
      Get the value for a point on an axis for which there may be a tick. The value is the one used to print a label for ticks that label their coordinates.
      Overrides:
      axisValue in class Graph.Axis
      Parameters:
      ind - the index
      Returns:
      the value corresponding to the index
    • axisCoord

      public double axisCoord(long ind)
      Description copied from class: Graph.Axis
      Get the coordinate value for a point on an axis for which there may be a tick. This will determine the x or y coordinate at which a tick mark may appear.
      Overrides:
      axisCoord in class Graph.Axis
      Parameters:
      ind - the index
      Returns:
      the value in graph coordinate space corresponding to the index