我正在使用JFreeChart
做条形图,我的类别完全重叠。
我已经看过了JFreechart: Displaying X axis with values after specific units,但我无法以某种方式做到这一点。我有
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
for (int l = 1; l<256; l++)
{
dataset.setValue(CountRed[l],"Red",Integer.toString(l));
dataset.setValue(CountBlue[l], "Blue", Integer.toString(l));
dataset.setValue(CountGreen[l], "Green", Integer.toString(l));
}
JFreeChart chart = ChartFactory.createStackedBarChart("RGB", "pixels", "Num", dataset, PlotOrientation.VERTICAL, false, true, false);
CategoryPlot p=chart.getCategoryPlot();
p.setRangeGridlinePaint(Color.BLACK);
CategoryAxis xAxis = p.getDomainAxis();
xAxis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_90);
xAxis.setTickLabelFont(new Font("Times New Roman", Font.PLAIN, 7));
ImgDiag1 = chart.createBufferedImage(700,250);
diag1 = new ImageIcon(ImgDiag1);
jLabel4.setIcon(diag1);
其中CountRed,CountBlue和CountGreen是int的数组。 所以有0-255的数字,我想举例说明其中每30个类别。 希望你能帮帮我。
更新:使用堆积条形图,它看起来像这样: