Solved

JFreeChart: Axis range

Posted on 2011-09-26
7
403 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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
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…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
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:

757 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

21 Experts available now in Live!

Get 1:1 Help Now