Example usage for org.jfree.chart ChartFactory createScatterPlot

List of usage examples for org.jfree.chart ChartFactory createScatterPlot

Introduction

In this page you can find the example usage for org.jfree.chart ChartFactory createScatterPlot.

Prototype

public static JFreeChart createScatterPlot(String title, String xAxisLabel, String yAxisLabel,
        XYDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls) 

Source Link

Document

Creates a scatter plot with default settings.

Usage

From source file:org.pentaho.chart.plugin.jfreechart.JFreeChartFactoryEngine.java

protected JFreeChart makeScatterChart(ChartModel chartModel, MultiSeriesXYDataModel data) {

    XYSeriesCollection dataset = new XYSeriesCollection();

    for (Series series : data.getSeries()) {
        dataset.addSeries(createXYSeries(series));
    }/*from www  . j  a  v  a  2s  .c o  m*/

    org.pentaho.chart.model.TwoAxisPlot twoAxisPlot = (org.pentaho.chart.model.TwoAxisPlot) chartModel
            .getPlot();

    String title = "";
    if ((chartModel.getTitle() != null) && (chartModel.getTitle().getText() != null)
            && (chartModel.getTitle().getText().trim().length() > 0)) {
        title = chartModel.getTitle().getText();
    }

    AxesLabels axesLabels = getAxesLabels(chartModel);
    PlotOrientation plotOrientation = (twoAxisPlot.getOrientation() == Orientation.HORIZONTAL)
            ? PlotOrientation.HORIZONTAL
            : PlotOrientation.VERTICAL;
    boolean showLegend = (chartModel.getLegend() != null) && (chartModel.getLegend().getVisible());
    JFreeChart chart = ChartFactory.createScatterPlot(title, axesLabels.domainAxisLabel,
            axesLabels.rangeAxisLabel, dataset, plotOrientation, showLegend, true, false);

    initXYPlot(chart, chartModel);
    initChart(chart, chartModel);

    return chart;
}

From source file:keel.GraphInterKeel.datacf.visualizeData.VisualizePanelAttribute.java

