[英]how to set first and last tick mark and x axis value in jfree bar chart x-axis
[英]jfree chart set show range x value in chart
我想使用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);
結果是:
但是y軸從我設置的第一個值開始,而不是如上圖所示的0,我如何將其設置為自己的特定值? 還是我擁有的最低x數據?
默認情況下,NumberAxis類將根據您的實際數據值計算其范圍,並且默認情況下包括零。 您可以設置一個標志來控制是否包含零:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.