我有一个 XYLineChart,其中 X 轴上的标签是水平书写的。我希望能够垂直(降序)书写它们。
我已经可以对 BarCharts 执行此操作:
CategoryPlot plot = (CategoryPlot) chart.getPlot();
final CategoryAxis domainAxis = plot.getDomainAxis();
domainAxis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_90);
但是 XYChart 返回 XYPlot,而不是 CategoryPlot,并且 XYPlot 的 getDomainAxis() 返回 ValueAxis,而不是 CategoryAxis。 ValueAxis 让我打电话
setVerticalTickLabels(true);
就快到了!但它吸引他们上升,而不是下降。有办法解决这个问题吗?
谢谢
编辑:我需要将域轴保留在图表的底部。在制作原始帖子时没有考虑过它是任何其他方式。
最佳答案
ValueAxis
在 drawTickMarksAndLabels()
中自动执行此操作对于 RectangleEdge.TOP
边缘上的轴:
xyPlot.setDomainAxisLocation(AxisLocation.TOP_OR_LEFT);
基于 ScatterAdd
变体的示例.
关于java - JFreechart - XYChart 上的垂直 X 轴标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8430747/