private void infoAttribute() {
    this.enabledTable(true);
    // Extended info about selected attribute
    if (((VisualizePanel) this.getParent().getParent()).getData()
            .getAttributeTypeIndex(this.tableInfojTable.getSelectedRow()).equals("nominal")) {
        this.valuesjScrollPane.setEnabled(true);
        this.valuesjScrollPane.setVisible(true);
        this.valuesjTextPane.setEnabled(true);
        this.valuesjTextPane.setVisible(true);

        Vector r = ((VisualizePanel) this.getParent().getParent()).getData()
                .getRangesVar(((VisualizePanel) this.getParent().getParent()).getData()
                        .getAttributeIndex(this.tableInfojTable.getSelectedRow()));

        this.valuesjTextPane.setText("");
        this.valueAveragejLabel.setText("");
        this.valueVariancejLabel.setText("");
        this.valueRankjLabelIzdo.setText("  ");
        this.valueRankjLabelDcho.setText("  ");

        String cadena = new String();
        for (int i = 0; i < r.size(); i++) {
            if (i == 0) {
                cadena = r.elementAt(i).toString() + "";
                this.valuesjTextPane.setText(cadena);
            } else {
                cadena = this.valuesjTextPane.getText() + "\n" + r.elementAt(i).toString();
            }/*  w  w  w .  jav  a  2 s.co  m*/
            this.valuesjTextPane.setText(cadena);
        }
        boolean legend = false;
        // Draw bar chart
        DefaultCategoryDataset dataset = new DefaultCategoryDataset();
        try {
            for (int i = 0; i < ((VisualizePanel) this.getParent().getParent()).getData().getNData(); i++) {
                String column = ((VisualizePanel) this.getParent().getParent()).getData().getDataIndex(i,
                        this.tableInfojTable.getSelectedRow());
                String row = "";
                if (((VisualizePanel) this.getParent().getParent()).getOutAttribute() != -1
                        && this.tableInfojTable
                                .getSelectedRow() != ((VisualizePanel) this.getParent().getParent())
                                        .getOutAttribute()) {
                    row = "Class " + ((VisualizePanel) this.getParent().getParent()).getData().getDataIndex(i,
                            ((VisualizePanel) this.getParent().getParent()).getOutAttribute());
                    legend = true;
                }

                if (column != null) {
                    if (dataset.getRowIndex(row) == -1 || ((dataset.getColumnIndex(column) == -1))) {
                        dataset.addValue(1.0, row, column);
                    } else {
                        dataset.incrementValue(1.0, row, column);
                    }
                }
            }
        } catch (ArrayIndexOutOfBoundsException exp) {
            JOptionPane.showMessageDialog(this,
                    "The data set contains some errors. This attribute can not be visualized", "Error", 2);
        }

        this.chart = ChartFactory.createBarChart3D("", "", "", dataset, PlotOrientation.VERTICAL, legend, false,
                false);

        this.chart.setBackgroundPaint(new Color(0xFFFFFF));
        //BufferedImage image = this.chart.createBufferedImage(210, 140);
        BufferedImage image = this.chart.createBufferedImage(400, 240);
        this.imagejLabel.setIcon(new ImageIcon(image));
        this.clickToExpandjLabel.setVisible(true);
    } else {
        this.valuesjScrollPane.setEnabled(false);
        this.valuesjScrollPane.setVisible(false);
        this.valuesjTextPane.setEnabled(false);
        this.valuesjTextPane.setVisible(false);
        Vector r = ((VisualizePanel) this.getParent().getParent()).getData()
                .getRangesVar(((VisualizePanel) this.getParent().getParent()).getData()
                        .getAttributeIndex(this.tableInfojTable.getSelectedRow()));
        this.valueRankjLabelIzdo.setText(r.elementAt(0).toString());
        this.valueRankjLabelDcho.setText(r.elementAt(1).toString());

        // Average
        double m = 0.0;
        for (int i = 0; i < ((VisualizePanel) this.getParent().getParent()).getData().getNData(); i++) {
            String valor = ((VisualizePanel) this.getParent().getParent()).getData().getDataIndex(i,
                    this.tableInfojTable.getSelectedRow());
            if (valor != null) {
                m += Double.valueOf(valor).doubleValue();
            }
        }
        m = m / ((VisualizePanel) this.getParent().getParent()).getData().getNData();
        DecimalFormat df = new DecimalFormat();
        df.setMaximumFractionDigits(3);
        this.valueAveragejLabel.setText(df.format(m));
        // Variance
        double v = 0.0;
        for (int i = 0; i < ((VisualizePanel) this.getParent().getParent()).getData().getNData(); i++) {
            String valor = ((VisualizePanel) this.getParent().getParent()).getData().getDataIndex(i,
                    this.tableInfojTable.getSelectedRow());
            if (valor != null) {
                v += Math.pow(Double.valueOf(valor).doubleValue() - m, 2);
            }
        }
        v = v / (((VisualizePanel) this.getParent().getParent()).getData().getNData() - 1);
        this.valueVariancejLabel.setText(df.format(v));

        // Draw scatter plot
        XYSeriesCollection juegoDatos = new XYSeriesCollection();
        boolean legend = false;
        if (((VisualizePanel) this.getParent().getParent()).getOutAttribute() != -1) {
            Vector outputRang = ((VisualizePanel) this.getParent().getParent()).getData()
                    .getRange(((VisualizePanel) this.getParent().getParent()).getOutAttribute());
            XYSeries series[] = new XYSeries[outputRang.size()];
            for (int i = 0; i < outputRang.size(); i++) {
                series[i] = new XYSeries("Class " + outputRang.elementAt(i));
                juegoDatos.addSeries(series[i]);
            }
            for (int i = 0; i < ((VisualizePanel) this.getParent().getParent()).getData().getNData(); i++) {
                int clase = outputRang.indexOf(((VisualizePanel) this.getParent().getParent()).getData()
                        .getDataIndex(i, ((VisualizePanel) this.getParent().getParent()).getOutAttribute()));
                String valor = ((VisualizePanel) this.getParent().getParent()).getData().getDataIndex(i,
                        this.tableInfojTable.getSelectedRow());
                if (valor != null) {
                    series[clase].add(Double.parseDouble(Integer.toString(i)),
                            Double.valueOf(valor).doubleValue());
                }
            }
            legend = true;
        } else {
            XYSeries series = new XYSeries("Regresin");
            juegoDatos.addSeries(series);
            for (int i = 0; i < ((VisualizePanel) this.getParent().getParent()).getData().getNData(); i++) {
                String valor = ((VisualizePanel) this.getParent().getParent()).getData().getDataIndex(i,
                        this.tableInfojTable.getSelectedRow());
                if (valor != null) {
                    series.add(Double.parseDouble(Integer.toString(i)), Double.valueOf(valor).doubleValue());
                }
            }

        }

        chart = ChartFactory.createScatterPlot("", "", "", juegoDatos, PlotOrientation.VERTICAL, legend, false,
                false);
        chart.setBackgroundPaint(new Color(0xFFFFFF));
        //BufferedImage image = chart.createBufferedImage(210, 140);
        BufferedImage image = chart.createBufferedImage(400, 240);
        this.imagejLabel.setIcon(new ImageIcon(image));
        this.clickToExpandjLabel.setVisible(true);
    }
}

