de.erichseifert.gral.data.DataSeries Java Examples
The following examples show how to use
de.erichseifert.gral.data.DataSeries.
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 |
public AreaPlot() { // Generate data DataTable data = new DataTable(Double.class, Double.class, Double.class, Double.class); for (double x = 0.0; x < 50; x ++) { double y1 = Double.NaN, y2 = Double.NaN, y3 = Double.NaN; y1 = random.nextGaussian(); y2 = random.nextGaussian(); y3 = random.nextGaussian(); data.add(x, y1, y2, y3); } // Create data series DataSeries data1 = new DataSeries("series 1", data, 0, 1); DataSeries data2 = new DataSeries("series 2", data, 0, 2); DataSeries data3 = new DataSeries("series 3", data, 0, 3); // Create new xy-plot XYPlot plot = new XYPlot(data1, data2, data3); plot.setLegendVisible(true); plot.setInsets(new Insets2D.Double(20.0, 40.0, 20.0, 20.0)); // Format data series formatFilledArea(plot, data1, COLOR2); formatFilledArea(plot, data2, COLOR1); formatLineArea(plot, data3, GraphicsUtils.deriveDarker(COLOR1)); // Add plot to Swing component add(new InteractivePanel(plot)); }
Example #2
Source File: ScatterPlot.java From cf4j with Apache License 2.0 | 4 votes |
@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; }