Java Code Examples for de.erichseifert.gral.plots.points.PointRenderer#setColor()

The following examples show how to use de.erichseifert.gral.plots.points.PointRenderer#setColor() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AreaPlot.java    From Java-Data-Science-Cookbook with MIT License 5 votes vote down vote up
private static void formatFilledArea(XYPlot plot, DataSource data, Color color) {
	PointRenderer point = new DefaultPointRenderer2D();
	point.setColor(color);
	plot.setPointRenderer(data, point);
	LineRenderer line = new DefaultLineRenderer2D();
	line.setColor(color);
	line.setGap(3.0);
	line.setGapRounded(true);
	plot.setLineRenderer(data, line);
	AreaRenderer area = new DefaultAreaRenderer2D();
	area.setColor(GraphicsUtils.deriveWithAlpha(color, 64));
	plot.setAreaRenderer(data, area);
}
 
Example 2
Source File: AreaPlot.java    From Java-Data-Science-Cookbook with MIT License 5 votes vote down vote up
private static void formatLineArea(XYPlot plot, DataSource data, Color color) {
	PointRenderer point = new DefaultPointRenderer2D();
	point.setColor(color);
	plot.setPointRenderer(data, point);
	plot.setLineRenderer(data, null);
	AreaRenderer area = new LineAreaRenderer2D();
	area.setGap(3.0);
	area.setColor(color);
	plot.setAreaRenderer(data, area);
}
 
Example 3
Source File: ScatterPlot.java    From cf4j with Apache License 2.0 4 votes vote down vote up
@Override
protected AbstractPlot getGralPlot() {

  // Create XY plot with data
  DataTable data = new DataTable(Double.class, Double.class);
  for (Pair<Double, Double> point : this.points) {
    data.add(point.getFirst(), point.getSecond());
  }

  DataSeries series = new DataSeries("Series", data);

  XYPlot plot = new XYPlot(series);

  // Customize plot
  plot.setBackground(PlotSettings.getBackgroundColor());

  PointRenderer pr = new DefaultPointRenderer2D();
  pr.setShape(new Ellipse2D.Double(-3.0, -3.0, 6.0, 6.0));
  pr.setColor(GraphicsUtils.deriveWithAlpha(PlotSettings.getColor(0), 128));
  plot.setPointRenderers(series, pr);

  plot.setInsets(
      new Insets2D.Double(
          PlotSettings.getClearInset(),
          PlotSettings.getyAxisInset(),
          PlotSettings.getxAxisInset(),
          PlotSettings.getClearInset()));

  // Customize x axis
  AxisRenderer xAxisRenderer = plot.getAxisRenderer(XYPlot.AXIS_X);

  xAxisRenderer.setLabel(new Label(xLabel));
  xAxisRenderer.getLabel().setFont(PlotSettings.getPrimaryFont());
  xAxisRenderer.setLabelDistance(PlotSettings.getxAxisLabelDistance());

  xAxisRenderer.setTickFont(PlotSettings.getSecondaryFont());
  xAxisRenderer.setTickLabelFormat(NumberFormat.getInstance(Locale.US));
  xAxisRenderer.setTicksAutoSpaced(true);

  // Customize y axis
  AxisRenderer yAxisRenderer = plot.getAxisRenderer(XYPlot.AXIS_Y);

  yAxisRenderer.setLabel(new Label(yLabel));
  yAxisRenderer.getLabel().setFont(PlotSettings.getPrimaryFont());
  yAxisRenderer.getLabel().setRotation(90);
  yAxisRenderer.setLabelDistance(PlotSettings.getyAxisLabelDistance());

  yAxisRenderer.setTickFont(PlotSettings.getSecondaryFont());
  yAxisRenderer.setTickLabelFormat(NumberFormat.getInstance(Locale.US));
  yAxisRenderer.setTicksAutoSpaced(true);

  xAxisRenderer.setIntersection(-Double.MAX_VALUE);
  yAxisRenderer.setIntersection(-Double.MAX_VALUE);

  // Customize navigator settings
  plot.getNavigator().setZoom(0.9);
  plot.getNavigator().setZoomable(false);

  return plot;
}