-
Notifications
You must be signed in to change notification settings - Fork 33
howto axis title
GRAL follows Java's notion of renderers. The Axis class is a data class and only allows to set values like the minimum and maximum values. It has nothing to do with the rendering on screen.
For the rendering, a class of type AxisRenderer is responsible. Different implementations are available, since you could display the scale linearly (LinearRenderer2D) or logarithmically (LograithmicRenderer2D), for example. The AxisRenderer for a specific axis can be retrieved using Plot.getAxisRenderer(String axisName). The implementations of Plot already have built-in String constants for different axes, such as XYPlot.AXIS_X.
From an AxisRenderer, you can retrieve a Label using getLabel(), which can be rotated, aligned, and so on, and also contains the text that is displayed near the axis. Just set the label text using the method Label.setText(String).
So, if you have an XYPlot instance xyPlot you can use the following code, so set the title of the x-axis:
xyPlot.getAxisRenderers(XYPlot.AXIS_X).getLabel().setText("Text below X-Axis");