Axis range limitation + Vertical Tick Width

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
hugues
Posts: 18
Joined: Tue Jul 04, 2006 8:59 am
Contact:

Axis range limitation + Vertical Tick Width

Post by hugues » Wed Dec 20, 2006 6:17 pm

Hi,

when I want to display small values, I have no information on my curve's range on the Y axis.
See images :

this one is still OK : 1e-7 * sin(x)
http://img470.imageshack.us/my.php?imag ... es2gu9.jpg

this one is not OK : 1e-8 * sin(x)
http://img217.imageshack.us/my.php?imag ... es1gh9.jpg

Thank you for your help.

Regards.

Hugues Legardeur.
Last edited by hugues on Wed Jan 10, 2007 10:25 am, edited 1 time in total.
SAMTECH, Integrating CAE towards Professional Solutions : www.samcef.com

hugues
Posts: 18
Joined: Tue Jul 04, 2006 8:59 am
Contact:

Post by hugues » Fri Dec 22, 2006 5:26 pm

may be just an other renderer could do the job ?

any idea ?

Hugues
SAMTECH, Integrating CAE towards Professional Solutions : www.samcef.com

hugues
Posts: 18
Joined: Tue Jul 04, 2006 8:59 am
Contact:

Post by hugues » Wed Jan 03, 2007 2:04 pm

up :cry:
SAMTECH, Integrating CAE towards Professional Solutions : www.samcef.com

hugues
Posts: 18
Joined: Tue Jul 04, 2006 8:59 am
Contact:

Post by hugues » Fri Jan 05, 2007 5:20 pm

A solution seems to be in the pipe (I hope so) with those few lines :
NumberFormat aDF = new DecimalFormat("##0.#####E0");
NumberTickUnit aNTU = new NumberTickUnit(10.e-10);
NumberAxis aAxis = (NumberAxis) myXYPlot.getRangeAxis();
aAxis.setNumberFormatOverride(aDF);
aAxis.setTickUnit(aNTU);
I ll have to program that properly next week.

Hugues
SAMTECH, Integrating CAE towards Professional Solutions : www.samcef.com

hugues
Posts: 18
Joined: Tue Jul 04, 2006 8:59 am
Contact:

Post by hugues » Wed Jan 10, 2007 10:08 am

For the next version of my software, I will try this solution :

1. I use an Homemade TickUnits : FunctionJFreeTickUnits
DecimalFormat aDf11 = new DecimalFormat("##0.#####E0");

// we can add the units in any order, the TickUnits collection will
// sort them...
add(new NumberTickUnit(1.e-20, aDf11));
add(new NumberTickUnit(1.e-19, aDf11));
add(new NumberTickUnit(1.e-18, aDf11));
add(new NumberTickUnit(1.e-17, aDf11));
add(new NumberTickUnit(1.e-16, aDf11));
add(new NumberTickUnit(1.e-15, aDf11));
add(new NumberTickUnit(1.e-14, aDf11));
add(new NumberTickUnit(1.e-13, aDf11));
add(new NumberTickUnit(1.e-12, aDf11));
add(new NumberTickUnit(1.e-11, aDf11));
add(new NumberTickUnit(1.e-10, aDf11));
add(new NumberTickUnit(1.e-9, aDf11));
add(new NumberTickUnit(1.e-8, aDf11));
add(new NumberTickUnit(0.0000001, aDf1));
add(new NumberTickUnit(0.000001, aDf2));
add(new NumberTickUnit(0.00001, aDf3));
add(new NumberTickUnit(0.0001, aDf4));
add(new NumberTickUnit(0.001, aDf5));
add(new NumberTickUnit(0.01, aDf6));
add(new NumberTickUnit(0.1, aDf7));
add(new NumberTickUnit(1, aDf8));
add(new NumberTickUnit(10, aDf8));
add(new NumberTickUnit(100, aDf8));
add(new NumberTickUnit(1000, aDf8));
add(new NumberTickUnit(10000, aDf8));
add(new NumberTickUnit(100000, aDf8));
add(new NumberTickUnit(1000000, aDf9));
add(new NumberTickUnit(10000000, aDf9));
add(new NumberTickUnit(100000000, aDf9));
add(new NumberTickUnit(1000000000, aDf10));
add(new NumberTickUnit(10000000000.0, aDf10));
add(new NumberTickUnit(100000000000.0, aDf10));
add(new NumberTickUnit(1.0e12, aDf11));
add(new NumberTickUnit(1.0e13, aDf11));
add(new NumberTickUnit(1.0e14, aDf11));
add(new NumberTickUnit(1.0e15, aDf11));
add(new NumberTickUnit(1.0e16, aDf11));
add(new NumberTickUnit(1.0e17, aDf11));
add(new NumberTickUnit(1.0e18, aDf11));
add(new NumberTickUnit(1.0e19, aDf11));
add(new NumberTickUnit(1.0e20, aDf11));
2. I modify the AutoRangeMinimumSize
//
// new Tick Units for low values (under 1e-8)
theAxis.setStandardTickUnits(new FunctionJFreeTickUnits());
//
// set the lowest limit of the auto range lower the the default (1e-8)
theAxis.setAutoRangeMinimumSize(1.0e-19);
resultat http://img205.imageshack.us/my.php?image=gr10pj6.jpg
SAMTECH, Integrating CAE towards Professional Solutions : www.samcef.com

