Skip to content

howto change origin

Erich Seifert edited this page Sep 21, 2017 · 3 revisions

How can I change the origin of a plot?

You can use the intersection property to move the origin to a certain position. This setting defines the intersection point of one axis with another (perpendicular) axis.

As an example, we take a standard x-y plot, which has its origin at (0, 0) by default. To move its origin to (–4, –2), we can use the following code:

// The x axis intersects the y axis at –2
AxisRenderer rendererX = plot.getAxisRenderer(XYPlot.AXIS_X);
rendererX.setIntersection(-2);
// The y axis intersect the x axis at –4
AxisRenderer rendererY = plot.getAxisRenderer(XYPlot.AXIS_Y);
rendererY.setIntersection(-4);

See also

How-to Move the y axis completely to the left or to the right

Clone this wiki locally