Search in sources :

Example 16 with XYSeries

use of org.jfree.data.xy.XYSeries in project gephi by gephi.

the class EigenvectorCentrality method getReport.

/**
     *
     * @return
     */
@Override
public String getReport() {
    //distribution of values
    Map<Double, Integer> dist = new HashMap<>();
    for (int i = 0; i < centralities.length; i++) {
        Double d = centralities[i];
        if (dist.containsKey(d)) {
            Integer v = dist.get(d);
            dist.put(d, v + 1);
        } else {
            dist.put(d, 1);
        }
    }
    //Distribution series
    XYSeries dSeries = ChartUtils.createXYSeries(dist, "Eigenvector Centralities");
    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(dSeries);
    JFreeChart chart = ChartFactory.createScatterPlot("Eigenvector Centrality Distribution", "Score", "Count", dataset, PlotOrientation.VERTICAL, true, false, false);
    chart.removeLegend();
    ChartUtils.decorateChart(chart);
    ChartUtils.scaleChart(chart, dSeries, true);
    String imageFile = ChartUtils.renderChart(chart, "eigenvector-centralities.png");
    String report = "<HTML> <BODY> <h1>Eigenvector Centrality Report</h1> " + "<hr>" + "<h2> Parameters: </h2>" + "Network Interpretation:  " + (isDirected ? "directed" : "undirected") + "<br>" + "Number of iterations: " + numRuns + "<br>" + "Sum change: " + sumChange + "<br> <h2> Results: </h2>" + imageFile + "</BODY></HTML>";
    return report;
}
Also used : XYSeries(org.jfree.data.xy.XYSeries) HashMap(java.util.HashMap) XYSeriesCollection(org.jfree.data.xy.XYSeriesCollection) JFreeChart(org.jfree.chart.JFreeChart)

Example 17 with XYSeries

use of org.jfree.data.xy.XYSeries in project gephi by gephi.

the class GraphDistance method createImageFile.

private String createImageFile(TempDir tempDir, double[] pVals, String pName, String pX, String pY) {
    //distribution of values
    Map<Double, Integer> dist = new HashMap<>();
    for (int i = 0; i < N; i++) {
        Double d = pVals[i];
        if (dist.containsKey(d)) {
            Integer v = dist.get(d);
            dist.put(d, v + 1);
        } else {
            dist.put(d, 1);
        }
    }
    //Distribution series
    XYSeries dSeries = ChartUtils.createXYSeries(dist, pName);
    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(dSeries);
    JFreeChart chart = ChartFactory.createXYLineChart(pName, pX, pY, dataset, PlotOrientation.VERTICAL, true, false, false);
    chart.removeLegend();
    ChartUtils.decorateChart(chart);
    ChartUtils.scaleChart(chart, dSeries, isNormalized);
    return ChartUtils.renderChart(chart, pName + ".png");
}
Also used : XYSeries(org.jfree.data.xy.XYSeries) HashMap(java.util.HashMap) XYSeriesCollection(org.jfree.data.xy.XYSeriesCollection) JFreeChart(org.jfree.chart.JFreeChart)

Example 18 with XYSeries

use of org.jfree.data.xy.XYSeries in project gephi by gephi.

the class WeightedDegree method getReport.

@Override
public String getReport() {
    String report;
    if (isDirected) {
        report = getDirectedReport();
    } else {
        //Distribution series
        XYSeries dSeries = ChartUtils.createXYSeries(degreeDist, "Degree Distribution");
        XYSeriesCollection dataset1 = new XYSeriesCollection();
        dataset1.addSeries(dSeries);
        JFreeChart chart1 = ChartFactory.createXYLineChart("Degree Distribution", "Value", "Count", dataset1, PlotOrientation.VERTICAL, true, false, false);
        chart1.removeLegend();
        ChartUtils.decorateChart(chart1);
        ChartUtils.scaleChart(chart1, dSeries, false);
        String degreeImageFile = ChartUtils.renderChart(chart1, "w-degree-distribution.png");
        NumberFormat f = new DecimalFormat("#0.000");
        report = "<HTML> <BODY> <h1>Weighted Degree Report </h1> " + "<hr>" + "<br> <h2> Results: </h2>" + "Average Weighted Degree: " + f.format(avgWDegree) + "<br /><br />" + degreeImageFile + "</BODY></HTML>";
    }
    return report;
}
Also used : XYSeries(org.jfree.data.xy.XYSeries) DecimalFormat(java.text.DecimalFormat) XYSeriesCollection(org.jfree.data.xy.XYSeriesCollection) JFreeChart(org.jfree.chart.JFreeChart) NumberFormat(java.text.NumberFormat)

