[英]jfree chart set show range x value in chart
I want to create a image file using jfreechart heres my code : 我想使用jfreechart这是我的代码来创建图像文件:
XYSeries xydata = new XYSeries("fitness");
for (int i = 0; i < it; i++) {
xydata.add(i,fitness[i]);
//System.out.println(fitness[i]);
}
XYSeriesCollection fitness_series = new XYSeriesCollection();
fitness_series.addSeries(xydata);
//Use createXYLineChart to create the chart
JFreeChart XYLineChart = ChartFactory.createXYLineChart("fitness", "iteration", "fitness", fitness_series, PlotOrientation.VERTICAL, true, true, false);
/* Step -3 : Write line chart to a file */
int width = 640; /* Width of the image */
int height = 480; /* Height of the image */
File XYlineChart = new File("xy_line_Chart_fitness.png");
ChartUtilities.saveChartAsPNG(XYlineChart, XYLineChart, width, height);
and the result is : 结果是:
but the y axis start with the first value of my set not a 0 like in the picture shown above, how do i set it to my own specific value ? 但是y轴从我设置的第一个值开始,而不是如上图所示的0,我如何将其设置为自己的特定值? or the lowest x data that i have ?
还是我拥有的最低x数据?
The NumberAxis class will, by default, calculate its range from your actual data values as well as including zero by default. 默认情况下,NumberAxis类将根据您的实际数据值计算其范围,并且默认情况下包括零。 There is a flag that you can set to control whether or not zero is included:
您可以设置一个标志来控制是否包含零:
http://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/axis/NumberAxis.html#setAutoRangeIncludesZero-boolean- http://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/axis/NumberAxis.html#setAutoRangeIncludesZero-boolean-
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.