X、Y轴设定范围-JfreeChart
关于如何设置 X 轴和 Y 轴范围的任何建议。
我的“X 轴”范围是从“0.00 到 1.00”,差异为“0.05”。我的意思是 0.00 0.05 0.10 0.15.....0.90 0.95 1.00
我的“Y 轴”范围是从“0.0 到 1.0”,差异为“0.1”。我的意思是 0.0 0.1 0.2 0.3 0.4.........0.9 1.0
我尝试这样做,但它没有反映在图表上;我不知道如何将其应用于 ChartFactory.createScatterPlot()
。
final NumberAxis domainAxis = new NumberAxis("X-Axis");
domainAxis.setRange(0.00,1.00);
domainAxis.setTickUnit(new NumberTickUnit(0.1));
final NumberAxis rangeAxis = new NumberAxis("Y-Axis");
rangeAxis.setRange(0.0,1.0);
rangeAxis.setTickUnit(new NumberTickUnit(0.05));
public JPanel createDemoPanel() {
XYDataset dataset1 = samplexydataset2();
JFreeChart jfreechart = ChartFactory.createScatterPlot("Scatter Plot Demo",
"X", "Y",dataset1, PlotOrientation.VERTICAL, true, true, false);
}
任何有关这方面的帮助都会很棒。
Any suggestions over how to set Range for X-Axis and Y-Axis.
My "X-Axis" Range is from "0.00 to 1.00" with difference of "0.05". I mean 0.00 0.05 0.10 0.15.....0.90 0.95 1.00
My "Y-Axis" Range is from "0.0 to 1.0" with difference of "0.1". I mean 0.0 0.1 0.2 0.3 0.4.........0.9 1.0
I tried doing this Way, but it's not reflecting on the Graph; I don't know how to apply it to ChartFactory.createScatterPlot()
.
final NumberAxis domainAxis = new NumberAxis("X-Axis");
domainAxis.setRange(0.00,1.00);
domainAxis.setTickUnit(new NumberTickUnit(0.1));
final NumberAxis rangeAxis = new NumberAxis("Y-Axis");
rangeAxis.setRange(0.0,1.0);
rangeAxis.setTickUnit(new NumberTickUnit(0.05));
public JPanel createDemoPanel() {
XYDataset dataset1 = samplexydataset2();
JFreeChart jfreechart = ChartFactory.createScatterPlot("Scatter Plot Demo",
"X", "Y",dataset1, PlotOrientation.VERTICAL, true, true, false);
}
Any help regarding this would be great.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我猜你的新
NumberAxis
实例没有被绘图使用;使用工厂现有的可能会更容易。I'm guessing your new
NumberAxis
instances aren't being used by the plot; it may be easier to use the existing ones from the factory.除非您粘贴的代码不完整,否则您的问题似乎是您没有将创建的 NumberAxis 对象与绘图关联起来。
不要手动创建新的 NumberAxis 对象,而是尝试获取与绘图关联的默认 ValueAxis 对象,然后修改它们的属性:
Unless the code that you pasted is incomplete, it looks like your problem is that you didn't associate the NumberAxis objects that you created with your plot.
Instead of creating new NumberAxis objects manually, try getting the default ValueAxis objects that are associated with your plot, then modifying their properties: