JFreeChart domain/range axes defined
Asked Answered
G

1

8

Could somebody provide a simple explanation of the JFreeChart axis-types?

  1. First, we have the axes that are based on the class hierarchy (ValueAxis, CategoryAxis, lots of subclasses)

  2. We also have the "domain axis" versus "range axis" distinction (only for xy plots?). It is not entirely clear how these relate to the class-hierarchy-based axes. These are not classes but there are setDomainAxis and setRangeAxis methods in XYPlot.

  3. Visually I would think in horizontal and vertical axes, I am not sure how these are related to the previous concepts (is "domain" always horizontal?). I think that the x-axis is horizontal and the y-axis vertical, but I am not sure whether this is always the case with XYPlot.

EDIT: I tried to study both the API docs and the developer guide. The API docs just give a hierarchy of classes, but it is not clear when and how to use them. The developer guide also gives no definition or explanation of "domain axis" and "range axis", it just uses these terms. I admit that the question is broad, it is because I could not find this basic information anywhere. I wanted to have a general understanding, but my most important question at the moment is what determines what gets to be on the horizontal/vertical axis (is "domain" always horizontal? if not how to set it?) because I am getting some crazy results and I don't know where to start the debugging. It is also not clear whether I should use CombinedRangeXYPlot or CombinedDomainXYPlot if I want the two plots to be placed one above the other.

EDIT2: Although this was not answered, I found out in the meantime what determines whether the domain axis is horizontal: the PlotOrientation setting. This setting (on the level of combined plot) also determines whether CombinedRangeXYPlot/CombinedDomainXYPlot arrange the two plots horizontally or vertically.

Gauhati answered 10/8, 2012 at 13:29 Comment(1)
Sorry, this question is overly broad, immanent in the API and illustrated in the developer guide. Addendum: Please edit your question to focus on the problem that prompts this inquiry.Sheena
K
11

In a XYPlot, every series that you are displaying represents a discrete function f[t] with a discrete set of t's {t1, t2, ..., tn} and their corresponding values {f[t1], f[t2], ..., f[tn]}.

  • The domain of the function is holding all possible values of t.
  • The range of the function holds all possible values of the function f[t].

The important thing here is that there can be multiple points in the function with the same value in the range axis, but every point of the function has to have a unique value in the domain axis. For instance: Bananas can have the same prize as Apples, but there can not be two prizes for a Banana (tell that to the brokers! :P).

Usually, the horizontal axis is the domain axis, but that can also be changed.

Then you have the class Axis which holds a lot of possible types of visual representations of axes (logarithmic/linear/category/no labels/gridlines/blue colored axis line...).

So in summary: Domain and range are mathematical definitions and pose some constraints on the displayed data. The terms are used for a special kind of data (the classical form of a function that everybody learns in basic school). They have nothing to do with their visual represenation. So the range as well as the domain axis of a plot can be defined to be a CategoryAxis, a NumberAxis, a LogarithmicAxis or something else.

EDIT (for completeness): You can change the orientation of the plot (i.e. define, which of the axes is the range axis) using PlotOrientation.VERTICAL/PlotOrientation.HORIZONTAL.

Keelin answered 10/8, 2012 at 15:20 Comment(3)
Thank you! So, you are saying that the distinction between domain and range axes applies only for XYPlots, which in fact should be named something like MathematicalFunctionPlot because it cannot display arbitrary xy values within a series? I am accepting this answer as long as nobody disagrees with you...Gauhati
+1 To see the difference, try PlotOrientation.HORIZONTAL on this minimal reproducible example().Sheena
@user1235867 That's exactly what it is. As trashgod mentioned, you can change the orientation of the plot (i.e. define, which of the two axes is the domain axis (which can not hold more than one point per value)). Technically, the domain/range distiction also holds for some other types of plots (for example CategoryPlot).Keelin

© 2022 - 2024 — McMap. All rights reserved.