From source file:jprobix.ui.UI.java

@SuppressWarnings("empty-statement")
private void jButtonRunActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonRunActionPerformed
    uList.clear();/*from  w ww.  java2 s  .  c  o m*/
    ziarno.clear();

    ziarno.add(x1);
    ziarno.add(x2);
    ziarno.add(x3);
    ziarno.add(x4);

    if (size > 0) {
        uList.add(a1);
        uList.add(a2);
        uList.add(a3);
        uList.add(a4);
    }

    int xN = 0;
    if (size > 0) {
        int i = 0;
        while (i < (size - (ziarno.size()))) {
            int ij;
            ij = ((ziarno.get(ziarno.size() - 1) * uList.get(uList.size() - 1)
                    + ziarno.get(ziarno.size() - 2) * uList.get(uList.size() - 2)
                    + ziarno.get(ziarno.size() - 3) * uList.get(uList.size() - 3)
                    + ziarno.get(ziarno.size() - 4) * uList.get(uList.size() - 4)) + c) % m;

            if (ij >= rozkladI) {
                uList.add(ij);
            } else {
                ij = ij + rozkladI;
                uList.add(ij);
            }
            i++;
        }
    }
    jTextAreaConsole.insert(uList + "\n", 0);

    JPanel jpanel3 = creteDemoPanel();
    jpanel3.setPreferredSize(new Dimension(640, 480));

    ds = createDataset();
    cp.repaint();
    chart = ChartFactory.createScatterPlot("Wykres XY", "U(i)", "U(i+1)", ds, PlotOrientation.VERTICAL, true,
            true, false);

    xyPlot = (XYPlot) chart.getPlot();
    renderer = xyPlot.getRenderer();

    cp.repaint();

    cp = new ChartPanel(chart);
    cp.repaint();

    jTabbedPane2.removeAll();
    jTabbedPane2.addTab("wygenerowane punkty", cp);

    cp.setMouseWheelEnabled(true);

    cdb = createDatasetBar();
    chartBar = ChartFactory.createXYBarChart("Histogram", // chart title
            "Zmienne", // domain axis label
            false, "Wartosci zmiennych", // range axis label
            cdb, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips?
            false // URLs?
    );
    PlotBar = (XYPlot) chartBar.getPlot();
    rendererBar = (XYBarRenderer) PlotBar.getRenderer();
    chartPanelBar = new ChartPanel(chartBar);
    jTabbedPane2.addTab("histogram", chartPanelBar);
    chartPanelBar.setMouseWheelEnabled(true);

    for (int i = 0; i < uList.size(); i++) { //suma
        MediumS += uList.get(i);
    }
    MediumS = MediumS / uList.size(); //liczymy redni
    jTextFieldS.setText("" + MediumS);

    MediumO = 0.0;
    for (int i = 0; i < uList.size(); i++) { //suma
        MediumO += pow(uList.get(i), 2);
    }
    MediumO = abs(MediumO / (uList.size())); //liczymy redni

    odchylenieSigma = sqrt((MediumO - (MediumS * MediumS)));
    jTextFieldO.setText("" + odchylenieSigma);

}

