use of org.jfree.data.xy.XYSeries in project gephi by gephi.
the class ConnectedComponents method getReport.
@Override
public String getReport() {
Map<Integer, Integer> sizeDist = new HashMap<>();
for (int v : componentsSize) {
if (!sizeDist.containsKey(v)) {
sizeDist.put(v, 0);
}
sizeDist.put(v, sizeDist.get(v) + 1);
}
//Distribution series
XYSeries dSeries = ChartUtils.createXYSeries(sizeDist, "Size Distribution");
XYSeriesCollection dataset1 = new XYSeriesCollection();
dataset1.addSeries(dSeries);
JFreeChart chart = ChartFactory.createXYLineChart("Size Distribution", "Size (number of nodes)", "Count", dataset1, PlotOrientation.VERTICAL, true, false, false);
chart.removeLegend();
ChartUtils.decorateChart(chart);
ChartUtils.scaleChart(chart, dSeries, false);
String imageFile = ChartUtils.renderChart(chart, "cc-size-distribution.png");
NumberFormat f = new DecimalFormat("#0.000");
String report = "<HTML> <BODY> <h1>Connected Components Report </h1> " + "<hr>" + "<br>" + "<h2> Parameters: </h2>" + "Network Interpretation: " + (isDirected ? "directed" : "undirected") + "<br>" + "<br> <h2> Results: </h2>" + "Number of Weakly Connected Components: " + componentCount + "<br>" + (isDirected ? "Number of Stronlgy Connected Components: " + stronglyCount + "<br>" : "") + "<br /><br />" + imageFile + "<br />" + "<h2> Algorithm: </h2>" + "Robert Tarjan, <i>Depth-First Search and Linear Graph Algorithms</i>, in SIAM Journal on Computing 1 (2): 146–160 (1972)<br />" + "</BODY> </HTML>";
return report;
}
use of org.jfree.data.xy.XYSeries in project gephi by gephi.
the class Hits method getReport.
/**
*
* @return
*/
@Override
public String getReport() {
//distribution of hub values
Map<Double, Integer> distHubs = new HashMap<>();
for (int i = 0; i < hubs.length; i++) {
Double d = hubs[i];
if (distHubs.containsKey(d)) {
Integer v = distHubs.get(d);
distHubs.put(d, v + 1);
} else {
distHubs.put(d, 1);
}
}
//distribution of authority values
Map<Double, Integer> distAuthorities = new HashMap<>();
for (int i = 0; i < authority.length; i++) {
Double d = authority[i];
if (distAuthorities.containsKey(d)) {
Integer v = distAuthorities.get(d);
distAuthorities.put(d, v + 1);
} else {
distAuthorities.put(d, 1);
}
}
//Distribution of hub series
XYSeries dHubsSeries = ChartUtils.createXYSeries(distHubs, "Hubs");
//Distribution of authority series
XYSeries dAuthsSeries = ChartUtils.createXYSeries(distAuthorities, "Authority");
XYSeriesCollection datasetHubs = new XYSeriesCollection();
datasetHubs.addSeries(dHubsSeries);
XYSeriesCollection datasetAuths = new XYSeriesCollection();
datasetAuths.addSeries(dAuthsSeries);
JFreeChart chart = ChartFactory.createXYLineChart("Hubs Distribution", "Score", "Count", datasetHubs, PlotOrientation.VERTICAL, true, false, false);
chart.removeLegend();
ChartUtils.decorateChart(chart);
ChartUtils.scaleChart(chart, dHubsSeries, true);
String imageFile1 = ChartUtils.renderChart(chart, "hubs.png");
JFreeChart chart2 = ChartFactory.createXYLineChart("Authority Distribution", "Score", "Count", datasetAuths, PlotOrientation.VERTICAL, true, false, false);
chart2.removeLegend();
ChartUtils.decorateChart(chart2);
ChartUtils.scaleChart(chart2, dAuthsSeries, true);
String imageFile2 = ChartUtils.renderChart(chart2, "authorities.png");
String report = "<HTML> <BODY> <h1> HITS Metric Report </h1>" + "<hr>" + "<br />" + "<h2> Parameters: </h2> Ε = " + this.epsilon + "<br /> <h2> Results: </h2><br />" + imageFile1 + "<br />" + imageFile2 + "<br /><br />" + "<h2> Algorithm: </h2>" + "Jon M. Kleinberg, <i>Authoritative Sources in a Hyperlinked Environment</i>, in Journal of the ACM 46 (5): 604–632 (1999)<br />" + "</BODY> </HTML>";
return report;
}
use of org.jfree.data.xy.XYSeries in project gephi by gephi.
the class ChartsUtils method buildScatterPlot.
/**
* Build new scatter plot from numbers array using a default title and xLabel.
* String dataName will be used for yLabel.
* Appearance can be changed later with the other methods of ChartsUtils.
* @param numbers Numbers for the scatter plot
* @param dataName Name of the numbers data
* @param useLines Indicates if lines have to be drawn instead of shapes
* @param useLinearRegression Indicates if the scatter plot has to have linear regreesion line drawn
* @return Scatter plot for the data and appearance options
*/
public static JFreeChart buildScatterPlot(final Number[] numbers, final String dataName, final boolean useLines, final boolean useLinearRegression) {
if (numbers == null || numbers.length == 0) {
return null;
}
XYSeriesCollection dataset = new XYSeriesCollection();
XYSeries series = new XYSeries(dataName);
for (int i = 0; i < numbers.length; i++) {
series.add(i, numbers[i]);
}
dataset.addSeries(series);
JFreeChart scatterPlot = buildScatterPlot(dataset, getMessage("ChartsUtils.report.scatter-plot.title"), getMessage("ChartsUtils.report.scatter-plot.xLabel"), dataName, useLines, useLinearRegression);
return scatterPlot;
}
use of org.jfree.data.xy.XYSeries in project uncommons-maths by dwdyer.
the class GraphPanel method generateGraph.
public void generateGraph(String title, Map<Double, Double> observedValues, Map<Double, Double> expectedValues, double expectedMean, double expectedStandardDeviation, boolean discrete) {
XYSeriesCollection dataSet = new XYSeriesCollection();
XYSeries observedSeries = new XYSeries("Observed");
dataSet.addSeries(observedSeries);
XYSeries expectedSeries = new XYSeries("Expected");
dataSet.addSeries(expectedSeries);
for (Map.Entry<Double, Double> entry : observedValues.entrySet()) {
observedSeries.add(entry.getKey(), entry.getValue());
}
for (Map.Entry<Double, Double> entry : expectedValues.entrySet()) {
expectedSeries.add(entry.getKey(), entry.getValue());
}
JFreeChart chart = ChartFactory.createXYLineChart(title, "Value", "Probability", dataSet, PlotOrientation.VERTICAL, true, false, false);
XYPlot plot = (XYPlot) chart.getPlot();
if (discrete) {
// Render markers at each data point (these discrete points are the
// distibution, not the lines between them).
plot.setRenderer(new XYLineAndShapeRenderer());
} else {
// Render smooth lines between points for a continuous distribution.
XYSplineRenderer renderer = new XYSplineRenderer();
renderer.setBaseShapesVisible(false);
plot.setRenderer(renderer);
}
chartPanel.setChart(chart);
}
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;
}
Aggregations