List of usage examples for org.jfree.chart.axis NumberAxis setUpperMargin
public void setUpperMargin(double margin)
From source file:org.jfree.chart.demo.ItemLabelDemo3.java
private static JFreeChart createChart(CategoryDataset categorydataset) { JFreeChart jfreechart = ChartFactory.createBarChart("Item Label Demo 3", "Category", "Value", categorydataset, PlotOrientation.VERTICAL, false, true, false); jfreechart.setBackgroundPaint(Color.white); CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot(); categoryplot.setBackgroundPaint(Color.lightGray); categoryplot.setDomainGridlinePaint(Color.white); categoryplot.setRangeGridlinePaint(Color.white); CategoryAxis categoryaxis = categoryplot.getDomainAxis(); categoryaxis.setVisible(false);/*from w w w. jav a2s. c o m*/ NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis(); numberaxis.setUpperMargin(0.14999999999999999D); CategoryItemRenderer categoryitemrenderer = categoryplot.getRenderer(); StandardCategoryItemLabelGenerator standardcategoryitemlabelgenerator = new StandardCategoryItemLabelGenerator( "{1}", NumberFormat.getInstance()); categoryitemrenderer.setBaseItemLabelGenerator(standardcategoryitemlabelgenerator); categoryitemrenderer.setBaseItemLabelFont(new Font("SansSerif", 0, 12)); categoryitemrenderer.setBaseItemLabelsVisible(true); categoryitemrenderer.setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER, TextAnchor.CENTER, -1.5707963267948966D)); return jfreechart; }
From source file:org.jfree.chart.demo.ItemLabelDemo4.java
private static JFreeChart createChart(CategoryDataset categorydataset) { JFreeChart jfreechart = ChartFactory.createLineChart("Java Standard Class Library", "Release", "Class Count", categorydataset, PlotOrientation.VERTICAL, false, true, false); jfreechart.addSubtitle(new TextTitle("Number of Classes By Release")); TextTitle texttitle = new TextTitle( "Source: Java In A Nutshell (4th Edition) by David Flanagan (O'Reilly)"); texttitle.setFont(new Font("SansSerif", 0, 10)); texttitle.setPosition(RectangleEdge.BOTTOM); texttitle.setHorizontalAlignment(HorizontalAlignment.RIGHT); jfreechart.addSubtitle(texttitle);// w w w. jav a2 s . c o m jfreechart.setBackgroundPaint(Color.white); CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot(); categoryplot.setBackgroundPaint(Color.lightGray); categoryplot.setRangeGridlinePaint(Color.white); NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis(); numberaxis.setUpperMargin(0.14999999999999999D); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); LineAndShapeRenderer lineandshaperenderer = (LineAndShapeRenderer) categoryplot.getRenderer(); lineandshaperenderer.setBaseShapesVisible(true); lineandshaperenderer.setDrawOutlines(true); lineandshaperenderer.setUseFillPaint(true); lineandshaperenderer.setBaseFillPaint(Color.white); lineandshaperenderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator()); lineandshaperenderer.setBaseItemLabelsVisible(true); return jfreechart; }
From source file:org.jfree.chart.demo.XYBlockChartDemo2.java
private static JFreeChart createChart(XYZDataset xyzdataset) { DateAxis dateaxis = new DateAxis("Date"); dateaxis.setLowerMargin(0.0D);//w w w .ja v a2 s .co m dateaxis.setUpperMargin(0.0D); dateaxis.setInverted(true); NumberAxis numberaxis = new NumberAxis("Hour"); numberaxis.setUpperMargin(0.0D); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); XYBlockRenderer xyblockrenderer = new XYBlockRenderer(); xyblockrenderer.setBlockWidth(86400000D); xyblockrenderer.setBlockAnchor(RectangleAnchor.BOTTOM_LEFT); LookupPaintScale lookuppaintscale = new LookupPaintScale(0.5D, 4.5D, Color.white); lookuppaintscale.add(0.5D, Color.red); lookuppaintscale.add(1.5D, Color.green); lookuppaintscale.add(2.5D, Color.blue); lookuppaintscale.add(3.5D, Color.yellow); xyblockrenderer.setPaintScale(lookuppaintscale); XYPlot xyplot = new XYPlot(xyzdataset, dateaxis, numberaxis, xyblockrenderer); xyplot.setOrientation(PlotOrientation.HORIZONTAL); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setRangeGridlinePaint(Color.white); xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D)); JFreeChart jfreechart = new JFreeChart("XYBlockChartDemo2", xyplot); jfreechart.removeLegend(); jfreechart.setBackgroundPaint(Color.white); SymbolAxis symbolaxis = new SymbolAxis(null, new String[] { "", "Unavailable", "Free", "Group 1", "Group 2" }); symbolaxis.setRange(0.5D, 4.5D); symbolaxis.setPlot(new PiePlot()); symbolaxis.setGridBandsVisible(false); PaintScaleLegend paintscalelegend = new PaintScaleLegend(lookuppaintscale, symbolaxis); paintscalelegend.setMargin(new RectangleInsets(3D, 10D, 3D, 10D)); paintscalelegend.setPosition(RectangleEdge.BOTTOM); paintscalelegend.setAxisOffset(5D); jfreechart.addSubtitle(paintscalelegend); return jfreechart; }
From source file:org.jfree.chart.demo.BubbleChartDemo1.java
private static JFreeChart createChart(XYZDataset xyzdataset) { JFreeChart jfreechart = ChartFactory.createBubbleChart("Bubble Chart Demo 1", "X", "Y", xyzdataset, PlotOrientation.HORIZONTAL, true, true, false); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); xyplot.setForegroundAlpha(0.65F);/*from www .j a v a 2 s. co m*/ XYItemRenderer xyitemrenderer = xyplot.getRenderer(); xyitemrenderer.setSeriesPaint(0, Color.blue); NumberAxis numberaxis = (NumberAxis) xyplot.getDomainAxis(); numberaxis.setLowerMargin(0.14999999999999999D); numberaxis.setUpperMargin(0.14999999999999999D); NumberAxis numberaxis1 = (NumberAxis) xyplot.getRangeAxis(); numberaxis1.setLowerMargin(0.14999999999999999D); numberaxis1.setUpperMargin(0.14999999999999999D); return jfreechart; }
From source file:cv.mikusher.freechart.BubbleChart.java
private static JFreeChart createChart(XYZDataset xyzdataset) { JFreeChart jfreechart = ChartFactory.createBubbleChart("AGE vs WEIGHT vs WORK", "Weight", "AGE", xyzdataset, PlotOrientation.HORIZONTAL, true, true, false); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); xyplot.setForegroundAlpha(0.65F);/*from w ww .j a v a2 s. c om*/ XYItemRenderer xyitemrenderer = xyplot.getRenderer(); xyitemrenderer.setSeriesPaint(0, Color.blue); NumberAxis numberaxis = (NumberAxis) xyplot.getDomainAxis(); numberaxis.setLowerMargin(0.2); numberaxis.setUpperMargin(0.5); NumberAxis numberaxis1 = (NumberAxis) xyplot.getRangeAxis(); numberaxis1.setLowerMargin(0.8); numberaxis1.setUpperMargin(0.9); return jfreechart; }
From source file:org.jfree.chart.demo.XYTaskDatasetDemo2.java
private static XYPlot createSubplot1(XYDataset xydataset) { XYLineAndShapeRenderer xylineandshaperenderer = new XYLineAndShapeRenderer(); xylineandshaperenderer.setUseFillPaint(true); xylineandshaperenderer.setBaseFillPaint(Color.white); xylineandshaperenderer.setBaseShape(new java.awt.geom.Ellipse2D.Double(-4D, -4D, 8D, 8D)); xylineandshaperenderer.setAutoPopulateSeriesShape(false); NumberAxis numberaxis = new NumberAxis("Y"); numberaxis.setLowerMargin(0.10000000000000001D); numberaxis.setUpperMargin(0.10000000000000001D); XYPlot xyplot = new XYPlot(xydataset, new DateAxis("Time"), numberaxis, xylineandshaperenderer); return xyplot; }
From source file:org.jfree.chart.demo.VectorPlotDemo1.java
private static JFreeChart createChart(VectorXYDataset dataset) { NumberAxis xAxis = new NumberAxis("X"); xAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); xAxis.setLowerMargin(0.01D);//from ww w . ja v a 2 s .c o m xAxis.setUpperMargin(0.01D); xAxis.setAutoRangeIncludesZero(false); NumberAxis yAxis = new NumberAxis("Y"); yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); yAxis.setLowerMargin(0.01D); yAxis.setUpperMargin(0.01D); yAxis.setAutoRangeIncludesZero(false); // VectorRenderer renderer = new VectorRenderer(); renderer.setSeriesPaint(0, Color.blue); XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D)); plot.setOutlinePaint(Color.black); JFreeChart chart = new JFreeChart("Vector Plot Demo 1", plot); chart.setBackgroundPaint(Color.white); return chart; }
From source file:org.jfree.chart.demo.VectorRendererDemo1.java
private static JFreeChart createChart(VectorXYDataset dataset) { NumberAxis xAxis = new NumberAxis("X"); xAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); xAxis.setLowerMargin(0.01D);/*w w w.ja v a 2s .c om*/ xAxis.setUpperMargin(0.01D); xAxis.setAutoRangeIncludesZero(false); NumberAxis yAxis = new NumberAxis("Y"); yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); yAxis.setLowerMargin(0.01D); yAxis.setUpperMargin(0.01D); yAxis.setAutoRangeIncludesZero(false); // VectorRenderer renderer = new VectorRenderer(); renderer.setSeriesPaint(0, Color.blue); XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D)); plot.setOutlinePaint(Color.black); JFreeChart chart = new JFreeChart("Vector Renderer Demo 1", plot); chart.setBackgroundPaint(Color.white); return chart; }
From source file:org.jfree.chart.demo.XYBlockChartDemo3.java
private static JFreeChart createChart(XYZDataset xyzdataset) { NumberAxis numberaxis = new NumberAxis("X"); numberaxis.setLowerMargin(0.0D);/*from ww w. j av a 2 s .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:org.jfree.chart.demo.AnnotationDemo1.java
private static JFreeChart createChart(XYDataset xydataset) { JFreeChart jfreechart = ChartFactory.createXYLineChart(null, "Age in Months", "Weight (kg)", xydataset, PlotOrientation.VERTICAL, true, true, false); TextTitle texttitle = new TextTitle("Growth Charts: United States", new Font("SansSerif", 1, 14)); TextTitle texttitle1 = new TextTitle("Weight-for-age percentiles: boys, birth to 36 months", new Font("SansSerif", 0, 11)); jfreechart.addSubtitle(texttitle);// w ww.j a va2 s .com jfreechart.addSubtitle(texttitle1); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); NumberAxis numberaxis = (NumberAxis) xyplot.getDomainAxis(); numberaxis.setUpperMargin(0.12D); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); NumberAxis numberaxis1 = (NumberAxis) xyplot.getRangeAxis(); numberaxis1.setAutoRangeIncludesZero(false); XYTextAnnotation xytextannotation = null; Font font = new Font("SansSerif", 0, 9); xytextannotation = new XYTextAnnotation("3rd", 36.5D, 11.76D); xytextannotation.setFont(font); xytextannotation.setTextAnchor(TextAnchor.HALF_ASCENT_LEFT); xyplot.addAnnotation(xytextannotation); xytextannotation = new XYTextAnnotation("5th", 36.5D, 12.039999999999999D); xytextannotation.setFont(font); xytextannotation.setTextAnchor(TextAnchor.HALF_ASCENT_LEFT); xyplot.addAnnotation(xytextannotation); xytextannotation = new XYTextAnnotation("10th", 36.5D, 12.493D); xytextannotation.setFont(font); xytextannotation.setTextAnchor(TextAnchor.HALF_ASCENT_LEFT); xyplot.addAnnotation(xytextannotation); xytextannotation = new XYTextAnnotation("25th", 36.5D, 13.313000000000001D); xytextannotation.setFont(font); xytextannotation.setTextAnchor(TextAnchor.HALF_ASCENT_LEFT); xyplot.addAnnotation(xytextannotation); xytextannotation = new XYTextAnnotation("50th", 36.5D, 14.33D); xytextannotation.setFont(font); xytextannotation.setTextAnchor(TextAnchor.HALF_ASCENT_LEFT); xyplot.addAnnotation(xytextannotation); xytextannotation = new XYTextAnnotation("75th", 36.5D, 15.478D); xytextannotation.setFont(font); xytextannotation.setTextAnchor(TextAnchor.HALF_ASCENT_LEFT); xyplot.addAnnotation(xytextannotation); xytextannotation = new XYTextAnnotation("90th", 36.5D, 16.641999999999999D); xytextannotation.setFont(font); xytextannotation.setTextAnchor(TextAnchor.HALF_ASCENT_LEFT); xyplot.addAnnotation(xytextannotation); xytextannotation = new XYTextAnnotation("95th", 36.5D, 17.408000000000001D); xytextannotation.setFont(font); xytextannotation.setTextAnchor(TextAnchor.HALF_ASCENT_LEFT); xyplot.addAnnotation(xytextannotation); xytextannotation = new XYTextAnnotation("97th", 36.5D, 17.936D); xytextannotation.setFont(font); xytextannotation.setTextAnchor(TextAnchor.HALF_ASCENT_LEFT); xyplot.addAnnotation(xytextannotation); return jfreechart; }