From source file:cish.CISH.java

/**
 * Draws the global / local ratio plot in this Plugin window.
 *///from   w  ww . j a v a2s . co  m
void drawRatioPlot() {
    //Set the chartpanel
    DefaultXYDataset dataset = new DefaultXYDataset();
    if (lRatios != null) {
        for (int i = 0; i < lRatios.length; i++) {
            if (gRatios[i] != Double.POSITIVE_INFINITY && lRatios[i] != Double.POSITIVE_INFINITY) {
                dataset.addSeries(tss.get(i).getName(),
                        new double[][] { new double[] { gRatios[i] }, new double[] { lRatios[i] } });
            }
        }
    }

    JFreeChart chart = ChartFactory.createScatterPlot("CISH Ratio", "Global Ratio", "Local Ratio", dataset,
            PlotOrientation.VERTICAL, true, true, false);
    //chart.getXYPlot().getDomainAxis().setRange(0, 1);
    //chart.getXYPlot().getRangeAxis().setRange(0, 1);
    chart.setBackgroundPaint(null);
    chart.getPlot().setBackgroundPaint(null);
    ChartPanel chartPanel = new ChartPanel(chart);
    setPrecisionRecallPlot(chartPanel);
}

From source file:ispd.gui.auxiliar.Graficos.java

private JFreeChart criarGraficoEstadoTarefa(List<Tarefa> tarefas) {
    XYSeries canceladas = new XYSeries("Canceled");
    XYSeries concluidas = new XYSeries("Completed");
    XYSeries paradas = new XYSeries("Not executed");
    XYSeries falhas = new XYSeries("Failures");
    for (Tarefa tarefa : tarefas) {
        switch (tarefa.getEstado()) {
        case Tarefa.PARADO:
            paradas.add(tarefa.getTimeCriacao(), 4);
            break;
        case Tarefa.CONCLUIDO:
            concluidas.add(tarefa.getTempoFinal().get(tarefa.getTempoFinal().size() - 1), (Double) 1.0);
            break;
        case Tarefa.CANCELADO:
            if (!tarefa.getTempoFinal().isEmpty()) {
                canceladas.add(tarefa.getTempoFinal().get(tarefa.getTempoFinal().size() - 1), (Double) 2.0);
            }//from w  w w .  j ava 2 s  . co m
            break;
        case Tarefa.FALHA:
            falhas.add(tarefa.getTempoFinal().get(tarefa.getTempoFinal().size() - 1), (Double) 3.0);
            break;
        }
    }
    XYSeriesCollection data = new XYSeriesCollection();
    data.addSeries(falhas);
    data.addSeries(canceladas);
    data.addSeries(concluidas);
    data.addSeries(paradas);
    JFreeChart chart = ChartFactory.createScatterPlot("State of tasks", "Time (seconds)", "Y", data,
            PlotOrientation.VERTICAL, //Orientacao do grafico
            true, true, false);
    NumberAxis domainAxis = (NumberAxis) chart.getXYPlot().getDomainAxis();
    domainAxis.setAutoRangeIncludesZero(false);
    return chart;
}

