List of usage examples for org.jfree.chart.axis NumberAxis setAutoRangeIncludesZero
public void setAutoRangeIncludesZero(boolean flag)
From source file:org.jfree.chart.demo.MultipleAxisDemo4.java
private static JFreeChart createChart() { XYDataset xydataset = createDataset("March 2007", 100D, new Day(1, 3, 2007), 31); JFreeChart jfreechart = ChartFactory.createTimeSeriesChart("Multiple Axis Demo 4", "Date", "Value", xydataset, true, true, false); jfreechart.setBackgroundPaint(Color.white); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); xyplot.setOrientation(PlotOrientation.VERTICAL); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setDomainGridlinePaint(Color.white); xyplot.setRangeGridlinePaint(Color.white); xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D)); DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis(); dateaxis.setDateFormatOverride(new SimpleDateFormat("d-MMM-yyyy")); XYItemRenderer xyitemrenderer = xyplot.getRenderer(); xyitemrenderer.setSeriesPaint(0, Color.red); NumberAxis numberaxis = (NumberAxis) xyplot.getRangeAxis(); numberaxis.setTickLabelPaint(Color.red); DateAxis dateaxis1 = new DateAxis("Date"); dateaxis1.setDateFormatOverride(new SimpleDateFormat("d-MMM-yyyy")); xyplot.setDomainAxis(1, dateaxis1);// w ww. j av a 2 s . co m xyplot.setDomainAxisLocation(1, AxisLocation.TOP_OR_LEFT); NumberAxis numberaxis1 = new NumberAxis("Value"); numberaxis1.setAutoRangeIncludesZero(false); numberaxis1.setTickLabelPaint(Color.blue); xyplot.setRangeAxis(1, numberaxis1); xyplot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_RIGHT); XYDataset xydataset1 = createDataset("July 2007", 1000D, new Day(1, 7, 2007), 31); xyplot.setDataset(1, xydataset1); xyplot.mapDatasetToDomainAxis(1, 1); xyplot.mapDatasetToRangeAxis(1, 1); XYLineAndShapeRenderer xylineandshaperenderer = new XYLineAndShapeRenderer(true, false); xylineandshaperenderer.setSeriesPaint(0, Color.blue); xyplot.setRenderer(1, xylineandshaperenderer); return jfreechart; }
From source file:org.jfree.chart.demo.HighLowChartDemo3.java
private static JFreeChart createChart(OHLCDataset ohlcdataset) { JFreeChart jfreechart = ChartFactory.createHighLowChart("OHLC Demo 3", "Time", "Price", ohlcdataset, true); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); HighLowRenderer highlowrenderer = (HighLowRenderer) xyplot.getRenderer(); highlowrenderer.setBaseStroke(new BasicStroke(2.0F)); highlowrenderer.setSeriesPaint(0, Color.blue); DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis(); dateaxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); NumberAxis numberaxis = (NumberAxis) xyplot.getRangeAxis(); numberaxis.setAutoRangeIncludesZero(false); NumberAxis numberaxis1 = new NumberAxis("Price 2"); numberaxis1.setAutoRangeIncludesZero(false); xyplot.setRangeAxis(1, numberaxis1); xyplot.setDataset(1, createDataset2()); xyplot.setRenderer(1, new CandlestickRenderer(10D)); xyplot.mapDatasetToRangeAxis(1, 1);// w ww.j a va 2 s . co m ChartUtilities.applyCurrentTheme(jfreechart); return jfreechart; }
From source file:com.itemanalysis.jmetrik.graph.histogram.HistogramChart.java
public static JFreeChart createHistogram(String title, String xAxisLabel, String yAxisLabel, IntervalXYDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls) { if (orientation == null) { throw new IllegalArgumentException("Null 'orientation' argument."); }//from w w w . j av a2 s .c o m NumberAxis xAxis = new NumberAxis(xAxisLabel); xAxis.setAutoRangeIncludesZero(false); ValueAxis yAxis = new NumberAxis(yAxisLabel); XYItemRenderer renderer = new XYBarRenderer(); if (tooltips) { renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); } if (urls) { renderer.setURLGenerator(new StandardXYURLGenerator()); } XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); plot.setOrientation(orientation); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); currentTheme.apply(chart); return chart; }
From source file:org.jfree.chart.demo.CompassFormatDemo1.java
private static JFreeChart createChart() { XYDataset xydataset = createDirectionDataset(600); JFreeChart jfreechart = ChartFactory.createTimeSeriesChart("Time", "Date", "Direction", xydataset, true, true, false);/*w w w. j av a2 s . c om*/ XYPlot xyplot = (XYPlot) jfreechart.getPlot(); xyplot.getDomainAxis().setLowerMargin(0.0D); xyplot.getDomainAxis().setUpperMargin(0.0D); NumberAxis numberaxis = (NumberAxis) xyplot.getRangeAxis(); numberaxis.setAutoRangeIncludesZero(false); TickUnits tickunits = new TickUnits(); tickunits.add(new NumberTickUnit(180D, new CompassFormat())); tickunits.add(new NumberTickUnit(90D, new CompassFormat())); tickunits.add(new NumberTickUnit(45D, new CompassFormat())); tickunits.add(new NumberTickUnit(22.5D, new CompassFormat())); numberaxis.setStandardTickUnits(tickunits); xyplot.setRangeAxis(numberaxis); XYAreaRenderer xyarearenderer = new XYAreaRenderer(); NumberAxis numberaxis1 = new NumberAxis("Force"); numberaxis1.setRange(0.0D, 12D); xyarearenderer.setSeriesPaint(0, new Color(0, 0, 255, 128)); xyplot.setDataset(1, createForceDataset(600)); xyplot.setRenderer(1, xyarearenderer); xyplot.setRangeAxis(1, numberaxis1); xyplot.mapDatasetToRangeAxis(1, 1); return jfreechart; }
From source file:org.jfree.chart.demo.XYBlockChartDemo3.java
private static JFreeChart createChart(XYZDataset xyzdataset) { NumberAxis numberaxis = new NumberAxis("X"); numberaxis.setLowerMargin(0.0D);/* www . j av a2s . co m*/ numberaxis.setUpperMargin(0.0D); NumberAxis numberaxis1 = new NumberAxis("Y"); numberaxis1.setAutoRangeIncludesZero(false); numberaxis1.setInverted(true); numberaxis1.setLowerMargin(0.0D); numberaxis1.setUpperMargin(0.0D); numberaxis1.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); XYBlockRenderer xyblockrenderer = new XYBlockRenderer(); LookupPaintScale lookuppaintscale = new LookupPaintScale(0.5D, 3.5D, Color.black); lookuppaintscale.add(0.5D, Color.green); lookuppaintscale.add(1.5D, Color.orange); lookuppaintscale.add(2.5D, Color.red); xyblockrenderer.setPaintScale(lookuppaintscale); XYPlot xyplot = new XYPlot(xyzdataset, numberaxis, numberaxis1, xyblockrenderer); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setDomainGridlinePaint(Color.white); xyplot.setRangeGridlinePaint(Color.white); xyplot.setForegroundAlpha(0.66F); xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D)); JFreeChart jfreechart = new JFreeChart("XYBlockChartDemo3", xyplot); jfreechart.removeLegend(); jfreechart.setBackgroundPaint(Color.white); SymbolAxis symbolaxis = new SymbolAxis(null, new String[] { "", "OK", "Uncertain", "Bad" }); symbolaxis.setRange(0.5D, 3.5D); symbolaxis.setPlot(new PiePlot()); symbolaxis.setGridBandsVisible(false); PaintScaleLegend paintscalelegend = new PaintScaleLegend(lookuppaintscale, symbolaxis); paintscalelegend.setAxisOffset(5D); paintscalelegend.setPosition(RectangleEdge.BOTTOM); paintscalelegend.setMargin(new RectangleInsets(5D, 5D, 5D, 5D)); jfreechart.addSubtitle(paintscalelegend); return jfreechart; }
From source file:es.bsc.autonomic.powermodeller.graphics.TotalPowerVsTotalPrediction.java
public static JPanel createPanel() { //Axis configuration NumberAxis sampleAxis = new NumberAxis("Sample"); sampleAxis.setAutoRangeIncludesZero(false); NumberAxis powerAxis = new NumberAxis("Power (Watts)"); powerAxis.setAutoRangeIncludesZero(false); XYSplineRenderer xysplinerenderer = new XYSplineRenderer(); XYPlot xyplot = new XYPlot(data, sampleAxis, powerAxis, xysplinerenderer); for (int i = 0; i < data.getSeriesCount(); i++) { xyplot.getRenderer().setSeriesShape(i, new Rectangle()); }//from ww w . j av a 2 s. c o m //Panel layout configuration xyplot.setBackgroundPaint(Color.lightGray); xyplot.setDomainGridlinePaint(Color.white); xyplot.setRangeGridlinePaint(Color.white); xyplot.setAxisOffset(new RectangleInsets(4D, 4D, 4D, 4D)); JFreeChart jfreechart = new JFreeChart(NAME, JFreeChart.DEFAULT_TITLE_FONT, xyplot, true); ChartUtilities.applyCurrentTheme(jfreechart); ChartPanel chartpanel = new ChartPanel(jfreechart); return chartpanel; }
From source file:jamel.gui.charts.Histogram.java
/** * Returns a new plot./*from w w w. j a v a 2 s .com*/ * @param dataset the dataset. * @param hAxisLabel the label for the x axis. * @param vAxisLabel the label for the y axis. * @param color the color of the chart. * @return the new plot. */ static private Plot newPlot(HistogramDataset dataset, String hAxisLabel, String vAxisLabel, Color color) { NumberAxis xAxis = new NumberAxis(hAxisLabel); xAxis.setAutoRangeIncludesZero(false); ValueAxis yAxis = new NumberAxis(vAxisLabel); XYBarRenderer renderer = new XYBarRenderer(); renderer.setBarPainter(new StandardXYBarPainter()); renderer.setShadowVisible(false); renderer.setMargin(0.05); renderer.setSeriesPaint(0, color); XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); plot.setOrientation(PlotOrientation.VERTICAL); plot.setDomainZeroBaselineVisible(true); plot.setRangeZeroBaselineVisible(true); return plot; }
From source file:ta4jexamples.analysis.CashFlowToChart.java
/** * Adds the cash flow axis to the plot./*from w w w.j a va2 s. com*/ * @param plot the plot * @param dataset the cash flow dataset */ private static void addCashFlowAxis(XYPlot plot, TimeSeriesCollection dataset) { final NumberAxis cashAxis = new NumberAxis("Cash Flow Ratio"); cashAxis.setAutoRangeIncludesZero(false); plot.setRangeAxis(1, cashAxis); plot.setDataset(1, dataset); plot.mapDatasetToRangeAxis(1, 1); final StandardXYItemRenderer cashFlowRenderer = new StandardXYItemRenderer(); cashFlowRenderer.setSeriesPaint(0, Color.blue); plot.setRenderer(1, cashFlowRenderer); }
From source file:edu.msu.cme.rdp.classifier.train.validation.distance.BoxPlotUtils.java
public static void createBoxplot(DefaultBoxAndWhiskerCategoryDataset scatterDataset, PrintStream outStream, String title, String xAxisLabel, String yAxisLabel, Font lableFont) throws IOException { CategoryAxis xAxis = new CategoryAxis(xAxisLabel); xAxis.setLabelFont(lableFont);//from w w w.java2 s .c om NumberAxis yAxis = new NumberAxis(yAxisLabel); yAxis.setTickLabelFont(lableFont); yAxis.setAutoRangeIncludesZero(false); yAxis.setRange(0, 100); yAxis.setLabelFont(lableFont); BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer(); renderer.setFillBox(true); renderer.setBaseLegendTextFont(lableFont); renderer.setStroke(new BasicStroke(5.0f)); CategoryPlot plot = new CategoryPlot(scatterDataset, xAxis, yAxis, renderer); JFreeChart boxchart = new JFreeChart(title, new Font("Helvetica", Font.BOLD, 40), plot, true); // higher scale factor gives higher resolution ChartUtilities.writeScaledChartAsPNG(outStream, boxchart, 800, 1000, 3, 3); }
From source file:org.jfree.chart.demo.StatisticalLineChartDemo1.java
private static JFreeChart createChart(CategoryDataset categorydataset) { JFreeChart jfreechart = ChartFactory.createLineChart("Statistical Line Chart Demo 1", "Type", "Value", categorydataset, PlotOrientation.VERTICAL, true, true, false); jfreechart.setBackgroundPaint(Color.white); CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot(); categoryplot.setBackgroundPaint(Color.lightGray); categoryplot.setRangeGridlinePaint(Color.white); CategoryAxis categoryaxis = categoryplot.getDomainAxis(); categoryaxis.setUpperMargin(0.0D);/* w w w.java 2 s . com*/ categoryaxis.setLowerMargin(0.0D); NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis(); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); numberaxis.setAutoRangeIncludesZero(true); StatisticalLineAndShapeRenderer statisticallineandshaperenderer = new StatisticalLineAndShapeRenderer(true, false); categoryplot.setRenderer(statisticallineandshaperenderer); return jfreechart; }