Solved

JFreeChart: Axis range

Posted on 2011-09-26
7
407 Views
Last Modified: 2012-05-12
I want to fix the min and max value of my Y axis.

If possible, please provide some sample code. Thanks!
0
Comment
Question by:dshrenik
  • 5
  • 2
7 Comments
 
LVL 47

Accepted Solution

by:
for_yan earned 500 total points
ID: 36602584
Yes, that is a bit painful.
This ishow I finally was setting axis range in this trail:

http://www.experts-exchange.com/Programming/Languages/Java/Q_27020858.html?sfQueryTermInfo=1+10+30+axi+jfreechart+yan

                      NumberAxis ax1 = new  NumberAxis("Depth");
                ax1.setAutoRangeIncludesZero(false);
         ax1.setAutoRangeStickyZero(false);
     //   ax1.setAutoRange(true);
           ax1.setRange(6800.0,7500.0);
        XYPlot subplot1 = new XYPlot(dataset30, new NumberAxis("Gamma"),ax1, renderer1);
        NumberAxis axis1 = (NumberAxis) subplot1.getRangeAxis();
        System.out.println("axis1" + axis1);
        axis1.setAutoRangeIncludesZero(false);
        axis1.setTickLabelFont(new Font("Monospaced", Font.PLAIN, 11));
        axis1.setLabelFont(new Font("SansSerif", Font.PLAIN, 11));
        axis1.setAutoRangeIncludesZero(false);

Open in new window

0
 
LVL 47

Expert Comment

by:for_yan
ID: 36602591

You want to use these calls:
               ax1.setAutoRangeIncludesZero(false);
         ax1.setAutoRangeStickyZero(false);
as by default they tend to include zero  in the range.
Even with that it is kind of not very straightforward.

Try to sdo it in your plot - if it does not work we'll try together

0
 
LVL 47

Expert Comment

by:for_yan
ID: 36602608


Also look here - they have sdifferent suggestions but they maybe had different case:
http://stackoverflow.com/questions/7231824/setting-range-for-x-y-axis-jfreechart
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:dshrenik
ID: 36603324
Just this was enough. Thanks!
NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
		rangeAxis.setRange(0,600);

Open in new window

0
 
LVL 47

Expert Comment

by:for_yan
ID: 36603639
As you need to include zero - it should raise less issues.
I wanted without zero - so I remeber I was struggling for some time
0
 

Author Comment

by:dshrenik
ID: 36603921
Sure. Thanks!
0
 
LVL 47

Expert Comment

by:for_yan
ID: 36604270
You are always welcome.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
bitbucket vs gitbucket 3 57
get weblogic logged in user in java 2 58
Image decoding from Camera 3 72
ForLoop Example 3 40
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now