hugues
Posts: 18
Joined: Tue Jul 04, 2006 8:59 am
Contact:

Vertical Tick Width

Post by hugues » Wed Jan 10, 2007 10:24 am

My other problem is to control the vertical tick width in order to align 2 graphics.
See picture :
http://img206.imageshack.us/my.php?image=gr11jk7.jpg

I tried :
myXYPlot.getRangeAxis().setFixedDimension(30.);
But it doens't give the expected result.

What else could I try ?

Thanks a lot.

Hugues.
SAMTECH, Integrating CAE towards Professional Solutions : www.samcef.com

cme_st
Posts: 31
Joined: Thu Aug 31, 2006 9:02 am
Location: Lappeenranta, Finland

Post by cme_st » Wed Jan 10, 2007 11:57 am

Try org.jfree.chart.plot.CombinedDomainXYPlot. It combines you two plots. You can find some examples for combined plots in the JFreeChart examples.

Chris

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Re: Vertical Tick Width

Post by david.gilbert » Wed Jan 10, 2007 12:01 pm

hugues wrote:I tried :
myXYPlot.getRangeAxis().setFixedDimension(30.);
But it doens't give the expected result.

What else could I try ?
You'll need to set the fixed dimension on both range axes (that is, in both plots). Also, I don't know how wide you need to make it, but it probably needs to be something wider than 30 Java2D units.
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

hugues
Posts: 18
Joined: Tue Jul 04, 2006 8:59 am
Contact:

Re: Vertical Tick Width

Post by hugues » Wed Jan 10, 2007 12:15 pm

cme_st wrote:Try org.jfree.chart.plot.CombinedDomainXYPlot. It combines you two plots. You can find some examples for combined plots in the JFreeChart examples.
Chris
This will probably be the solution for a future version. But no time to do that at the moment.
david.gilbert wrote:
hugues wrote:I tried :
myXYPlot.getRangeAxis().setFixedDimension(30.);
But it doens't give the expected result.
What else could I try ?
You'll need to set the fixed dimension on both range axes (that is, in both plots). Also, I don't know how wide you need to make it, but it probably needs to be something wider than 30 Java2D units.
I used setFixedDimension on both chart of course. I will try wider values.

thanks all.
SAMTECH, Integrating CAE towards Professional Solutions : www.samcef.com

hugues
Posts: 18
Joined: Tue Jul 04, 2006 8:59 am
Contact:

Post by hugues » Wed Jan 10, 2007 3:54 pm

Hello again,

the method "setFixedDimension" did not suit my request so I found a solution which was to create a new class over "NumberAxis" to redefine the method "findMaximumTickLabelWidth" (from ValueAxis). This method retruns now a constant value.
public class FunctionJFreeNumberAxis extends NumberAxis {

public FunctionJFreeNumberAxis() {
this(null);
}

public FunctionJFreeNumberAxis(String theLabel) {
super(theLabel);
}

protected double findMaximumTickLabelWidth(List ticks, Graphics2D g2, Rectangle2D drawArea, boolean vertical) {
return 75;
}
}
Thanks again for your Help.

Hugues
SAMTECH, Integrating CAE towards Professional Solutions : www.samcef.com

Locked