List of usage examples for org.jfree.chart.plot XYPlot setRangeGridlinePaint
public void setRangeGridlinePaint(Paint paint)
From source file:org.jfree.chart.demo.XYBarChartDemo6.java
private static JFreeChart createChart(IntervalXYDataset intervalxydataset) { JFreeChart jfreechart = ChartFactory.createXYBarChart("XYBarChartDemo6", "X", false, "Y", intervalxydataset, PlotOrientation.HORIZONTAL, false, false, false); jfreechart.setBackgroundPaint(Color.white); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); XYBarRenderer xybarrenderer = (XYBarRenderer) xyplot.getRenderer(); xybarrenderer.setUseYInterval(true); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setDomainGridlinePaint(Color.white); xyplot.setRangeGridlinePaint(Color.white); return jfreechart; }
From source file:com.compomics.pepshell.view.statistics.JFreeChartPanel.java
private static void setupPlot(XYPlot xYPlot) { // set background to white and grid color to black xYPlot.setBackgroundPaint(Color.white); xYPlot.setRangeGridlinePaint(Color.black); // hide the border of the sorrounding box xYPlot.setOutlinePaint(Color.white); // get domanin and range axes ValueAxis domainAxis = xYPlot.getDomainAxis(); ValueAxis rangeAxis = xYPlot.getRangeAxis(); // set label paint for axes to black domainAxis.setLabelPaint(Color.black); rangeAxis.setLabelPaint(Color.black); // set font for labels, both on domain and range axes domainAxis.setLabelFont(new Font("Tahoma", Font.BOLD, 12)); rangeAxis.setLabelFont(new Font("Tahoma", Font.BOLD, 12)); }
From source file:org.jfree.chart.demo.MarkerDemo2.java
private static JFreeChart createChart(XYDataset xydataset) { JFreeChart jfreechart = ChartFactory.createXYLineChart("Marker Demo 2", "X", "Temperature", xydataset, PlotOrientation.VERTICAL, false, true, false); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); xyplot.setDomainGridlinePaint(Color.lightGray); xyplot.setDomainGridlineStroke(new BasicStroke(1.0F)); xyplot.setRangeGridlinePaint(Color.lightGray); xyplot.setRangeGridlineStroke(new BasicStroke(1.0F)); xyplot.setRangeTickBandPaint(new Color(240, 240, 240)); PeriodAxis periodaxis = new PeriodAxis(null, new Hour(0, 30, 6, 2005), new Hour(23, 30, 6, 2005)); PeriodAxisLabelInfo aperiodaxislabelinfo[] = new PeriodAxisLabelInfo[2]; aperiodaxislabelinfo[0] = new PeriodAxisLabelInfo(org.jfree.data.time.Hour.class, new SimpleDateFormat("HH")); aperiodaxislabelinfo[1] = new PeriodAxisLabelInfo(org.jfree.data.time.Day.class, new SimpleDateFormat("dd-MMM")); periodaxis.setLabelInfo(aperiodaxislabelinfo); xyplot.setDomainAxis(periodaxis);/* w w w. j a v a2 s .co m*/ ValueAxis valueaxis = xyplot.getRangeAxis(); valueaxis.setRange(0.0D, 100D); XYItemRenderer xyitemrenderer = xyplot.getRenderer(); xyitemrenderer.setSeriesPaint(0, Color.green); xyitemrenderer.setSeriesStroke(0, new BasicStroke(2.0F)); ValueMarker valuemarker = new ValueMarker(80D); valuemarker.setLabelOffsetType(LengthAdjustmentType.EXPAND); valuemarker.setPaint(Color.red); valuemarker.setStroke(new BasicStroke(2.0F)); valuemarker.setLabel("Temperature Threshold"); valuemarker.setLabelFont(new Font("SansSerif", 0, 11)); valuemarker.setLabelPaint(Color.red); valuemarker.setLabelAnchor(RectangleAnchor.TOP_LEFT); valuemarker.setLabelTextAnchor(TextAnchor.BOTTOM_LEFT); xyplot.addRangeMarker(valuemarker); Hour hour = new Hour(18, 30, 6, 2005); Hour hour1 = new Hour(20, 30, 6, 2005); double d = hour.getFirstMillisecond(); double d1 = hour1.getFirstMillisecond(); IntervalMarker intervalmarker = new IntervalMarker(d, d1); intervalmarker.setLabelOffsetType(LengthAdjustmentType.EXPAND); intervalmarker.setPaint(new Color(150, 150, 255)); intervalmarker.setLabel("Automatic Cooling"); intervalmarker.setLabelFont(new Font("SansSerif", 0, 11)); intervalmarker.setLabelPaint(Color.blue); intervalmarker.setLabelAnchor(RectangleAnchor.TOP_LEFT); intervalmarker.setLabelTextAnchor(TextAnchor.TOP_RIGHT); xyplot.addDomainMarker(intervalmarker, Layer.BACKGROUND); ValueMarker valuemarker1 = new ValueMarker(d, Color.blue, new BasicStroke(2.0F)); ValueMarker valuemarker2 = new ValueMarker(d1, Color.blue, new BasicStroke(2.0F)); xyplot.addDomainMarker(valuemarker1, Layer.BACKGROUND); xyplot.addDomainMarker(valuemarker2, Layer.BACKGROUND); 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);//from ww w. j a va 2 s. c o 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:cit.workflow.engine.manager.test.SWTTimeSeriesDemo.java
/** * Creates a chart.//from w ww.j ava2 s. co m * * @param dataset a dataset. * * @return A chart. */ private static JFreeChart createChart(XYDataset dataset) { JFreeChart chart = ChartFactory.createTimeSeriesChart("Legal & General Unit Trust Prices", // title "Date", // x-axis label "Price Per Unit", // y-axis label dataset, // data true, // create legend? true, // generate tooltips? false // generate URLs? ); chart.setBackgroundPaint(Color.white); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); XYItemRenderer r = plot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); } DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy")); return chart; }
From source file:io.sanfran.wikiTrends.extraction.plots.PlotTimeSeries.java
private static JFreeChart createChart(XYDataset dataset, String title) { JFreeChart chart = ChartFactory.createTimeSeriesChart(title, // title "Date", // x-axis label "Page visits", // y-axis label dataset, // data true, // create legend? true, // generate tooltips? false // generate URLs? );//from w w w . jav a2s . co m chart.setBackgroundPaint(Color.white); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); XYItemRenderer r = plot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(false); // if you want visible dots -> true renderer.setBaseShapesFilled(false); // if you want visible dots -> true if (seriesWidth != null) { for (int i = 0; i < seriesWidth.size(); i++) { renderer.setSeriesStroke(i, new BasicStroke(seriesWidth.get(i))); } } if (seriesColor != null) { for (int i = 0; i < seriesColor.size(); i++) { renderer.setSeriesPaint(i, seriesColor.get(i)); } } } DateAxis axis = (DateAxis) plot.getDomainAxis(); //axis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy")); axis.setDateFormatOverride(new SimpleDateFormat("dd-MM-yyyy")); return chart; }
From source file:org.csml.tommo.sugar.heatmap.MappingQualityMatrixChart.java
private static MappingQualityMatrixChart createChart(MappingQualityMatrixDataset dataset, NumberAxis xAxis, NumberAxis yAxis, PaintScale paintScale) { XYBlockRenderer renderer = new XYBlockRenderer(); renderer.setPaintScale(paintScale);/*from w w w . j ava 2s. com*/ XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinesVisible(false); plot.setRangeGridlinePaint(Color.white); MappingQualityMatrixChart chart = new MappingQualityMatrixChart(plot); chart.setBackgroundPaint(Color.white); chart.removeLegend(); return chart; }
From source file:org.jfree.chart.demo.PlotOrientationDemo1.java
private static JFreeChart createChart(int i, XYDataset xydataset) { JFreeChart jfreechart = ChartFactory.createXYLineChart("Chart " + (i + 1), "X", "Y", xydataset, PlotOrientation.VERTICAL, false, false, false); jfreechart.setBackgroundPaint(Color.white); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D)); xyplot.setDomainGridlinePaint(Color.white); xyplot.setRangeGridlinePaint(Color.white); XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyplot.getRenderer(); xylineandshaperenderer.setBaseShapesVisible(true); xylineandshaperenderer.setBaseShapesFilled(true); ValueAxis valueaxis = xyplot.getDomainAxis(); valueaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); ValueAxis valueaxis1 = xyplot.getRangeAxis(); valueaxis1.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); return jfreechart; }
From source file:org.csml.tommo.sugar.heatmap.MeanQualityMatrixChart.java
private static MeanQualityMatrixChart createChart(MeanQualityMatrixDataset dataset, NumberAxis xAxis, NumberAxis yAxis, PaintScale paintScale) { XYBlockRenderer renderer = new XYBlockRenderer(); renderer.setPaintScale(paintScale);// w w w . j a va 2 s . c om XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinesVisible(false); plot.setRangeGridlinePaint(Color.white); MeanQualityMatrixChart chart = new MeanQualityMatrixChart(plot); chart.setBackgroundPaint(Color.white); chart.removeLegend(); return chart; }
From source file:eu.kprod.gui.chart.MwChartFactory.java
public static MwChartPanel createChart(MwConfiguration conf, final XYDataset xyDataset) { final JFreeChart chart; chart = ChartFactory.createTimeSeriesChart(null, null, null, xyDataset, false, true, true); chart.setBackgroundPaint(conf.color.getColor(MwColor.BACKGROUND_COLOR)); chart.setBorderVisible(false);/*w ww . j a v a 2s . com*/ final XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(conf.color.getColor(MwColor.BACKGROUND_COLOR)); plot.setDomainGridlinePaint(conf.color.getColor(MwColor.FORGROUND_COLOR)); plot.setRangeGridlinePaint(conf.color.getColor(MwColor.FORGROUND_COLOR)); plot.setDomainGridlinesVisible(false); plot.setDomainCrosshairPaint(conf.color.getColor(MwColor.FORGROUND_COLOR)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); final DateAxis axis = (DateAxis) plot.getDomainAxis(); // axis.setDateFormatOverride(new SimpleDateFormat("mm''ss''''SSS")); axis.setAxisLineVisible(false); axis.setTickLabelsVisible(false); axis.setTickLabelPaint(conf.color.getColor(MwColor.FORGROUND_COLOR)); // force integer display final ValueAxis va = plot.getRangeAxis(); va.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); va.setLabelPaint(conf.color.getColor(MwColor.FORGROUND_COLOR)); va.setAxisLinePaint(conf.color.getColor(MwColor.FORGROUND_COLOR)); va.setTickLabelPaint(conf.color.getColor(MwColor.FORGROUND_COLOR)); // va.setRange(-280,280); // va.setFixedAutoRange(560); // va.setLowerBound(-280); // va.setUpperBound(280); // va.setAutoRange(false); va.setRangeWithMargins(-280, 280); final MwChartPanel chartPanel = new MwChartPanel(chart, conf); chartPanel.setMouseWheelEnabled(false); chartPanel.setDomainZoomable(false); chartPanel.setRangeZoomable(false); return chartPanel; }