1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.geom.Ellipse2D;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.ChartFrame;
import org.jfree.chart.annotations.XYShapeAnnotation;
import org.jfree.chart.axis.ValueAxis;
import org.jfree.chart.labels.StandardXYToolTipGenerator;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.plot.XYPlot;
import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;
import org.jfree.data.xy.DefaultXYDataset;
public class Graph {
public static void main() {
DefaultXYDataset data = new DefaultXYDataset();
double [][] donnees = new double [2][3];
donnees[0][0]=0.36;
donnees[0][1]=-0.93;
donnees[0][2]=0.00;
donnees[1][0]=0.90;
donnees[1][1]=0.19;
donnees[1][2]=-0.39;
data.addSeries("Variables", donnees);
JFreeChart chart = ChartFactory.createScatterPlot("Test", "Axe Principal 1", "Axe Principal 2", data, PlotOrientation.VERTICAL, true, true, true);
XYPlot plot = (XYPlot) chart.getPlot();
ValueAxis axisX = (ValueAxis) plot.getDomainAxis();
axisX.setAutoRange(false);
axisX.setRangeWithMargins(-1.0,1.0);
axisX.setAutoTickUnitSelection(false);
ValueAxis axisY = (ValueAxis) plot.getRangeAxis();
axisY.setAutoRange(false);
axisY.setRangeWithMargins(-1.0,1.0);
axisY.setAutoTickUnitSelection(false);
XYShapeAnnotation a = new XYShapeAnnotation(new Ellipse2D.Double(-1,-1,2,2),
new BasicStroke(1.0f),
Color.BLACK );
plot.addAnnotation(a);
ChartFrame frame = new ChartFrame("Représentation", chart);
frame.pack();
frame.setVisible(true);
}
} |
Partager