Solved

JFreeChart: Axis range

Posted on 2011-09-26
7
412 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
ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

 

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

777 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