with this code I am able to draw a 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 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);
}
}
Two questions:
How can I make the axes ranges from 1 to 100?
How can I draw into that scatter plot a horizontal and a vertical line at x = 0.4 and y = 0.7?
Thank you!
to set X axis range:
plot.setFixedBounds(0,1,100)-> (where 0 means X, 1 means Y)to add an horizontal line at Y=49.5:
plot.addPlotable(new Line(Color.red,new double[]{plot.plotCanvas.base.getMinBounds()[0],49.5},
new double[]{plot.plotCanvas.base.getMaxBounds()[0],49.5}));