From source file:org.glotaran.core.datadisplayers.multispec.MultiSpecEditorTopComponent.java

private JFreeChart createChart(XYDataset dataset1) {
    JFreeChart chart_temp = ChartFactory.createScatterPlot(null, null, null, dataset1, PlotOrientation.VERTICAL,
            false, false, false);/*from   w  ww .  j av a  2  s  .c om*/

    double range = Math.abs(data.getMaxInt() - data.getMinInt());
    double dataMin, dataMax;
    if (range == 0.0) {
        dataMin = data.getMinInt() - 0.1;
        dataMax = data.getMaxInt() + 0.1;
    } else {
        dataMin = data.getMinInt();
        dataMax = data.getMaxInt();
    }
    PaintScale ps = new RainbowPaintScale(dataMin, dataMax);
    //        PaintScale ps = new RedGreenPaintScale(dataMin, dataMax);
    BufferedImage image = ImageUtilities.createColorCodedImage(this.dataset, ps);

    XYDataImageAnnotation ann = new XYDataImageAnnotation(image, 0, 0, dataset.GetImageWidth(),
            dataset.GetImageHeigth(), true);
    XYPlot plot = (XYPlot) chart_temp.getPlot();
    plot.setDomainPannable(true);
    plot.setRangePannable(true);
    plot.getRenderer().addAnnotation(ann, Layer.BACKGROUND);
    NumberAxis xAxis = (NumberAxis) plot.getDomainAxis();
    xAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    xAxis.setLowerMargin(0.0);
    xAxis.setUpperMargin(0.0);
    xAxis.setVisible(false);
    NumberAxis yAxis = (NumberAxis) plot.getRangeAxis();
    yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    yAxis.setLowerMargin(0.0);
    yAxis.setUpperMargin(0.0);
    yAxis.setVisible(false);
    return chart_temp;
}

From source file:org.jfree.chart.demo.JFreeChartDemoBase.java

/**
 * Creates and returns a sample scatter plot.
 *
 * @return a sample scatter plot.//from  w  ww. j av  a  2  s .  co  m
 */
public JFreeChart createScatterPlot() {

    // create a default chart based on some sample data...
    final String title = this.resources.getString("other.scatter.title");
    final String domain = this.resources.getString("other.scatter.domain");
    final String range = this.resources.getString("other.scatter.range");
    final XYDataset data = new SampleXYDataset2();
    final JFreeChart chart = ChartFactory.createScatterPlot(title, domain, range, data,
            PlotOrientation.VERTICAL, true, true, // tooltips
            false // urls
    );

    // then customise it a little...
    chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 1000, 0, Color.green));

    final XYPlot plot = chart.getXYPlot();
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);
    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setAutoRangeIncludesZero(false);
    return chart;

}

From source file:ubic.gemma.web.controller.expression.experiment.ExpressionExperimentQCController.java

