use of org.jfree.chart.plot.XYPlot in project cytoscape-impl by cytoscape.
the class HeatMapLayer method createChart.
@Override
protected JFreeChart createChart(final XYZDataset dataset) {
final PlotOrientation plotOrientation = orientation == Orientation.HORIZONTAL ? PlotOrientation.HORIZONTAL : PlotOrientation.VERTICAL;
final SymbolAxis xAxis = new SymbolAxis(null, xLabels);
xAxis.setVisible(showDomainAxis);
xAxis.setAxisLineVisible(false);
xAxis.setTickMarksVisible(false);
xAxis.setTickLabelFont(xAxis.getLabelFont().deriveFont(axisFontSize));
xAxis.setTickLabelPaint(axisColor);
xAxis.setVerticalTickLabels(domainLabelPosition != LabelPosition.STANDARD);
xAxis.setLowerMargin(0.0);
xAxis.setUpperMargin(0.0);
final SymbolAxis yAxis = new SymbolAxis(null, yLabels);
yAxis.setVisible(showRangeAxis);
yAxis.setAxisLineVisible(false);
yAxis.setTickMarksVisible(false);
yAxis.setTickLabelFont(yAxis.getLabelFont().deriveFont(axisFontSize));
yAxis.setTickLabelPaint(axisColor);
yAxis.setLowerMargin(0.0);
yAxis.setUpperMargin(0.0);
yAxis.setInverted(true);
final XYBlockRenderer renderer = new XYBlockRenderer();
if (range != null && range.size() >= 2 && range.get(0) != null && range.get(1) != null) {
final int colorsSize = colors != null ? colors.size() : 0;
Color upperColor = colorsSize > 0 ? colors.get(0) : Color.BLUE;
Color zeroColor = colorsSize > 1 ? colors.get(1) : Color.WHITE;
Color lowerColor = colorsSize > 2 ? colors.get(2) : Color.RED;
Color nanColor = colorsSize > 3 ? colors.get(3) : Color.GRAY;
final ColorScale scale = new ColorScale(range.get(0), range.get(1), lowerColor, zeroColor, upperColor, nanColor);
renderer.setPaintScale(scale);
}
final XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
plot.setDomainAxis(xAxis);
plot.setDomainAxisLocation(AxisLocation.TOP_OR_LEFT);
plot.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT);
plot.setOutlineVisible(false);
plot.setDomainGridlinesVisible(false);
plot.setRangeGridlinesVisible(false);
plot.setBackgroundPaint(TRANSPARENT_COLOR);
plot.setInsets(new RectangleInsets(1.0, 1.0, 1.0, 1.0));
plot.setAxisOffset(new RectangleInsets(1.0, 1.0, 1.0, 1.0));
plot.setOrientation(plotOrientation);
final JFreeChart chart = new JFreeChart(null, plot);
chart.removeLegend();
chart.setBorderVisible(false);
chart.setBackgroundPaint(TRANSPARENT_COLOR);
chart.setPadding(new RectangleInsets(0.0, 0.0, 0.0, 0.0));
return chart;
}
use of org.jfree.chart.plot.XYPlot in project gephi by gephi.
the class ChartsUtils method setScatterPlotLinesEnabled.
/**
* Modify a scatter plot to show lines instead or shapes or not.
* @param scatterPlot Scatter plot to modify
* @param enabled Indicates if lines have to be shown
*/
public static void setScatterPlotLinesEnabled(final JFreeChart scatterPlot, final boolean enabled) {
XYPlot plot = (XYPlot) scatterPlot.getPlot();
XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
if (enabled) {
renderer.setSeriesLinesVisible(0, true);
renderer.setSeriesShapesVisible(0, false);
} else {
renderer.setSeriesLinesVisible(0, false);
renderer.setSeriesShapesVisible(0, true);
renderer.setSeriesShape(0, new java.awt.geom.Ellipse2D.Double(0, 0, 1, 1));
}
renderer.setSeriesPaint(0, Color.RED);
plot.setRenderer(0, renderer);
}
use of org.jfree.chart.plot.XYPlot in project gephi by gephi.
the class ChartsUtils method setScatterPlotLinearRegressionEnabled.
/**
* Modify a scatter plot to show linear regression or not.
* @param scatterPlot Scatter plot to modify
* @param enabled Indicates if linear regression has to be shown
*/
public static void setScatterPlotLinearRegressionEnabled(final JFreeChart scatterPlot, final boolean enabled) {
XYPlot plot = (XYPlot) scatterPlot.getPlot();
if (enabled) {
StandardXYItemRenderer regressionRenderer = new StandardXYItemRenderer();
regressionRenderer.setBaseSeriesVisibleInLegend(false);
plot.setDataset(1, regress((XYSeriesCollection) plot.getDataset(0)));
plot.setRenderer(1, regressionRenderer);
} else {
// Remove linear regression
plot.setDataset(1, null);
}
}
use of org.jfree.chart.plot.XYPlot in project gephi by gephi.
the class ChartsUtils method buildScatterPlot.
/**
* Build new Scatter plot. Appearance can be changed later with the other methods of ChartsUtils.
* @param data Data for the plot
* @param title Title for the chart
* @param xLabel Text for x label
* @param yLabel Text for y label
* @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 XYSeriesCollection data, final String title, final String xLabel, final String yLabel, final boolean useLines, final boolean useLinearRegression) {
JFreeChart scatterPlot = ChartFactory.createXYLineChart(title, xLabel, yLabel, data, PlotOrientation.VERTICAL, true, true, false);
XYPlot plot = (XYPlot) scatterPlot.getPlot();
plot.setBackgroundPaint(java.awt.Color.WHITE);
plot.setDomainGridlinePaint(java.awt.Color.GRAY);
plot.setRangeGridlinePaint(java.awt.Color.GRAY);
setScatterPlotLinesEnabled(scatterPlot, useLines);
setScatterPlotLinearRegressionEnabled(scatterPlot, useLinearRegression);
return scatterPlot;
}
use of org.jfree.chart.plot.XYPlot in project j6dof-flight-sim by chris-ali.
the class SimulationPlot method createPlots.
/**
* Populates the {@link plotLists} List with {@link XYPlot} objects created from the logsOut ArrayList
* argument. It first creates {@link XYSeries} objects with data from logsOut, adds those to
* {@link XYSeriesCollection}, adds those series collections to {@link XYPlot} objects, and finally
* puts the XYPlot objects into {@link plotList}. The types of {@link XYPlot} objects generated
* comes from settings in {@link SubPlotBundle}
*
* @param logsOut
* @param bundle
*/
private void createPlots(List<Map<SimOuts, Double>> logsOut, SubPlotBundle bundle) {
for (SubPlotOptions option : bundle.getSubPlots()) {
XYSeriesCollection collection = new XYSeriesCollection();
for (SimOuts simout : option.getyData()) {
XYSeries series = new XYSeries(simout.toString());
xySeriesData.put(simout, series);
collection.addSeries(series);
}
domainAxis = new NumberAxis(option.getxAxisName());
rangeAxes.put(option.getTitle(), new NumberAxis(option.getyAxisName()));
xyCollections.put(option.getTitle(), collection);
}
combinedDomPlot = new CombinedDomainXYPlot(domainAxis);
updateXYSeriesData(logsOut, bundle);
for (Map.Entry<String, XYSeriesCollection> entry : xyCollections.entrySet()) {
logger.debug("Creating a subplot called: " + entry.getKey() + "...");
XYPlot subPlot = new XYPlot(entry.getValue(), domainAxis, rangeAxes.get(entry.getKey()), new StandardXYItemRenderer());
plotList.add(subPlot);
}
}
Aggregations