Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/383.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何将线添加到散点图?(Java,jmathplot)_Java_Scatter Plot - Fatal编程技术网

如何将线添加到散点图?(Java,jmathplot)

如何将线添加到散点图?(Java,jmathplot),java,scatter-plot,Java,Scatter Plot,有了这段代码,我可以画一个散点图 import javax.swing.*; import org.math.plot.*; public class ScatterPlotExample { public static void main(String[] args) { double[] x = new double[] { 60 }; double[] y = new double[] { 50 }; // create your PlotPanel (you

有了这段代码,我可以画一个散点图

import javax.swing.*;
import org.math.plot.*;
public class ScatterPlotExample {

public static void main(String[] args) {

    double[] x = new double[] { 60 };
    double[] y = new double[] { 50 };

    // create your PlotPanel (you can use it as a JPanel)
    Plot2DPanel plot = new Plot2DPanel();

    // add a line plot to the PlotPanel

    plot.addScatterPlot("teeeeest", x, y);


    // put the PlotPanel in a JFrame, as a JPanel
    JFrame frame = new JFrame("a plot panel");
    frame.setSize(600, 600);
    frame.setContentPane(plot);
    frame.setVisible(true);

}
}

两个问题:

如何使轴的范围从1到100
如何在散点图中画出x=0.4和y=0.7的水平线和垂直线

谢谢大家!

  • 要设置X轴范围,请执行以下操作:

    plot.setFixedBounds(0,1100)
    ->(其中0表示X,1表示Y)

  • 要在Y=49.5处添加水平线,请执行以下操作:

    plot.addPlotable(新行)(颜色为红色,
    新的双精度[]{plot.plotCanvas.base.getMinBounds()[0],49.5},
    新的双精度[]{plot.plotCanvas.base.getMaxBounds()[0],49.5})