private boolean writeDetailedFactorAnalysis(ExpressionExperiment ee, OutputStream os) throws Exception {
    SVDValueObject svdo = svdService.getSvdFactorAnalysis(ee.getId());
    if (svdo == null)
        return false;

    if (svdo.getFactors().isEmpty() && svdo.getDates().isEmpty()) {
        return false;
    }//from ww  w .  j a va 2s .co m
    Map<Integer, Map<Long, Double>> factorCorrelations = svdo.getFactorCorrelations();
    // Map<Integer, Map<Long, Double>> factorPvalues = svdo.getFactorPvalues();
    Map<Integer, Double> dateCorrelations = svdo.getDateCorrelations();

    assert ee.getId().equals(svdo.getId());

    ee = expressionExperimentService.thawLite(ee); // need the experimental design
    int maxWidth = 30;
    Map<Long, String> efs = this.getFactorNames(ee, maxWidth);
    Map<Long, ExperimentalFactor> efIdMap = EntityUtils
            .getIdMap(ee.getExperimentalDesign().getExperimentalFactors());
    Collection<Long> continuousFactors = new HashSet<>();
    for (ExperimentalFactor ef : ee.getExperimentalDesign().getExperimentalFactors()) {
        boolean isContinous = ExperimentalDesignUtils.isContinuous(ef);
        if (isContinous) {
            continuousFactors.add(ef.getId());
        }
    }

    /*
     * Make plots of the dates vs. PCs, factors vs. PCs.
     */
    int MAX_COMP = 3;

    Map<Long, List<JFreeChart>> charts = new LinkedHashMap<>();
    ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
    /*
     * FACTORS
     */
    String componentShorthand = "PC";
    for (Integer component : factorCorrelations.keySet()) {

        if (component >= MAX_COMP)
            break;
        String xaxisLabel = componentShorthand + (component + 1);

        for (Long efId : factorCorrelations.get(component).keySet()) {

            /*
             * Should not happen.
             */
            if (!efs.containsKey(efId)) {
                log.warn("No experimental factor with id " + efId);
                continue;
            }

            if (!svdo.getFactors().containsKey(efId)) {
                // this should not happen.
                continue;
            }

            boolean isCategorical = !continuousFactors.contains(efId);

            Map<Long, String> categories = new HashMap<>();

            if (isCategorical) {
                this.getCategories(efIdMap, efId, categories);
            }

            if (!charts.containsKey(efId)) {
                charts.put(efId, new ArrayList<JFreeChart>());
            }

            Double a = factorCorrelations.get(component).get(efId);
            String plotname = (efs.get(efId) == null ? "?" : efs.get(efId)) + " " + xaxisLabel; // unique?

            if (a != null && !Double.isNaN(a)) {
                String title = plotname + " " + String.format("%.2f", a);
                List<Double> values = svdo.getFactors().get(efId);
                Double[] eigenGene = this.getEigenGene(svdo, component);
                assert values.size() == eigenGene.length;

                /*
                 * Plot eigengene vs values, add correlation to the plot
                 */
                JFreeChart chart;
                if (isCategorical) {

                    /*
                     * Categorical factor
                     */

                    // use the absolute value of the correlation, since direction is arbitrary.
                    title = plotname + " " + String.format("r=%.2f", Math.abs(a));

                    DefaultMultiValueCategoryDataset dataset = new DefaultMultiValueCategoryDataset();

                    /*
                     * What this code does is organize the factor values by the groups.
                     */
                    Map<String, List<Double>> groupedValues = new TreeMap<>();
                    for (int i = 0; i < values.size(); i++) {
                        Long fvId = values.get(i).longValue();
                        String fvValue = categories.get(fvId);
                        if (fvValue == null) {
                            /*
                             * Problem ...eg gill2006fateinocean id=1748 -- missing values. We just don't plot
                             * anything for this sample.
                             */
                            continue; // is this all we need to do?
                        }
                        if (!groupedValues.containsKey(fvValue)) {
                            groupedValues.put(fvValue, new ArrayList<Double>());
                        }

                        groupedValues.get(fvValue).add(eigenGene[i]);

                        if (log.isDebugEnabled())
                            log.debug(fvValue + " " + values.get(i));
                    }

                    for (String key : groupedValues.keySet()) {
                        dataset.add(groupedValues.get(key), plotname, key);
                    }

                    // don't show the name of the X axis: it's redundant with the title.
                    NumberAxis rangeAxis = new NumberAxis(xaxisLabel);
                    rangeAxis.setAutoRangeIncludesZero(false);
                    // rangeAxis.setAutoRange( false );
                    rangeAxis.setAutoRangeMinimumSize(4.0);
                    // rangeAxis.setRange( new Range( -2, 2 ) );

                    CategoryPlot plot = new CategoryPlot(dataset, new CategoryAxis(null), rangeAxis,
                            new ScatterRenderer());
                    plot.setRangeGridlinesVisible(false);
                    plot.setDomainGridlinesVisible(false);

                    chart = new JFreeChart(title, new Font("SansSerif", Font.BOLD, 12), plot, false);

                    ScatterRenderer renderer = (ScatterRenderer) plot.getRenderer();
                    float saturationDrop = (float) Math.min(1.0, component * 0.8f / MAX_COMP);
                    renderer.setSeriesFillPaint(0, Color.getHSBColor(0.0f, 1.0f - saturationDrop, 0.7f));
                    renderer.setSeriesShape(0, new Ellipse2D.Double(0, 0, 3, 3));
                    renderer.setUseOutlinePaint(false);
                    renderer.setUseFillPaint(true);
                    renderer.setBaseFillPaint(Color.white);
                    CategoryAxis domainAxis = plot.getDomainAxis();
                    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);
                } else {

                    /*
                     * Continuous value factor
                     */

                    DefaultXYDataset series = new DefaultXYDataset();
                    series.addSeries(plotname,
                            new double[][] { ArrayUtils.toPrimitive(values.toArray(new Double[] {})),
                                    ArrayUtils.toPrimitive(eigenGene) });

                    // don't show x-axis label, which would otherwise be efs.get( efId )
                    chart = ChartFactory.createScatterPlot(title, null, xaxisLabel, series,
                            PlotOrientation.VERTICAL, false, false, false);
                    XYPlot plot = chart.getXYPlot();
                    plot.setRangeGridlinesVisible(false);
                    plot.setDomainGridlinesVisible(false);

                    XYItemRenderer renderer = plot.getRenderer();
                    renderer.setBasePaint(Color.white);
                    renderer.setSeriesShape(0, new Ellipse2D.Double(0, 0, 3, 3));
                    float saturationDrop = (float) Math.min(1.0, component * 0.8f / MAX_COMP);
                    renderer.setSeriesPaint(0, Color.getHSBColor(0.0f, 1.0f - saturationDrop, 0.7f));
                    plot.setRenderer(renderer);
                }

                chart.getTitle().setFont(new Font("SansSerif", Font.BOLD, 12));

                charts.get(efId).add(chart);
            }
        }
    }

    /*
     * DATES
     */
    charts.put(-1L, new ArrayList<JFreeChart>());
    for (Integer component : dateCorrelations.keySet()) {
        String xaxisLabel = componentShorthand + (component + 1);

        List<Date> dates = svdo.getDates();
        if (dates.isEmpty())
            break;

        long secspan = ubic.basecode.util.DateUtil.numberOfSecondsBetweenDates(dates);

        if (component >= MAX_COMP)
            break;
        Double a = dateCorrelations.get(component);

        if (a != null && !Double.isNaN(a)) {
            Double[] eigenGene = svdo.getvMatrix().getColObj(component);

            /*
             * Plot eigengene vs values, add correlation to the plot
             */
            TimeSeries series = new TimeSeries("Dates vs. eigen" + (component + 1));
            int i = 0;
            for (Date d : dates) {
                // if span is less than an hour, retain the minute.
                if (secspan < 60 * 60) {
                    series.addOrUpdate(new Minute(d), eigenGene[i++]);
                } else {
                    series.addOrUpdate(new Hour(d), eigenGene[i++]);
                }

            }
            TimeSeriesCollection dataset = new TimeSeriesCollection();
            dataset.addSeries(series);

            JFreeChart chart = ChartFactory.createTimeSeriesChart(
                    "Dates: " + xaxisLabel + " " + String.format("r=%.2f", a), null, xaxisLabel, dataset, false,
                    false, false);

            XYPlot xyPlot = chart.getXYPlot();

            chart.getTitle().setFont(new Font("SansSerif", Font.BOLD, 12));

            // standard renderer makes lines.
            XYDotRenderer renderer = new XYDotRenderer();
            renderer.setBaseFillPaint(Color.white);
            renderer.setDotHeight(3);
            renderer.setDotWidth(3);
            renderer.setSeriesShape(0, new Ellipse2D.Double(0, 0, 3, 3)); // has no effect, need dotheight.
            float saturationDrop = (float) Math.min(1.0, component * 0.8f / MAX_COMP);
            renderer.setSeriesPaint(0, Color.getHSBColor(0.0f, 1.0f - saturationDrop, 0.7f));
            ValueAxis domainAxis = xyPlot.getDomainAxis();
            domainAxis.setVerticalTickLabels(true);
            xyPlot.setRenderer(renderer);
            xyPlot.setRangeGridlinesVisible(false);
            xyPlot.setDomainGridlinesVisible(false);
            charts.get(-1L).add(chart);

        }
    }

    /*
     * Plot in a grid, with each factor as a column. FIXME What if we have too many factors to fit on the screen?
     */
    int columns = (int) Math.ceil(charts.size());
    int perChartSize = ExpressionExperimentQCController.DEFAULT_QC_IMAGE_SIZE_PX;
    BufferedImage image = new BufferedImage(columns * perChartSize, MAX_COMP * perChartSize,
            BufferedImage.TYPE_INT_ARGB);
    Graphics2D g2 = image.createGraphics();
    int currentX = 0;
    int currentY = 0;
    for (Long id : charts.keySet()) {
        for (JFreeChart chart : charts.get(id)) {
            this.addChartToGraphics(chart, g2, currentX, currentY, perChartSize, perChartSize);
            if (currentY + perChartSize < MAX_COMP * perChartSize) {
                currentY += perChartSize;
            } else {
                currentY = 0;
                currentX += perChartSize;
            }
        }
    }

    os.write(ChartUtilities.encodeAsPNG(image));
    return true;
}

