在JFreeChart中将原点从(0,0)切换到(0,50) [英] Shift the origin from (0,0) to (0,50) in JFreeChart
本文介绍了在JFreeChart中将原点从(0,0)切换到(0,50)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如图所示,图是从y = 0行开始的,这里我想从y = 50开始绘制一个图,我如何在 JFreeChart
中指定它?
以下是一些代码:
public class Profile {
double last = 0;
public void generateProfile(int [] pointValue,double [] distance){
ArrayList pv = new ArrayList();
ArrayList dist = new ArrayList();
pv.add(pointValue);
dist.add(distance);
for(int i = 0; i< pv.size(); i ++){
System.out.print(pointValue [i]);
}
for(int i = 0; i< dist.size(); i ++){
System.out.print(distance [i]);
}
XYSeries series = new XYSeries(Average Weight);
for(int i = 0; i< pointValue.length; i ++){
if(pointValue [i]!= 0){
series.add(last,pointValue [一世]);
last = distance [i];
}
}
XYDataset xyDataset = new XYSeriesCollection(series);
JFreeChart图表;
chart = ChartFactory.createXYAreaChart(轮廓剖面图,距离,轮廓值,xyDataset,PlotOrientation.VERTICAL,true,true,false);
ChartFrame frame1 =新的ChartFrame(XYLine Chart,chart);
frame1.setVisible(true);
frame1.setSize(300,300);
解决方案
您可以指定底部值使用你的例子:
<$ p $
使用你的例子:
p> JFreeChart图表;
chart = ChartFactory.createXYAreaChart(轮廓剖面视图,距离,轮廓值,xyDataset,PlotOrientation.VERTICAL,true,true,false);
ValueAxis rangeAxis = chart.getXYPlot()。getRangeAxis();
rangeAxis.setLowerBound(50.0f);
As shown in image the graph is from line y=0, here i want to plot a graph from y=50, how can i specify this in JFreeChart
?
Here is Some Code:
public class Profile {
double last=0;
public void generateProfile(int[] pointValue,double[] distance){
ArrayList pv=new ArrayList();
ArrayList dist=new ArrayList();
pv.add(pointValue);
dist.add(distance);
for(int i=0;i<pv.size();i++){
System.out.print(pointValue[i]);
}
for(int i=0;i<dist.size();i++){
System.out.print(distance[i]);
}
XYSeries series = new XYSeries("Average Weight");
for(int i=0;i<pointValue.length;i++){
if(pointValue[i]!=0){
series.add(last,pointValue[i]);
last=distance[i];
}
}
XYDataset xyDataset = new XYSeriesCollection(series);
JFreeChart chart;
chart= ChartFactory.createXYAreaChart("Profile View Of Contour", "Distance", "Contour Value", xyDataset, PlotOrientation.VERTICAL, true, true, false);
ChartFrame frame1=new ChartFrame("XYLine Chart",chart);
frame1.setVisible(true);
frame1.setSize(300,300);
}
解决方案
You can specify the bottom value of the Y axis with the setLowerBound() method of the ValueAxis class.
Using your example:
JFreeChart chart;
chart = ChartFactory.createXYAreaChart("Profile View Of Contour", "Distance", "Contour Value", xyDataset, PlotOrientation.VERTICAL, true, true, false);
ValueAxis rangeAxis = chart.getXYPlot().getRangeAxis();
rangeAxis.setLowerBound(50.0f);
这篇关于在JFreeChart中将原点从(0,0)切换到(0,50)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文