List of usage examples for org.jfree.chart.axis NumberAxis NumberAxis
public NumberAxis(String label)
From source file:org.spantus.exp.segment.exec.DrawSegmentComparision.java
/** * initialize// w ww .j av a2s . com */ public void init() { final CombinedDomainXYPlot plot = new CombinedDomainXYPlot(new NumberAxis("Time")); plot.setGap(10.0); plot.setOrientation(PlotOrientation.VERTICAL); XYSeries[] seriesArr = createSeries(getWavName(), getMarkerName()); for (XYSeries series : seriesArr) { final XYSeriesCollection data1 = new XYSeriesCollection(series); final XYItemRenderer renderer1 = new StandardXYItemRenderer(); final NumberAxis rangeAxis1 = new NumberAxis(series.getDescription()); final XYPlot subplot = new XYPlot(data1, null, rangeAxis1, renderer1); plot.add(subplot, 1); } final JFreeChart chart = new JFreeChart("Segmentation Result", JFreeChart.DEFAULT_TITLE_FONT, plot, false); final ChartPanel chartPanel = new ChartPanel(chart); setContentPane(chartPanel); chartPanel.setPreferredSize(new Dimension(500, 270)); }
From source file:org.jfree.chart.demo.CombinedXYPlotDemo3.java
/** * Creates a combined XYPlot chart.//from ww w .j a v a 2 s. c o m * * @return the combined chart. */ private JFreeChart createCombinedChart() { // create a default chart based on some sample data... final TimeSeriesCollection dataset0 = new TimeSeriesCollection(); final TimeSeries eur = DemoDatasetFactory.createEURTimeSeries(); dataset0.addSeries(eur); final TimeSeriesCollection dataset1 = new TimeSeriesCollection(); final TimeSeries mav = MovingAverage.createMovingAverage(eur, "EUR/GBP (30 Day MA)", 30, 30); dataset1.addSeries(eur); dataset1.addSeries(mav); final TimeSeriesCollection dataset2 = new TimeSeriesCollection(); dataset2.addSeries(eur); JFreeChart chart = null; // make a common vertical axis for all the sub-plots final NumberAxis valueAxis = new NumberAxis("Value"); valueAxis.setAutoRangeIncludesZero(false); // override default // make a horizontally combined plot final CombinedRangeXYPlot parent = new CombinedRangeXYPlot(valueAxis); // add subplot 1... final XYPlot subplot1 = new XYPlot(dataset0, new DateAxis("Date 1"), null, new StandardXYItemRenderer()); parent.add(subplot1, 1); // add subplot 2... final XYPlot subplot2 = new XYPlot(dataset1, new DateAxis("Date 2"), null, new StandardXYItemRenderer()); parent.add(subplot2, 1); // add subplot 3... final XYPlot subplot3 = new XYPlot(dataset2, new DateAxis("Date 3"), null, new XYBarRenderer(0.20)); parent.add(subplot3, 1); // now make the top level JFreeChart chart = new JFreeChart("Demo Chart", JFreeChart.DEFAULT_TITLE_FONT, parent, true); // then customise it a little... final TextTitle subtitle = new TextTitle("This is a subtitle", new Font("SansSerif", Font.BOLD, 12)); chart.addSubtitle(subtitle); chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 0, 1000, Color.blue)); return chart; }
From source file:org.matsim.counts.algorithms.graphs.BoxPlotErrorGraph.java
@SuppressWarnings("unchecked") @Override//from w w w . j a va2 s . c om public JFreeChart createChart(final int nbr) { DefaultBoxAndWhiskerCategoryDataset dataset0 = new DefaultBoxAndWhiskerCategoryDataset(); DefaultBoxAndWhiskerCategoryDataset dataset1 = new DefaultBoxAndWhiskerCategoryDataset(); final ArrayList<Double>[] listRel = new ArrayList[24]; final ArrayList<Double>[] listAbs = new ArrayList[24]; // init for (int i = 0; i < 24; i++) { listRel[i] = new ArrayList<Double>(); listAbs[i] = new ArrayList<Double>(); } // add the values of all counting stations to each hour for (CountSimComparison cc : this.ccl_) { int hour = cc.getHour() - 1; listRel[hour].add(cc.calculateRelativeError()); listAbs[hour].add(cc.getSimulationValue() - cc.getCountValue()); } // add the collected values to the graph / dataset for (int i = 0; i < 24; i++) { dataset0.add(listRel[i], "Rel Error", Integer.toString(i + 1)); dataset1.add(listAbs[i], "Abs Error", Integer.toString(i + 1)); } String title = "Iteration: " + this.iteration_; final CombinedDomainCategoryPlot plot = new CombinedDomainCategoryPlot(); final CategoryAxis xAxis = new CategoryAxis("Hour"); final NumberAxis yAxis0 = new NumberAxis("Signed Rel. Error [%]"); final NumberAxis yAxis1 = new NumberAxis("Signed Abs. Error [veh]"); yAxis0.setAutoRangeIncludesZero(false); yAxis1.setAutoRangeIncludesZero(false); final BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer(); renderer.setFillBox(false); renderer.setSeriesPaint(0, Color.blue); renderer.setSeriesToolTipGenerator(0, new BoxAndWhiskerToolTipGenerator()); CategoryPlot subplot0 = new CategoryPlot(dataset0, xAxis, yAxis0, renderer); CategoryPlot subplot1 = new CategoryPlot(dataset1, xAxis, yAxis1, renderer); plot.add(subplot0); plot.add(subplot1); final CategoryAxis axis1 = new CategoryAxis("hour"); axis1.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 7)); axis1.setCategoryLabelPositions(CategoryLabelPositions.UP_45); plot.setDomainAxis(axis1); this.chart_ = new JFreeChart(title, new Font("SansSerif", Font.BOLD, 14), plot, false); return this.chart_; }
From source file:de.atomfrede.tools.evalutation.tools.plot.custom.CustomSimplePlot.java
@Override protected JFreeChart createChart(XYDatasetWrapper... datasetWrappers) { XYDatasetWrapper mainDataset = datasetWrappers[0]; JFreeChart chart = ChartFactory.createXYLineChart(mainDataset.getSeriesName(), "Index", mainDataset.getSeriesName(), mainDataset.getDataset(), PlotOrientation.VERTICAL, true, false, false);/* ww w. j ava 2s . c o m*/ XYPlot plot = (XYPlot) chart.getPlot(); // all adjustments for first/main dataset plot.getRangeAxis(0).setLowerBound(mainDataset.getMinimum()); plot.getRangeAxis(0).setUpperBound(mainDataset.getMaximum()); // some additional "design" stuff for the plot plot.getRenderer(0).setSeriesPaint(0, mainDataset.getSeriesColor()); plot.getRenderer(0).setSeriesStroke(0, new BasicStroke(mainDataset.getStroke())); for (int i = 1; i < datasetWrappers.length; i++) { XYDatasetWrapper wrapper = datasetWrappers[i]; plot.setDataset(i, wrapper.getDataset()); chart.setTitle(chart.getTitle().getText() + "/" + wrapper.getSeriesName()); NumberAxis axis = new NumberAxis(wrapper.getSeriesName()); plot.setRangeAxis(i, axis); plot.setRangeAxisLocation(i, AxisLocation.BOTTOM_OR_RIGHT); plot.getRangeAxis(i).setLowerBound(wrapper.getMinimum() - 15.0); plot.getRangeAxis(i).setUpperBound(wrapper.getMaximum() + 15.0); // map the second dataset to the second axis plot.mapDatasetToRangeAxis(i, i); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setBaseShapesVisible(false); renderer.setSeriesStroke(0, new BasicStroke(wrapper.getStroke())); plot.setRenderer(i, renderer); plot.getRenderer(i).setSeriesPaint(0, wrapper.getSeriesColor()); } // change the background and gridline colors plot.setBackgroundPaint(Color.white); plot.setDomainMinorGridlinePaint(Color.LIGHT_GRAY); plot.setDomainGridlinePaint(Color.LIGHT_GRAY); plot.setRangeGridlinePaint(Color.LIGHT_GRAY); return chart; }
From source file:org.matsim.counts.algorithms.graphs.BoxPlotNormalizedErrorGraph.java
@SuppressWarnings("unchecked") @Override/*from w w w . ja v a 2 s .com*/ public JFreeChart createChart(final int nbr) { DefaultBoxAndWhiskerCategoryDataset dataset0 = new DefaultBoxAndWhiskerCategoryDataset(); DefaultBoxAndWhiskerCategoryDataset dataset1 = new DefaultBoxAndWhiskerCategoryDataset(); final ArrayList<Double>[] listRel = new ArrayList[24]; final ArrayList<Double>[] listAbs = new ArrayList[24]; // init for (int i = 0; i < 24; i++) { listRel[i] = new ArrayList<Double>(); listAbs[i] = new ArrayList<Double>(); } // add the values of all counting stations to each hour for (CountSimComparison cc : this.ccl_) { int hour = cc.getHour() - 1; listRel[hour].add(cc.calculateNormalizedRelativeError() * 100); listAbs[hour].add(cc.getSimulationValue() - cc.getCountValue()); } // add the collected values to the graph / dataset for (int i = 0; i < 24; i++) { dataset0.add(listRel[i], "Rel Norm Error", Integer.toString(i + 1)); dataset1.add(listAbs[i], "Abs Error", Integer.toString(i + 1)); } String title = "Iteration: " + this.iteration_; final CombinedDomainCategoryPlot plot = new CombinedDomainCategoryPlot(); final CategoryAxis xAxis = new CategoryAxis("Hour"); final NumberAxis yAxis0 = new NumberAxis("Norm. Rel. Error [%]"); final NumberAxis yAxis1 = new NumberAxis("Signed Abs. Error [veh]"); yAxis0.setAutoRangeIncludesZero(false); yAxis1.setAutoRangeIncludesZero(false); final BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer(); renderer.setFillBox(false); renderer.setSeriesPaint(0, Color.blue); renderer.setSeriesToolTipGenerator(0, new BoxAndWhiskerToolTipGenerator()); CategoryPlot subplot0 = new CategoryPlot(dataset0, xAxis, yAxis0, renderer); CategoryPlot subplot1 = new CategoryPlot(dataset1, xAxis, yAxis1, renderer); plot.add(subplot0); plot.add(subplot1); final CategoryAxis axis1 = new CategoryAxis("hour"); axis1.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 7)); axis1.setCategoryLabelPositions(CategoryLabelPositions.UP_45); plot.setDomainAxis(axis1); this.chart_ = new JFreeChart(title, new Font("SansSerif", Font.BOLD, 14), plot, false); return this.chart_; }
From source file:org.jfree.chart.demo.DualAxisDemo3.java
/** * Creates a new demo instance.//from w ww.j ava 2 s . c o m * * @param title the frame title. */ public DualAxisDemo3(final String title) { super(title); final CategoryDataset dataset1 = createDataset1(); // create the chart... final JFreeChart chart = ChartFactory.createBarChart("Dual Axis Chart", // chart title "Category", // domain axis label "Value", // range axis label dataset1, // dataset PlotOrientation.HORIZONTAL, // orientation true, // include legend true, false); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... // set the background color for the chart... chart.setBackgroundPaint(new Color(0xCC, 0xFF, 0xCC)); // chart.getLegend().setAnchor(Legend.WEST); // get a reference to the plot for further customisation... final CategoryPlot plot = chart.getCategoryPlot(); plot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_RIGHT); // plot.getDomainAxis().setMaxCategoryLabelWidthRatio(10.0f); final CategoryDataset dataset2 = createDataset2(); final ValueAxis axis2 = new NumberAxis("Secondary"); plot.setRangeAxis(1, axis2); plot.setDataset(1, dataset2); plot.mapDatasetToRangeAxis(1, 1); plot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_RIGHT); final CategoryItemRenderer renderer2 = new LineAndShapeRenderer(); plot.setRenderer(1, renderer2); // OPTIONAL CUSTOMISATION COMPLETED. // add the chart to a panel... final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); setContentPane(chartPanel); }
From source file:net.sf.mzmine.modules.visualization.neutralloss.NeutralLossPlot.java
NeutralLossPlot(NeutralLossVisualizerWindow visualizer, NeutralLossDataSet dataset, Object xAxisType) { super(null, true); this.visualizer = visualizer; setBackground(Color.white);// w ww .j a v a2 s.c o m setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR)); NumberFormat rtFormat = MZmineCore.getConfiguration().getRTFormat(); NumberFormat mzFormat = MZmineCore.getConfiguration().getMZFormat(); // set the X axis (retention time) properties NumberAxis xAxis; if (xAxisType.equals(NeutralLossParameters.xAxisPrecursor)) { xAxis = new NumberAxis("Precursor m/z"); xAxis.setNumberFormatOverride(mzFormat); } else { xAxis = new NumberAxis("Retention time"); xAxis.setNumberFormatOverride(rtFormat); } xAxis.setUpperMargin(0); xAxis.setLowerMargin(0); xAxis.setAutoRangeIncludesZero(false); // set the Y axis (intensity) properties NumberAxis yAxis = new NumberAxis("Neutral loss (Da)"); yAxis.setAutoRangeIncludesZero(false); yAxis.setNumberFormatOverride(mzFormat); yAxis.setUpperMargin(0); yAxis.setLowerMargin(0); // set the renderer properties defaultRenderer = new NeutralLossDataPointRenderer(false, true); defaultRenderer.setTransparency(0.4f); setSeriesColorRenderer(0, pointColor, dataPointsShape); setSeriesColorRenderer(1, searchPrecursorColor, dataPointsShape2); setSeriesColorRenderer(2, searchNeutralLossColor, dataPointsShape2); // tooltips defaultRenderer.setBaseToolTipGenerator(dataset); // set the plot properties plot = new XYPlot(dataset, xAxis, yAxis, defaultRenderer); plot.setBackgroundPaint(Color.white); plot.setRenderer(defaultRenderer); plot.setSeriesRenderingOrder(SeriesRenderingOrder.FORWARD); // chart properties chart = new JFreeChart("", titleFont, plot, false); chart.setBackgroundPaint(Color.white); setChart(chart); // title chartTitle = chart.getTitle(); chartTitle.setMargin(5, 0, 0, 0); chartTitle.setFont(titleFont); // disable maximum size (we don't want scaling) setMaximumDrawWidth(Integer.MAX_VALUE); setMaximumDrawHeight(Integer.MAX_VALUE); // set crosshair (selection) properties plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); plot.setDomainCrosshairPaint(crossHairColor); plot.setRangeCrosshairPaint(crossHairColor); plot.setDomainCrosshairStroke(crossHairStroke); plot.setRangeCrosshairStroke(crossHairStroke); plot.addRangeMarker(new ValueMarker(0)); // set focusable state to receive key events setFocusable(true); // register key handlers GUIUtils.registerKeyHandler(this, KeyStroke.getKeyStroke("SPACE"), visualizer, "SHOW_SPECTRUM"); // add items to popup menu JPopupMenu popupMenu = getPopupMenu(); popupMenu.addSeparator(); JMenuItem highLightPrecursorRange = new JMenuItem("Highlight precursor m/z range..."); highLightPrecursorRange.addActionListener(visualizer); highLightPrecursorRange.setActionCommand("HIGHLIGHT_PRECURSOR"); popupMenu.add(highLightPrecursorRange); JMenuItem highLightNeutralLossRange = new JMenuItem("Highlight neutral loss m/z range..."); highLightNeutralLossRange.addActionListener(visualizer); highLightNeutralLossRange.setActionCommand("HIGHLIGHT_NEUTRALLOSS"); popupMenu.add(highLightNeutralLossRange); }
From source file:wsattacker.plugin.intelligentdos.ui.helper.ChartHelper.java
public static JFreeChart createWhiskerChart(SuccessfulAttack sa) { BoxAndWhiskerCategoryDataset boxandwhiskercategorydataset = createDataset(sa); final BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer(); renderer.setMaximumBarWidth(0.05);//w ww . j av a 2s . c om renderer.setMeanVisible(false); renderer.setSeriesPaint(0, Color.GREEN); renderer.setSeriesPaint(1, Color.RED); renderer.setSeriesPaint(2, Color.BLUE); NumberAxis numberAxis = new NumberAxis("duration in ms"); CategoryPlot categoryplot = new CategoryPlot(boxandwhiskercategorydataset, new CategoryAxis(""), numberAxis, renderer); categoryplot.setDomainGridlinesVisible(true); categoryplot.setRangePannable(true); NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis(); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); JFreeChart jFreeChart = new JFreeChart("", new Font("SansSerif", Font.BOLD, 14), categoryplot, true); jFreeChart.removeLegend(); return jFreeChart; }
From source file:org.yooreeka.util.gui.XyGui.java
public XyGui(String title, double[] x) { super(title); errMsg = new StringBuilder(); setLoopInt(x.length);/* ww w .ja va 2 s . c o m*/ if (checkX(x)) { XYSeries xydata = new XYSeries(title); for (int i = 0; i < loopInt; i++) { xydata.add(x[i], C.ZERO_DOUBLE); } xycollection = new XYSeriesCollection(xydata); final JFreeChart chart = ChartFactory.createXYLineChart(title, "X", "Y", xycollection, PlotOrientation.VERTICAL, true, true, false); final XYPlot plot = chart.getXYPlot(); final NumberAxis domainAxis = new NumberAxis("x"); plot.setDomainAxis(domainAxis); final NumberAxis rangeAxis = new NumberAxis("y"); plot.setRangeAxis(rangeAxis); chart.setBackgroundPaint(Color.white); plot.setOutlinePaint(Color.black); final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); setContentPane(chartPanel); } else { System.err.println(errMsg.toString()); } }
From source file:edu.caltechUcla.sselCassel.projects.jMarkets.shared.interfaces.PriceChart.java
public JPanel getChartPanel() { XYSeriesCollection collection = new XYSeriesCollection(); Enumeration en = lines.elements(); while (en.hasMoreElements()) { XYSeries series = (XYSeries) en.nextElement(); collection.addSeries(series);/*from w w w .j a v a2s . c om*/ } NumberAxis yAxis = new NumberAxis("Price"); NumberAxis xAxis = new NumberAxis("Time"); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); XYPlot plot = new XYPlot(collection, xAxis, yAxis, renderer); JFreeChart chart = new JFreeChart("Price Chart", new Font("Arial", 0, 12), plot, true); ChartPanel chartPanel = new ChartPanel(chart, false, false, false, false, false); return chartPanel; }