Solved

JFreeChart: Axis range

Posted on 2011-09-26
7
413 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
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

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

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
table example 4 32
hibernate example for saving data 19 57
spring jars download 1 36
How to convert from xls to xlsx using java 7 56
For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
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…
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 learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…

820 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