How to implement Linear-Logarithmic axis (split axis)?

A free public discussion forum for the JFreeChart class library.

How to implement Linear-Logarithmic axis (split axis)?

Postby jsnel » Mon Oct 29, 2007 8:18 pm

I was wondering what would be the easiest way to implement a linear-logarithmic domain axis in JFreeChart, to the best my knowledge this hasn't been done yet.

I don't mean one linear and a second logarithmic axis but I mean a combination of the two, for instance the first part linear and starting a certain value the rest of the axis logarithmic.

For example:
x =
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 (5) 10 (50) 100 (500) 1000

Has anyone got any experience with this? Do you David Gilbert have any plans of implementing a split-axis feature?
jsnel
 
Posts: 19
Joined: Thu Apr 19, 2007 12:00 pm

Re: How to implement Linear-Logarithmic axis (split axis)?

Postby jsnel » Wed Apr 28, 2010 4:53 pm

I guess it's time for me to finally get back at this post from a few years ago. From the lack of responses I guess that something like a Linear-Logarithmic axis is not the most popular of features. However, in the particular branch of science I'm involved in - analysis of time-resolved spectroscopy data - it is widely used to present results from fitted data.


Presenting results
This is because in the studies of photophysics, photochemistry and photobiology we attempt to investigate the dynamic properties of very complex systems by studying phenomena that occur on very varied time scales, ranging from "ultra-fast time scales" (pico, or even femo-seconds) to relatively "longed lived time-scales" (nano-seconds, mili-seconds or even seconds). Apart from the actual data-fitting itself, an important aspect of analysis is how to present these kind of results in such a way that still makes sense and at the same time is useful to the researcher doing the analysis.


Limitation of JFreeChart
If we would use a simple linear axis then Figure 1 demonstrates what the results would look like. As you can see ... well, not everything can be seen here, there are clearly some strange artifacts at time zero. This is because most of the physics is happening in the first few picoseconds, but the total dataset stretches out for hundreds of picoseconds. Zooming in does not help much either, the first 2 spectra remain hardly visible because they are on the 0.1 to 1 picoseconds timescale. Plotting this on a logarithmic scale is also not an option.

Image
Figure 1: Time-resolved spectra on linear scale


Introduction of LinLogAxis
Instead what we do is plot the first few picoseconds on a linear time scale, occupying about 40% of the total axis space and plot the rest on a logarithmic time axis occupying the remaining space on the axis. In order to realize this functionality in JFreeChart I had to write a new LinLogAxis, deriving from ValueAxis, and a custom NumberFormatter. The results from the implementation of this new class are displayed in Figure 2. As you can see the shapes of the first 2 spectra are now clearly visible while no information from the slower spectra is lost.

Image
Figure 2: Time-resolved spectra on linear-logarithmic scale

Reinventing the wheel
If you came this far in reading my post, you might ask yourself, what is the reason for posting this? Well the answer is simple ....

Recently I saw a physicsworld.com webinar titled "A Crack in the Code: Why software fails in scientific research, and how to fix it".
The description was for this webinar was:
Millions of lines of code have been developed to support scientific research. Although an increasingly important part of almost all research projects, most of this software is barely fit for purpose compared with equivalent systems in the commercial world. The code is hard to understand and maintain, lacking documentation and version control, and is continually "re-invented" as the software developers move on to new projects.


Well, I also developed this linear-logarithmic "LinLogAxis" axis as part of my own research, and am about to move on to a new project. But having watched this seminar (briefly) I know what to do .... before I move on, I hope to contribute this new functionality to the JFreeChart code base - or at least put it out there in the public domain depending on the feedback. In the next few weeks I will be doing some internal testing and cleaning up to ready it for public release. In the meantime I was wondering the following ....

Feedback
Is there anyone out there who is working with completely different kind of data but for whom this kind of functionality in JFreeChart would make a welcome addition? I ask, because I designed this LinLogAxis class with only one kind of data in mind, but maybe with a few minor modifications it might be made suitable for other kinds of data as well. Better to make those changes now than reinvent the wheel again ...
Creator of Glotaran, a software program developed for global and target analysis of time-resolved spectroscopy and microscopy data. Big fan of JFreeChart.
jsnel
 
Posts: 19
Joined: Thu Apr 19, 2007 12:00 pm

Re: How to implement Linear-Logarithmic axis (split axis)?

Postby omricohen » Tue Apr 17, 2012 9:38 am

Hi,

I know this thread is a little old...

Can you please provide the code for the 'LinLogAxis' class.

Regards,
Omri
omricohen
 
Posts: 4
Joined: Tue Apr 17, 2012 8:43 am

Re: How to implement Linear-Logarithmic axis (split axis)?

Postby jsnel » Tue Apr 17, 2012 10:18 am

Hello Omri,

This class is part of the JFreeChartCustom module in the Glotaran project currently hosted on kenai.com.

Specifically it is implemented in the LinLogAxis.java class. For the number formatting I use a custom class:
LinLogFormat.java.
Please note that I cannot guarantee that the current implementation is bug free, especially on aspects such as zooming around the transition between the two axes and tick mark generations, but it is well tested 'in the field'.
Someone more experienced in JFreeChart could probably clean it up and integrate it into the JFreeChart library, which I would appriciate. I apologize for not changing any copyright notices, I'm not sure if I should have.

To see the LinLogAxis implementation in action, see the screenshots page on the website. Here's another example:

Image

Notice how the x-axis is linear from -2 to 2 and logarithmic thereafter.
Creator of Glotaran, a software program developed for global and target analysis of time-resolved spectroscopy and microscopy data. Big fan of JFreeChart.
jsnel
 
Posts: 19
Joined: Thu Apr 19, 2007 12:00 pm

Re: How to implement Linear-Logarithmic axis (split axis)?

Postby omricohen » Tue Apr 17, 2012 10:56 am

Thanks!

I'll look into it.

Omri
omricohen
 
Posts: 4
Joined: Tue Apr 17, 2012 8:43 am


Return to JFreeChart - General

Who is online

Users browsing this forum: Majestic-12 [Bot], Yahoo [Bot] and 7 guests