I have looked everywhere, but find nothing
I need to combine two graphics. A histogram and a graph of normal distribution.
I've tried everything, but nothing...
My code is:
Code: Select all
public void mostrarHistograma()
{
ChartFrame f = new ChartFrame("Histograma", chart);
f.pack();
f.setVisible(true);
}
private static void getDistNormal()
{
NormalDistributionFunction2D normal = new NormalDistributionFunction2D(0, 1.0);
XYDataset dataset = DatasetUtilities.sampleFunction2D(normal, -2.5, 2.5, 50, "Normal");
JFreeChart chart = ChartFactory.createXYLineChart("Normal", "x", "y", dataset, PlotOrientation.VERTICAL, true, true, false);
ChartFrame f = new ChartFrame("Histograma", chart);
f.pack();
f.setVisible(true);
}
private static JFreeChart getHistogram(double [] datos)
{
JFreeChart chart1 = ChartFactory.createHistogram("TCL", "X", "Y", crearDataset(datos), PlotOrientation.VERTICAL, false, false, false);
getDistNormal();
return chart1;
}
private static HistogramDataset crearDataset(double [] datos)
{
HistogramDataset dataset = new HistogramDataset();
dataset.addSeries("Histograma", datos, (int) Math.sqrt(datos.length));
return dataset;
}
I need your help
Thank you very much!!