List of usage examples for org.jfree.chart.axis NumberAxis setVerticalTickLabels
public void setVerticalTickLabels(boolean flag)
From source file:classpackage.ChartGalaxy.java
private static JFreeChart createChart(final XYDataset dataset) { JFreeChart jfreechart = ChartFactory.createScatterPlot("MDS Galaxy", "X", "Y", createDataset(), PlotOrientation.VERTICAL, true, true, false); XYPlot xyPlot = (XYPlot) jfreechart.getPlot(); XYItemRenderer renderer = xyPlot.getRenderer(); renderer.setBaseItemLabelGenerator(new LabelGenerator()); renderer.setBaseItemLabelPaint(Color.WHITE);//label renderer.setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER)); renderer.setBaseItemLabelFont(renderer.getBaseItemLabelFont().deriveFont(15f)); renderer.setBaseItemLabelsVisible(true); renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); //set false para linhas no grafico xyPlot.setDomainGridlinesVisible(false); xyPlot.setRangeGridlinesVisible(false); xyPlot.setRangeMinorGridlinesVisible(false); xyPlot.setRangeCrosshairVisible(false); xyPlot.setRangeCrosshairLockedOnData(false); xyPlot.setRangeZeroBaselineVisible(false); xyPlot.setBackgroundPaint(Color.BLACK); double size = 40.0; double delta = size / 2.0; Shape shape = new Rectangle2D.Double(-delta, -delta, size, size); renderer.setSeriesShape(0, shape);//from w w w .j a v a2s . c o m renderer.setSeriesPaint(0, transparent); NumberAxis domain = (NumberAxis) xyPlot.getDomainAxis(); domain.setRange(-0.1, 0.1); domain.setTickUnit(new NumberTickUnit(0.1)); domain.setVerticalTickLabels(true); NumberAxis range = (NumberAxis) xyPlot.getRangeAxis(); range.setRange(-0.1, 0.1); range.setTickUnit(new NumberTickUnit(0.1)); return jfreechart; }
From source file:org.spf4j.perf.impl.chart.Charts.java
public static JFreeChart createHeatJFreeChart(final String[] dsNames, final double[][] values, final long startTimeMillis, final long stepMillis, final String uom, final String chartName) { final QuantizedXYZDatasetImpl dataSet = new QuantizedXYZDatasetImpl(dsNames, values, startTimeMillis, stepMillis);//from w w w . j a v a 2s.c om NumberAxis xAxis = new NumberAxis("Time"); xAxis.setStandardTickUnits(dataSet.createXTickUnits()); xAxis.setLowerMargin(0); xAxis.setUpperMargin(0); xAxis.setVerticalTickLabels(true); NumberAxis yAxis = new NumberAxis(uom); yAxis.setStandardTickUnits(dataSet.createYTickUnits()); yAxis.setLowerMargin(0); yAxis.setUpperMargin(0); XYBlockRenderer renderer = new XYBlockRenderer(); PaintScale scale; if (dataSet.getMinValue() >= dataSet.getMaxValue()) { if (dataSet.getMinValue() == Double.POSITIVE_INFINITY) { scale = new InverseGrayScale(0, 1); } else { scale = new InverseGrayScale(dataSet.getMinValue(), dataSet.getMaxValue() + 1); } } else { scale = new InverseGrayScale(dataSet.getMinValue(), dataSet.getMaxValue()); } renderer.setPaintScale(scale); renderer.setBlockWidth(1); renderer.setBlockHeight(1); XYPlot plot = new XYPlot(dataSet, xAxis, yAxis, renderer); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinesVisible(false); plot.setRangeGridlinesVisible(false); plot.setRangeMinorGridlinesVisible(false); JFreeChart chart = new JFreeChart(chartName, plot); PaintScaleLegend legend = new PaintScaleLegend(scale, new NumberAxis("Count")); legend.setMargin(0, 5, 0, 5); chart.addSubtitle(legend); chart.removeLegend(); chart.setBackgroundPaint(Color.white); return chart; }
From source file:eu.cassandra.training.utils.ChartUtils.java
/** * This function is used for the visualization of two Area Diagrams. * /* w w w.jav a 2s .co m*/ * @param title * The title of the chart. * @param x * The unit on the X axis of the chart. * @param y * The unit on the Y axis of the chart. * @param doubles * The array of values of the first array. * * @return a chart panel with the graphical representation. */ public static ChartPanel createExpectedPowerChart(String title, String x, String y, double[] data) { JFreeChart chart = null; XYSeries series1 = new XYSeries("Expected Power"); for (int i = 0; i < data.length; i++) { series1.add(i, data[i]); } XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(series1); PlotOrientation orientation = PlotOrientation.VERTICAL; boolean show = false; boolean toolTips = false; boolean urls = false; chart = ChartFactory.createXYLineChart(title, x, y, dataset, orientation, show, toolTips, 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); NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setVerticalTickLabels(true); domainAxis.setRange(0.0, 1440.0); domainAxis.setTickUnit(new NumberTickUnit(100)); return new ChartPanel(chart); }
From source file:au.edu.jcu.usb.USBPlotFrame.java
/** * Constructs the ChartPanel from the provided XYSeriesCollection * * @param xySeriesCollection//from www. ja va2 s . co m * @return The constructed ChartPanel containing the XY scatter plot */ private ChartPanel constructChart(XYSeriesCollection xySeriesCollection) { // Construct the scatter plot from the provided xySeriesCollection JFreeChart chart = ChartFactory.createScatterPlot("Title", "X Axis", "Y Axis", xySeriesCollection); // Get the XY Plot from the scatter chart XYPlot xyPlot = (XYPlot) chart.getPlot(); xyPlot.setDomainCrosshairVisible(true); xyPlot.setRangeCrosshairVisible(true); // Create the renderer XYItemRenderer renderer = xyPlot.getRenderer(); renderer.setSeriesPaint(0, Color.blue); NumberAxis domain = (NumberAxis) xyPlot.getDomainAxis(); domain.setVerticalTickLabels(true); ChartPanel chartPanel = new ChartPanel(chart); return chartPanel; }
From source file:cgpanalyser.gui.chart.ChartCreator.java
private void setBothAxisProperties(XYPlot plot, XYDataset dataset) { NumberAxis xAxis = (NumberAxis) plot.getDomainAxis(); //set x axis tick xAxis.setVerticalTickLabels(true); //set x axis text rotation //xAxis.setTickUnit(new NumberTickUnit(100)); //xAxis.setLowerBound(1); //xAxis.setUpperBound(1000); NumberAxis yAxis = (NumberAxis) plot.getRangeAxis(); //yAxis.setTickUnit(new NumberTickUnit(100)); }
From source file:physical_network.OscilloscopePanel.java
public OscilloscopePanel() { super("Oscilloscope"); // Set initial (time, voltage) datapoint of (0.0, 0.0). voltages.add(0.0, 0.0);/*from ww w . jav a2 s. c o m*/ XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(voltages); JFreeChart chart = ChartFactory.createXYLineChart("Oscilloscope", "Time (seconds)", "Voltage", dataset, PlotOrientation.VERTICAL, true, false, false); XYPlot plot = (XYPlot) chart.getPlot(); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesLinesVisible(0, true); NumberAxis domain = (NumberAxis) plot.getDomainAxis(); domain.setRange(0.0, 10.0); domain.setTickUnit(new NumberTickUnit(1.0)); domain.setVerticalTickLabels(true); NumberAxis range = (NumberAxis) plot.getRangeAxis(); range.setRange(-5.0, 5.0); range.setTickUnit(new NumberTickUnit(1.0)); plot.setRenderer(renderer); ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(500, 300)); setContentPane(chartPanel); }
From source file:org.ow2.clif.jenkins.chart.FixedSliceNumberDistributionChart.java
@Override protected JFreeChart createChart() { JFreeChart chart = ChartFactory.createHistogram(getBasicTitle(), Messages.FixedSliceNumberDistributionChart_ResponseTime(), Messages.FixedSliceNumberDistributionChart_NumberOfCalls(), data, PlotOrientation.VERTICAL, true, true, false);//from w w w. ja va 2s .c om if (data.getSeriesCount() != 0) { double rangeStart = data.getStartX(0, 0).doubleValue(); double rangeEnd = data.getEndX(0, data.getItemCount(0) - 1).doubleValue(); NumberAxis domainAxis = new HistogramAxis(data, 0); domainAxis.setAutoRangeIncludesZero(false); domainAxis.setVerticalTickLabels(true); domainAxis.setTickLabelsVisible(true); domainAxis.setTickMarksVisible(true); domainAxis.setRange(rangeStart, rangeEnd); chart.getXYPlot().setDomainAxis(domainAxis); NumberAxis rangeAxis = (NumberAxis) chart.getXYPlot().getRangeAxis(); rangeAxis.setAutoRangeIncludesZero(true); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); } chart.getXYPlot().setRangeGridlinesVisible(true); chart.getXYPlot().setDomainGridlinesVisible(false); return chart; }
From source file:daylightchart.sunchart.chart.SunChart.java
private void createAzimuthAxis(final XYPlot plot) { final NumberAxis axis = new NumberAxis(); axis.setTickLabelFont(ChartConfiguration.chartFont.deriveFont(Font.PLAIN, 12)); axis.setVerticalTickLabels(true); ///*from w ww . j a va 2 s . co m*/ plot.setDomainAxis(axis); }
From source file:org.ow2.clif.jenkins.chart.FixedSliceSizeDistributionChart.java
@Override protected JFreeChart createChart() { JFreeChart chart = ChartFactory.createHistogram(getBasicTitle(), Messages.FixedSliceSizeDistributionChart_ResponseTime(), Messages.FixedSliceSizeDistributionChart_NumberOfCalls(), data, PlotOrientation.VERTICAL, true, true, false);// www . java 2 s . c om if (data.getSeriesCount() != 0 && data.getItemCount(0) > 0) { double rangeStart = data.getStartX(0, 0).doubleValue(); double rangeEnd = data.getEndX(0, data.getItemCount(0) - 1).doubleValue(); NumberAxis domainAxis = new HistogramAxis(data, 0); domainAxis.setAutoRangeIncludesZero(false); domainAxis.setVerticalTickLabels(true); domainAxis.setTickLabelsVisible(true); domainAxis.setTickMarksVisible(true); domainAxis.setRange(rangeStart, rangeEnd); chart.getXYPlot().setDomainAxis(domainAxis); NumberAxis rangeAxis = (NumberAxis) chart.getXYPlot().getRangeAxis(); rangeAxis.setAutoRangeIncludesZero(true); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); } chart.getXYPlot().setRangeGridlinesVisible(true); chart.getXYPlot().setDomainGridlinesVisible(false); return chart; }
From source file:c.depthchart.ViewerPanel.java
private void initChart() // create the dataset, chart, panel, and window { // create an empty data set series = new XYSeries("Depth Counts Histogram"); for (int i = 0; i <= CHART_MAX_DEPTH; i++) series.add(i, 0); // depth with a zero count XYSeriesCollection dataset = new XYSeriesCollection(series); // put the data into a chart JFreeChart chart = ChartFactory.createXYBarChart("Depth Histogram", "Depth (mm)", false, "Depth Count", dataset, PlotOrientation.VERTICAL, false, true, false); // legend, tooltips, urls // modify the chart axes XYPlot plot = (XYPlot) chart.getPlot(); NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); // x-axis domainAxis.setVerticalTickLabels(true); domainAxis.setRange(0, CHART_MAX_DEPTH); domainAxis.setTickUnit(new NumberTickUnit(100)); ValueAxis rangeAxis = plot.getRangeAxis(); // y-axis rangeAxis.setRange(0, 15000); // a bit of a guess // add the chart to a panel ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new Dimension(1000, 500)); // add the panel to a window JFrame chartFrame = new JFrame("Depth Histogram"); chartFrame.setContentPane(chartPanel); chartFrame.pack();/*from w ww . java2 s . c o m*/ chartFrame.setVisible(true); }