假設左邊有一個垂直軸的共同條形圖...我想知道如何控制圖表左側和垂直軸之間的空間?這個想法是,只要軸上顯示的刻度標籤變大,軸就會向右推動以容納刻度標籤。我希望能夠指定該軸應始終顯示在圖表整個寬度的20%處,這可能嗎?JFreeChart軸位置
0
A
回答
0
條形圖通常有一個域爲CategoryAxis
,因此您可以使用setLowerMargin()
,setUpperMargin()
和setCategoryMargin()
進行實驗。
0
您需要設置的範圍內軸的固定軸空間: http://www.jfree.org/jfreechart/api/gjdoc/org/jfree/chart/plot/XYPlot.html#setFixedRangeAxisSpace:AxisSpace
假設你剛剛創建圖表的圖像:
// Get your plot from the chart object..
XYPlot plot = (XYPlot)chart.getPlot();
// Create an instance of the image so we can do some calculations
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
// Create an instance of the Graphics2D from your image
Graphics2D g2 = image.createGraphics();
// Get the reserve space that jfree chart sets aside for the axis
AxisSpace space = yAxis.reserveSpace(g2, plot, new Rectangle(width,height), plot.getRangeAxisEdge(), plot.getFixedRangeAxisSpace());
// Give that space a fixed width
space.setLeft(fixedAxisWidth);
// Set it in the plot
plot.setFixedRangeAxisSpace(space);
你也許能夠只定義AxisSpace沒有去通過所有的Graphics2D rigamarole,但這是我過去的做法。
相關問題
- 1. JFreeChart - 軸標籤定位
- 2. 的JFreeChart和Y軸單位
- 3. JFreeChart XYAreaChart設置域軸
- 4. 是否可以在JFreeChart圖中操作Domain軸的位置?
- 5. 設置JFreeChart/Cewolf X軸間隔
- 6. X,Y軸-JfreeChart的設置範圍
- 7. JFreeChart x軸格式
- 8. JFreeChart的鏈接軸
- 9. JFreeChart與雙x軸
- 10. JFreeChart中有兩個範圍軸的倒置軸平移方向?
- 11. JFreechart X和Y軸縮放
- 12. 在jFreechart上顯示Y軸
- 13. JFreeChart:一軸分佈圖
- 14. JFreeChart域/範圍軸定義
- 15. Y軸是不是JFreeChart的
- 16. X軸上的JFreeChart表?
- 17. JFreeChart的x軸刻度
- 18. 自定義字幕位置 - JFreeChart
- 19. 如何使用JfreeChart設置Y軸的範圍?
- 20. 使用JFreeChart爲兩個系列設置不同的y軸
- 21. 如何設置JFreeChart X軸數據標題?
- 22. 在jFreeChart中設置縱軸標籤的貨幣格式
- 23. D3 x軸位置錯誤
- 24. Highchart的多軸y位置
- 25. 左軸標籤的位置
- 26. 輔助Y軸位置matplotlib
- 27. JFreeChart SlidingCategoryDataset圖表僅更新軸
- 28. 顯示完整軸標籤中的JFreeChart
- 29. JFreeChart自定義x軸標籤
- 30. 切換JFreeChart軸範圍的上限