jfree / jfreechart

A 2D chart library for Java applications (JavaFX, Swing or server-side).
http://www.jfree.org/jfreechart/
GNU Lesser General Public License v2.1
1.22k stars 462 forks source link

Secondary axis as a nonlinear function of the first axis #274

Open Niloooooooo opened 2 years ago

Niloooooooo commented 2 years ago

Hi, I am trying to create a plot with two X axes. The secondary axis values are the inverse of the the first axis values, e.g. the first x axis varies from 0.0004 to 0.001, with tick unit 0.001, and the inversed one from 2500 to 1000. I can create an inverted secondary axis, but I wonder how I can adjust the tick mark units for the secondary axis which are varying to even values, as shown in the figure. I would be very grateful if you could help me. Thank you very much in advance!

(https://user-images.githubusercontent.com/98088105/150792063-7fa733b6-aa0a-4c7b-8ac9-f844ff558f1c.png)

trashgod commented 2 years ago

The examples shown in Multiple axes on the same data use an AxisChangeListener.

Niloooooooo commented 2 years ago

The examples shown in Multiple axes on the same data use an AxisChangeListener.

Thank you, but it does not work like this since the values in the secondary axis are the inverse values of x values, not linear function of them. The values did not match the corresponding values on the x Axis. I could replace the tick unit labels and create the following figure, but I cannot scale it with even numbers as shown in the previous figure.

(https://user-images.githubusercontent.com/98088105/150933097-2765f3ee-f73a-491a-ab51-fcafc152994c.png)

trashgod commented 2 years ago

Maybe custom TickUnits like this?