List of usage examples for org.jfree.chart.axis NumberAxis NumberAxis
public NumberAxis(String label)
From source file:info.debatty.java.datasets.examples.GaussianMixtureBuilder.java
/** * Creates a new fast scatter plot demo. * * @param title the frame title.//from ww w . j av a2s .c om */ FastScatterPlot2D(final String title, final float[][] data) { super(title); final NumberAxis x_axis = new NumberAxis("X"); x_axis.setAutoRangeIncludesZero(false); final NumberAxis y_axis = new NumberAxis("Y"); y_axis.setAutoRangeIncludesZero(false); final FastScatterPlot plot = new FastScatterPlot(data, x_axis, y_axis); final JFreeChart chart = new JFreeChart(title, plot); // force aliasing of the rendered content.. chart.getRenderingHints().put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); final ChartPanel panel = new ChartPanel(chart, true); panel.setPreferredSize(new java.awt.Dimension(1024, 768)); setContentPane(panel); }
From source file:org.mwc.asset.netasset2.sensor2.VSensor.java
/** * Create the composite./* w w w. j a v a2 s . co m*/ * * @param parent * @param style */ public VSensor(final Composite parent, final int style) { super(parent, style); setLayout(new BorderLayout(0, 0)); final ToolBar toolBar = new ToolBar(this, SWT.FLAT | SWT.RIGHT); toolBar.setLayoutData(BorderLayout.NORTH); // ToolItem testBtn = new ToolItem(toolBar, SWT.NONE); // testBtn.setText("Test 1"); // testBtn.addSelectionListener(new SelectionAdapter() // { // // @Override // public void widgetSelected(SelectionEvent e) // { // doTest(); // } // }); final ToolItem tltmDropdownItem = new ToolItem(toolBar, SWT.DROP_DOWN); tltmDropdownItem.setText("Visible period"); final DropdownSelectionListener drops = new DropdownSelectionListener(tltmDropdownItem); drops.add("5 Mins", 5 * 60); drops.add("15 Mins", 15 * 60); drops.add("60 Mins", 60 * 60); drops.add("All data", 0); tltmDropdownItem.addSelectionListener(drops); final Composite sashForm = new Composite(this, SWT.EMBEDDED); // now we need a Swing object to put our chart into final Frame _plotControl = SWT_AWT.new_Frame(sashForm); // the y axis is common to hi & lo res. Format it here final NumberAxis yAxis = new NumberAxis("Degs"); // yAxis.setRange(0, 360); yAxis.setAutoRange(true); yAxis.setTickUnit(new NumberTickUnit(45)); // create a date-formatting axis _dateAxis = new RelativeDateAxis(); _dateAxis.setStandardTickUnits(DateAxisEditor.createStandardDateTickUnitsAsTickUnits()); _dateAxis.setAutoRange(true); final XYItemRenderer theRenderer = new XYShapeRenderer(); _thePlot = new XYPlot(null, _dateAxis, yAxis, theRenderer); _thePlot.setOrientation(PlotOrientation.HORIZONTAL); _thePlot.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT); _thePlot.setBackgroundPaint(Color.BLACK); theRenderer.setPlot(_thePlot); _dateAxis.setLabelPaint(Color.GREEN); _dateAxis.setTickLabelPaint(Color.GREEN); _dateAxis.setAxisLinePaint(Color.GREEN); yAxis.setLabelPaint(Color.GREEN); yAxis.setTickLabelPaint(Color.GREEN); _thePlotArea = new JFreeChart(null, _thePlot); _thePlotArea.setBackgroundPaint(Color.BLACK); _thePlotArea.setBorderPaint(Color.BLACK); // set the color of the area surrounding the plot // - naah, don't bother. leave it in the application background color. // //////////////////////////////////////////////// // put the holder into one of our special items // //////////////////////////////////////////////// _chartInPanel = new ChartPanel(_thePlotArea, true); _plotControl.add(_chartInPanel); }
From source file:org.jfree.chart.demo.MultipleAxisDemo1.java
/** * Creates the demo chart./*from w w w . ja va 2s .c o m*/ * * @return The chart. */ private JFreeChart createChart() { final XYDataset dataset1 = createDataset("Series 1", 100.0, new Minute(), 200); final JFreeChart chart = ChartFactory.createTimeSeriesChart("Multiple Axis Demo 1", "Time of Day", "Primary Range Axis", dataset1, true, true, false); chart.setBackgroundPaint(Color.white); chart.addSubtitle(new TextTitle("Four datasets and four range axes.")); final XYPlot plot = chart.getXYPlot(); plot.setOrientation(PlotOrientation.VERTICAL); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0)); final StandardXYItemRenderer renderer = (StandardXYItemRenderer) plot.getRenderer(); renderer.setPaint(Color.black); // AXIS 2 final NumberAxis axis2 = new NumberAxis("Range Axis 2"); axis2.setAutoRangeIncludesZero(false); axis2.setLabelPaint(Color.red); axis2.setTickLabelPaint(Color.red); plot.setRangeAxis(1, axis2); plot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_LEFT); final XYDataset dataset2 = createDataset("Series 2", 1000.0, new Minute(), 170); plot.setDataset(1, dataset2); plot.mapDatasetToRangeAxis(1, 1); XYItemRenderer renderer2 = new StandardXYItemRenderer(); renderer2.setSeriesPaint(0, Color.red); plot.setRenderer(1, renderer2); // AXIS 3 final NumberAxis axis3 = new NumberAxis("Range Axis 3"); axis3.setLabelPaint(Color.blue); axis3.setTickLabelPaint(Color.blue); plot.setRangeAxis(2, axis3); final XYDataset dataset3 = createDataset("Series 3", 10000.0, new Minute(), 170); plot.setDataset(2, dataset3); plot.mapDatasetToRangeAxis(2, 2); XYItemRenderer renderer3 = new StandardXYItemRenderer(); renderer3.setSeriesPaint(0, Color.blue); plot.setRenderer(2, renderer3); // AXIS 4 final NumberAxis axis4 = new NumberAxis("Range Axis 4"); axis4.setLabelPaint(Color.green); axis4.setTickLabelPaint(Color.green); plot.setRangeAxis(3, axis4); final XYDataset dataset4 = createDataset("Series 4", 25.0, new Minute(), 200); plot.setDataset(3, dataset4); plot.mapDatasetToRangeAxis(3, 3); XYItemRenderer renderer4 = new StandardXYItemRenderer(); renderer4.setSeriesPaint(0, Color.green); plot.setRenderer(3, renderer4); return chart; }
From source file:playground.benjamin.scenarios.zurich.analysis.charts.BkDeltaUtilsQuantilesChart.java
public JFreeChart createChart() { XYPlot plot = new XYPlot(this.dataset, new NumberAxis("population deciles sorted by income"), new NumberAxis("delta utils"), null); XYItemRenderer renderer = new XYLineAndShapeRenderer(false, true); plot.setRenderer(renderer);/*from ww w .j ava2 s . co m*/ JFreeChart jchart = new JFreeChart("", plot); return jchart; }
From source file:org.jfree.chart.demo.OverlaidXYPlotDemo.java
/** * Creates an overlaid chart.// www . ja va 2 s . c o m * * @return The chart. */ private JFreeChart createOverlaidChart() { // create plot ... final IntervalXYDataset data1 = createDataset1(); final XYItemRenderer renderer1 = new XYBarRenderer(0.20); renderer1.setToolTipGenerator( new StandardXYToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT, new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("0.00"))); final DateAxis domainAxis = new DateAxis("Date"); domainAxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); final ValueAxis rangeAxis = new NumberAxis("Value"); final XYPlot plot = new XYPlot(data1, domainAxis, rangeAxis, renderer1); final double x = new Day(9, SerialDate.MARCH, 2002).getMiddleMillisecond(); final XYTextAnnotation annotation = new XYTextAnnotation("Hello!", x, 10000.0); annotation.setFont(new Font("SansSerif", Font.PLAIN, 9)); plot.addAnnotation(annotation); // add a second dataset and renderer... final XYDataset data2 = createDataset2(); final XYItemRenderer renderer2 = new StandardXYItemRenderer(); renderer2.setToolTipGenerator( new StandardXYToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT, new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("0.00"))); plot.setDataset(1, data2); plot.setRenderer(1, renderer2); plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); // return a new chart containing the overlaid plot... return new JFreeChart("Overlaid Plot Example", JFreeChart.DEFAULT_TITLE_FONT, plot, true); }
From source file:org.altusmetrum.altosuilib_2.AltosUIGraph.java
public AltosUIGraph(AltosUIEnable enable) { this.enable = enable; this.graphers = new ArrayList<AltosUIGrapher>(); this.series_index = 0; this.axis_index = 0; xAxis = new NumberAxis("Time (s)"); xAxis.setAutoRangeIncludesZero(true); plot = new XYPlot(); plot.setDomainAxis(xAxis);//w w w .ja v a2s. co m plot.setOrientation(PlotOrientation.VERTICAL); plot.setDomainPannable(true); plot.setRangePannable(true); chart = new JFreeChart("Flight", JFreeChart.DEFAULT_TITLE_FONT, plot, true); ChartUtilities.applyCurrentTheme(chart); plot.setDomainGridlinePaint(gridline_color); plot.setRangeGridlinePaint(gridline_color); plot.setBackgroundPaint(background_color); plot.setBackgroundAlpha((float) 1); chart.setBackgroundPaint(background_color); chart.setBorderPaint(border_color); panel = new ChartPanel(chart); panel.setMouseWheelEnabled(true); panel.setPreferredSize(new java.awt.Dimension(800, 500)); AltosPreferences.register_units_listener(this); }
From source file:org.matsim.counts.algorithms.graphs.BiasNormalizedErrorGraph.java
@Override public JFreeChart createChart(final int nbr) { DefaultCategoryDataset dataset0 = new DefaultCategoryDataset(); DefaultCategoryDataset dataset1 = new DefaultCategoryDataset(); this.errorStats = new ComparisonErrorStatsCalculator(this.ccl_); double[] meanNormRelError = this.errorStats.getMeanNormRelError(); // double[] meanAbsError = this.errorStats.getMeanAbsError(); double[] meanBias = this.errorStats.getMeanBias(); for (int h = 0; h < 24; h++) { meanNormRelError[h] *= 100;/*from ww w.jav a 2s .c o m*/ dataset0.addValue(meanNormRelError[h], "Mean norm rel error", Integer.toString(h + 1)); // dataset1.addValue(meanAbsError[h], "Mean abs error", Integer.toString(h + 1)); dataset1.addValue(meanBias[h], "Mean bias", Integer.toString(h + 1)); } this.chart_ = ChartFactory.createLineChart("", "Hour", "Mean norm rel error [%]", dataset0, PlotOrientation.VERTICAL, true, // legend? true, // tooltips? false // URLs? ); CategoryPlot plot = this.chart_.getCategoryPlot(); plot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_RIGHT); plot.setDataset(1, dataset1); plot.mapDatasetToRangeAxis(1, 1); final LineAndShapeRenderer renderer = new LineAndShapeRenderer(); renderer.setSeriesToolTipGenerator(0, new StandardCategoryToolTipGenerator()); plot.setRenderer(0, renderer); final CategoryAxis axis1 = new CategoryAxis("Hour"); axis1.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 7)); plot.setDomainAxis(axis1); // final ValueAxis axis2 = new NumberAxis("Mean abs {bias, error} [veh/h]"); final ValueAxis axis2 = new NumberAxis("Mean bias [veh/h]"); plot.setRangeAxis(1, axis2); final ValueAxis axis3 = plot.getRangeAxis(0); axis3.setRange(0.0, 100.0); final LineAndShapeRenderer renderer2 = new LineAndShapeRenderer(); renderer2.setSeriesToolTipGenerator(0, new StandardCategoryToolTipGenerator()); renderer2.setSeriesToolTipGenerator(1, new StandardCategoryToolTipGenerator()); // renderer2.setSeriesPaint(0, Color.black); plot.setRenderer(1, renderer2); plot.setDatasetRenderingOrder(DatasetRenderingOrder.REVERSE); return this.chart_; }
From source file:r2d2e.solution.moduloteste.teste.GraficoD2.java
/** * Creates a combined chart./*from ww w .j ava 2 s . c o m*/ * * @return the combined chart. */ private JFreeChart createCombinedChart() { // create subplot 1... final XYDataset data1 = collection; final XYItemRenderer renderer1 = new StandardXYItemRenderer(); final NumberAxis rangeAxis1 = new NumberAxis("Nvel (cm)"); final XYPlot subplot1 = new XYPlot(data1, null, rangeAxis1, renderer1); subplot1.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); /* final XYTextAnnotation annotation = new XYTextAnnotation("Hello!", 50.0, 10000.0); annotation.setFont(new Font("SansSerif", Font.PLAIN, 9)); annotation.setRotationAngle(Math.PI / 4.0); subplot1.addAnnotation(annotation); */ // create subplot 2... final XYDataset data2 = collection2; final XYItemRenderer renderer2 = new StandardXYItemRenderer(); final NumberAxis rangeAxis2 = new NumberAxis("Tenso (volts)"); final XYPlot subplot2 = new XYPlot(data2, null, rangeAxis2, renderer2); subplot2.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT); // create subplot 3... final XYDataset data3 = collection3; final XYItemRenderer renderer3 = new StandardXYItemRenderer(); final NumberAxis rangeAxis3 = new NumberAxis("Tenso (volts)"); final XYPlot subplot3 = new XYPlot(data3, null, rangeAxis3, renderer3); subplot3.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT); // parent plot... final CombinedDomainXYPlot plot = new CombinedDomainXYPlot(new NumberAxis("Tempo")); plot.setGap(10.0); // add the subplots... plot.add(subplot1, 1); plot.add(subplot2, 1); plot.add(subplot3, 1); plot.setOrientation(PlotOrientation.VERTICAL); // return a new chart containing the overlaid plot... return new JFreeChart("Grficos", JFreeChart.DEFAULT_TITLE_FONT, plot, true); }
From source file:com.sixrr.metrics.ui.charts.DiffDistributionDialog.java
private JFreeChart createChart(XYDataset dataset) { final String title = getTitle(); final NumberAxis xAxis = new NumberAxis(metricName); xAxis.setAutoRangeIncludesZero(false); if (metricType.equals(MetricType.Ratio) || metricType.equals(MetricType.RecursiveRatio)) { xAxis.setNumberFormatOverride(new PercentFormatter()); }/*from w ww .j av a 2s .c o m*/ final NumberAxis yAxis = new NumberAxis("%"); final XYItemRenderer renderer = new StandardXYItemRenderer(StandardXYItemRenderer.LINES); final XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); plot.setOrientation(PlotOrientation.VERTICAL); renderer.setToolTipGenerator(new StandardXYToolTipGenerator()); return new JFreeChart(title, JFreeChartConstants.DEFAULT_TITLE_FONT, plot, true); }
From source file:org.vast.stt.renderer.JFreeChart.XYPlotBuilder.java
public void createPlot(ChartScene scene) { this.scene = scene; // scene contains the axis info, so passing it in here for now datasetCount = 0;/*from w w w. j a v a 2 s .co m*/ rangeAxisCount = 0; currentItem = null; axisTable.clear(); plot = new XYPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); String axisName = "Time (s)"; NumberAxis domainAxis = new NumberAxis(axisName); domainAxis.setAutoRangeIncludesZero(false); domainAxis.setAutoRange(false); domainAxis.setNumberFormatOverride(new DateFormat()); domainAxis.setTickLabelInsets(new RectangleInsets(0, 30, 0, 30)); domainAxis.setLowerBound(scene.getDomainMin()); domainAxis.setUpperBound(scene.getDomainMax()); plot.setDomainAxis(datasetCount, domainAxis); }