From source file:lucee.runtime.tag.Chart.java

private void chartScatter() throws PageException, IOException {
    // create the chart...
    final JFreeChart chart = ChartFactory.createScatterPlot(title, xaxistitle, yaxistitle,
            createXYSeriesCollection(), PlotOrientation.VERTICAL, false, true, false);
    final XYPlot p = chart.getXYPlot();
    Font _font = getFont();//  w ww. ja va2  s.  c o m
    // settings            

    setBackground(chart, p);
    setBorder(chart, p);
    set3d(p);
    setFont(chart, _font);
    setLabelFormat(chart);
    setLegend(chart, p, _font);
    setTooltip(chart);
    setScale(chart);
    setAxis(chart);
    setColor(chart);

    writeOut(chart);
}

From source file:org.jfree.eastwood.ChartEngine.java

/**
 * Creates a scatter chart.// w  w  w . ja v a2 s.c  om
 *
 * @return A scatter chart.
 */
private static JFreeChart createScatterChart() {
    JFreeChart chart = ChartFactory.createScatterPlot(null, null, null, null, PlotOrientation.VERTICAL, false,
            false, false);
    chart.setBackgroundPaint(Color.white);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(null);
    plot.setOutlinePaint(null);
    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
    renderer.setBasePaint(new Color(0x76A4FB));
    renderer.setAutoPopulateSeriesPaint(false);

    GValueAxis xAxis = new GValueAxis();
    xAxis.setTickLabelsVisible(false);
    xAxis.setTickMarksVisible(false);
    plot.setDomainAxis(xAxis);
    GValueAxis yAxis = new GValueAxis();
    yAxis.setTickLabelsVisible(false);
    yAxis.setTickMarksVisible(false);
    plot.setRangeAxis(yAxis);
    plot.setDomainGridlinesVisible(false);
    plot.setRangeGridlinesVisible(false);
    return chart;
}