简体   繁体   中英

How to set the range for Y-Axis using JfreeChart?

I want to create line chart with XYlinechart but i have a problem with create a Y-axis range. My "Y-Axis" range is start with 0 80 85 90 95 100

This is my code:

// for x-axis
    final NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    domainAxis.setRange(0, 90); 
    domainAxis.setTickUnit(new NumberTickUnit(10)); 
    domainAxis.setVerticalTickLabels(true); 
// for y-axis
    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); 
    rangeAxis.setRange(0, 100); 
    rangeAxis.setTickUnit(new NumberTickUnit(......)); 

    return chart;

Please guide me with your valuable suggestions. Thanks in advance!!!

Calling setTickUnit(new NumberTickUnit(0.5)) works as expected in this example , illustrated below. Please edit your question to include an sscce that exhibits the problem you describe.

图片]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM