Solved

JFreeChart: Axis range

Posted on 2011-09-26
7
429 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

 

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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Suggested Courses

615 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