Example 19 with XYSeries

use of org.jfree.data.xy.XYSeries in project gephi by gephi.

the class DynamicClusteringCoefficient method getReport.

@Override
public String getReport() {
    //Time series
    XYSeries dSeries = ChartUtils.createXYSeries(averages, "Clustering Coefficient Time Series");
    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(dSeries);
    JFreeChart chart = ChartFactory.createXYLineChart("Clustering Coefficient", "Time", "Average Clustering Coefficient", dataset, PlotOrientation.VERTICAL, true, false, false);
    chart.removeLegend();
    ChartUtils.decorateChart(chart);
    ChartUtils.scaleChart(chart, dSeries, false);
    String coefficientImageFile = ChartUtils.renderChart(chart, "coefficient-ts.png");
    NumberFormat f = new DecimalFormat("#0.000000");
    String report = "<HTML> <BODY> <h1>Dynamic Clustering Coefficient Report </h1> " + "<hr>" + "<br> Bounds: from " + f.format(bounds.getLow()) + " to " + f.format(bounds.getHigh()) + "<br> Window: " + window + "<br> Tick: " + tick + "<br><br><h2> Average clustering cloefficient over time: </h2>" + "<br /><br />" + coefficientImageFile;
    /*for (Interval<Double> average : averages) {
        report += average.toString(dynamicModel.getTimeFormat().equals(DynamicModel.TimeFormat.DOUBLE)) + "<br />";
        }*/
    report += "<br /><br /></BODY></HTML>";
    return report;
}
Also used : XYSeries(org.jfree.data.xy.XYSeries) DecimalFormat(java.text.DecimalFormat) XYSeriesCollection(org.jfree.data.xy.XYSeriesCollection) JFreeChart(org.jfree.chart.JFreeChart) NumberFormat(java.text.NumberFormat)

Example 20 with XYSeries

use of org.jfree.data.xy.XYSeries in project gephi by gephi.

the class ChartUtils method createXYSeries.

public static XYSeries createXYSeries(Map data, String name) {
    XYSeries series = new XYSeries(name);
    for (Iterator it = data.entrySet().iterator(); it.hasNext(); ) {
        Map.Entry d = (Map.Entry) it.next();
        Number x = (Number) d.getKey();
        Number y = (Number) d.getValue();
        series.add(x, y);
    }
    return series;
}
Also used : XYSeries(org.jfree.data.xy.XYSeries) Iterator(java.util.Iterator) Map(java.util.Map)

Aggregations

XYSeries (org.jfree.data.xy.XYSeries)25 XYSeriesCollection (org.jfree.data.xy.XYSeriesCollection)24 JFreeChart (org.jfree.chart.JFreeChart)17 DecimalFormat (java.text.DecimalFormat)11 NumberFormat (java.text.NumberFormat)11 HashMap (java.util.HashMap)6 Map (java.util.Map)2 BufferedReader (java.io.BufferedReader)1 FileReader (java.io.FileReader)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Node (org.gephi.graph.api.Node)1 XYPlot (org.jfree.chart.plot.XYPlot)1 XYLineAndShapeRenderer (org.jfree.chart.renderer.xy.XYLineAndShapeRenderer)1 XYSplineRenderer (org.jfree.chart.renderer.xy.XYSplineRenderer)1 XYDataItem (org.jfree.data.xy.XYDataItem)1