Example usage for org.jfree.chart.plot XYPlot getRangeAxis

List of usage examples for org.jfree.chart.plot XYPlot getRangeAxis

Introduction

In this page you can find the example usage for org.jfree.chart.plot XYPlot getRangeAxis.

Prototype

public ValueAxis getRangeAxis() 

Source Link

Document

Returns the range axis for the plot.

Usage

From source file:org.jfree.chart.demo.SecondDemo.java

public static void main(String args[]) {
    XYSeries xyseries = new XYSeries("Advisory Range");
    xyseries.add(new Integer(1200), new Integer(1));
    xyseries.add(new Integer(1500), new Integer(1));
    XYSeries xyseries1 = new XYSeries("Normal Range");
    xyseries1.add(new Integer(2000), new Integer(4));
    xyseries1.add(new Integer(2300), new Integer(4));
    XYSeries xyseries2 = new XYSeries("Recommended");
    xyseries2.add(new Integer(2100), new Integer(2));
    XYSeries xyseries3 = new XYSeries("Current");
    xyseries3.add(new Integer(2400), new Integer(3));
    XYSeriesCollection xyseriescollection = new XYSeriesCollection();
    xyseriescollection.addSeries(xyseries);
    xyseriescollection.addSeries(xyseries1);
    xyseriescollection.addSeries(xyseries2);
    xyseriescollection.addSeries(xyseries3);
    JFreeChart jfreechart = ChartFactory.createXYLineChart("My Chart", "Calories", "Y", xyseriescollection,
            PlotOrientation.VERTICAL, true, true, false);
    StandardXYItemRenderer standardxyitemrenderer = new StandardXYItemRenderer(3, null);
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    xyplot.setRenderer(standardxyitemrenderer);
    ValueAxis valueaxis = xyplot.getRangeAxis();
    valueaxis.setTickLabelsVisible(false);
    valueaxis.setRange(0.0D, 5D);//from  w  w w .j  a v a 2 s.  c  om
    ChartFrame chartframe = new ChartFrame("Test", jfreechart);
    chartframe.pack();
    chartframe.setVisible(true);
}

From source file:org.jfree.chart.demo.Second.java

/**
 * Starting point for the demo./*w w  w .  java2  s.co  m*/
 *
 * @param args  ignored.
 */
public static void main(final String[] args) {

    // create some data...
    final XYSeries series1 = new XYSeries("Advisory Range");
    series1.add(new Integer(1200), new Integer(1));
    series1.add(new Integer(1500), new Integer(1));

    final XYSeries series2 = new XYSeries("Normal Range");
    series2.add(new Integer(2000), new Integer(4));
    series2.add(new Integer(2300), new Integer(4));

    final XYSeries series3 = new XYSeries("Recommended");
    series3.add(new Integer(2100), new Integer(2));

    final XYSeries series4 = new XYSeries("Current");
    series4.add(new Integer(2400), new Integer(3));

    final XYSeriesCollection data = new XYSeriesCollection();
    data.addSeries(series1);
    data.addSeries(series2);
    data.addSeries(series3);
    data.addSeries(series4);

    // create a chart...
    final JFreeChart chart = ChartFactory.createXYLineChart("My Chart", "Calories", "Y", data,
            PlotOrientation.VERTICAL, true, true, false);

    // ****************************************************************************
    // * JFREECHART DEVELOPER GUIDE                                               *
    // * The JFreeChart Developer Guide, written by David Gilbert, is available   *
    // * to purchase from Object Refinery Limited:                                *
    // *                                                                          *
    // * http://www.object-refinery.com/jfreechart/guide.html                     *
    // *                                                                          *
    // * Sales are used to provide funding for the JFreeChart project - please    * 
    // * support us so that we can continue developing free software.             *
    // ****************************************************************************

    final XYItemRenderer renderer = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES_AND_LINES, null);
    final XYPlot plot = (XYPlot) chart.getPlot();
    plot.setRenderer(renderer);
    final ValueAxis axis = plot.getRangeAxis();
    axis.setTickLabelsVisible(false);
    axis.setRange(0.0, 5.0);

    // create and display a frame...
    final ChartFrame frame = new ChartFrame("Test", chart);
    frame.pack();
    frame.setVisible(true);

}

From source file:org.jfree.chart.demo.SparklineDemo1.java

public static void main(String args[]) {
    XYSeries xyseries = new XYSeries("Series 1");
    xyseries.add(1.0D, 1.0D);/*www.  ja  v  a 2  s.  c o  m*/
    xyseries.add(2D, 3D);
    xyseries.add(3D, 2D);
    xyseries.add(4D, 4D);
    XYSeriesCollection xyseriescollection = new XYSeriesCollection();
    xyseriescollection.addSeries(xyseries);
    JFreeChart jfreechart = ChartFactory.createXYLineChart(null, "X", "Y", xyseriescollection,
            PlotOrientation.VERTICAL, false, false, false);
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    xyplot.setInsets(RectangleInsets.ZERO_INSETS);
    xyplot.setDomainGridlinesVisible(false);
    xyplot.setRangeGridlinesVisible(false);
    xyplot.setOutlinePaint(null);
    xyplot.getDomainAxis().setVisible(false);
    xyplot.getRangeAxis().setVisible(false);
    try {
        ChartUtilities.saveChartAsPNG(new File("Sparky.png"), jfreechart, 100, 20);
    } catch (IOException ioexception) {
        ioexception.printStackTrace();
    }
}

From source file:pl.dpbz.poid.zadanie3.Main.java

public static void main(String args[]) throws UnsupportedAudioFileException, IOException {
    //Zassanie pliku
    File f = new File("ExampleSounds/artificial/easy/100Hz.wav");
    Integer[] ints = WaveToSamplesConverter.convertWaveToIntSamples(f);
    double samplingFrequency = WaveToSamplesConverter.getSamplingFrequency(f);

    //Zwyky sound, ktry nie potrzebuje zespolonych elementw
    Sound s = new Sound(ints, samplingFrequency);

    //Obliczenie czstotliwoci przy pomocy fazwki
    PhaseSpaceMultiDimensional pS = new PhaseSpaceMultiDimensional(s);
    pS.setupPhaseSpace();/*from  w  ww .  j  a  v a  2  s .c o  m*/
    pS.computeFrequency();
    System.out.println("Phase space " + pS.getFrequency());

    //Zespolony dwik, ktry jest bardziej zoony
    ComplexSound cs = new ComplexSound(ints, samplingFrequency, 15);
    //To oblicza fouriera
    cs.setupElementsOfComplexSound();
    //Tutaj obliczanie czstotliwoci przy pomocy fouriera
    CombFiltering cf = new CombFiltering(cs, samplingFrequency);
    cf.computeFrequency();
    cf.drawComplexSound();
    System.out.println("Comb Filtering " + cf.getFrequency());

    //Przy sekwencjach nie ma majstrowania przy ustawieniach, uytkownik
    // zmiennie moe podawa tylko liczb prbek, reszt jak czstotliwo prbkowania
    // i audio format pobiera si z otwieranego pliku

    //Test sekwencji na fazie
    File file = new File("ExampleSounds/seq/DWK_violin.wav");
    Integer[] seqInte = WaveToSamplesConverter.convertWaveToIntSamples(file);
    System.out.println("Samples overview " + seqInte.length);
    double seqSamplingFrequency = WaveToSamplesConverter.getSamplingFrequency(file);
    int samplesPerPart = 3000;
    SamplesToWaveConverter conv = new PhaseSpaceSampleConverter(seqSamplingFrequency, samplesPerPart,
            WaveToSamplesConverter.getAudioFormat(file));

    conv.setupFrequenciesFromSamples(seqInte);
    System.out.println("Zapisuj");
    conv.saveGeneratedSamples("XDPhase.wav");

    //Test sekwencji na grzebieniu
    SamplesToWaveConverter conv2 = new CombFilteringSampleConverter(seqSamplingFrequency, samplesPerPart,
            WaveToSamplesConverter.getAudioFormat(file));

    conv2.setupFrequenciesFromSamples(seqInte);
    System.out.println("Zapisuj");
    conv2.saveGeneratedSamples("XDComb.wav");

    //Rysowanie wykresu sygnau dwikowego
    final XYSeries dist = new XYSeries("P0");
    int index = 0;
    for (Integer i : ints) {
        dist.add(index / samplingFrequency, i);
        index++;
    }
    final XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(dist);

    JFreeChart chart = ChartFactory.createXYLineChart(f.getName(), "index", "Distance", dataset,
            PlotOrientation.VERTICAL, true, true, false);
    XYPlot xyPlot = (XYPlot) chart.getPlot();
    xyPlot.setDomainCrosshairVisible(true);
    xyPlot.setRangeCrosshairVisible(true);
    XYItemRenderer renderer = xyPlot.getRenderer();
    renderer.setSeriesPaint(0, Color.blue);
    NumberAxis domain = (NumberAxis) xyPlot.getRangeAxis();
    domain.setRange(-32768, 32768);
    ChartDrawer.drawChart(chart);

    System.out.println("FINISHED");
}

From source file:ta4jexamples.indicators.CandlestickChart.java

public static void main(String[] args) {
    /**// www .j  a  va2  s . c  o  m
     * Getting time series
     */
    TimeSeries series = CsvTradesLoader.loadBitstampSeries();

    /**
     * Creating the OHLC dataset
     */
    OHLCDataset ohlcDataset = createOHLCDataset(series);

    /**
     * Creating the additional dataset
     */
    TimeSeriesCollection xyDataset = createAdditionalDataset(series);

    /**
     * Creating the chart
     */
    JFreeChart chart = ChartFactory.createCandlestickChart("Bitstamp BTC price", "Time", "USD", ohlcDataset,
            true);
    // Candlestick rendering
    CandlestickRenderer renderer = new CandlestickRenderer();
    renderer.setAutoWidthMethod(CandlestickRenderer.WIDTHMETHOD_SMALLEST);
    XYPlot plot = chart.getXYPlot();
    plot.setRenderer(renderer);
    // Additional dataset
    int index = 1;
    plot.setDataset(index, xyDataset);
    plot.mapDatasetToRangeAxis(index, 0);
    XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer(true, false);
    renderer2.setSeriesPaint(index, Color.blue);
    plot.setRenderer(index, renderer2);
    // Misc
    plot.setRangeGridlinePaint(Color.lightGray);
    plot.setBackgroundPaint(Color.white);
    NumberAxis numberAxis = (NumberAxis) plot.getRangeAxis();
    numberAxis.setAutoRangeIncludesZero(false);
    plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);

    /**
     * Displaying the chart
     */
    displayChart(chart);
}

From source file:org.jfree.chart.demo.XYStepRendererDemo2.java

private static JFreeChart createChart(XYDataset xydataset) {
    JFreeChart jfreechart = ChartFactory.createXYLineChart("XYStepRenderer Demo 2", "X", "Y", xydataset,
            PlotOrientation.VERTICAL, true, true, false);
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    ValueAxis valueaxis = xyplot.getRangeAxis();
    valueaxis.setUpperMargin(0.14999999999999999D);
    XYStepRenderer xysteprenderer = new XYStepRenderer();
    xysteprenderer.setSeriesStroke(0, new BasicStroke(2.0F));
    xysteprenderer.setSeriesStroke(1, new BasicStroke(2.0F));
    xysteprenderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
    xysteprenderer.setDefaultEntityRadius(6);
    xysteprenderer.setBaseItemLabelGenerator(new StandardXYItemLabelGenerator());
    xysteprenderer.setBaseItemLabelsVisible(true);
    xysteprenderer.setBaseItemLabelFont(new Font("Dialog", 1, 14));
    xyplot.setRenderer(xysteprenderer);/*  w  w  w  .java2  s .com*/
    return jfreechart;
}

From source file:org.jfree.chart.demo.AnnotationDemo2.java

private static JFreeChart createChart() {
    XYDataset xydataset = createDataset1();
    JFreeChart jfreechart = ChartFactory.createXYLineChart("Annotation Demo 2", "Date", "Price Per Unit",
            xydataset, PlotOrientation.VERTICAL, false, true, false);
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    NumberAxis numberaxis = (NumberAxis) xyplot.getRangeAxis();
    numberaxis.setAutoRangeIncludesZero(false);
    NumberAxis numberaxis1 = new NumberAxis("Secondary");
    numberaxis1.setAutoRangeIncludesZero(false);
    xyplot.setRangeAxis(1, numberaxis1);
    xyplot.setDataset(1, createDataset2());
    xyplot.mapDatasetToRangeAxis(1, 1);// w  w  w  . j  a  va2 s.  c om
    XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyplot.getRenderer();
    xylineandshaperenderer.setBaseToolTipGenerator(StandardXYToolTipGenerator.getTimeSeriesInstance());
    xylineandshaperenderer.setBaseShapesVisible(true);
    xylineandshaperenderer.setBaseShapesFilled(true);
    XYPointerAnnotation xypointerannotation = new XYPointerAnnotation("Annotation 1 (2.0, 167.3)", 2D,
            167.30000000000001D, -0.78539816339744828D);
    xypointerannotation.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    xypointerannotation.setPaint(Color.red);
    xypointerannotation.setArrowPaint(Color.red);
    xylineandshaperenderer.addAnnotation(xypointerannotation);
    XYLineAndShapeRenderer xylineandshaperenderer1 = new XYLineAndShapeRenderer(true, true);
    xylineandshaperenderer1.setSeriesPaint(0, Color.black);
    xylineandshaperenderer.setBaseToolTipGenerator(StandardXYToolTipGenerator.getTimeSeriesInstance());
    XYPointerAnnotation xypointerannotation1 = new XYPointerAnnotation("Annotation 2 (15.0, 613.2)", 15D,
            613.20000000000005D, 1.5707963267948966D);
    xypointerannotation1.setTextAnchor(TextAnchor.TOP_CENTER);
    xylineandshaperenderer1.addAnnotation(xypointerannotation1);
    xyplot.setRenderer(1, xylineandshaperenderer1);
    LegendTitle legendtitle = new LegendTitle(xylineandshaperenderer);
    LegendTitle legendtitle1 = new LegendTitle(xylineandshaperenderer1);
    BlockContainer blockcontainer = new BlockContainer(new BorderArrangement());
    blockcontainer.add(legendtitle, RectangleEdge.LEFT);
    blockcontainer.add(legendtitle1, RectangleEdge.RIGHT);
    blockcontainer.add(new EmptyBlock(2000D, 0.0D));
    CompositeTitle compositetitle = new CompositeTitle(blockcontainer);
    compositetitle.setPosition(RectangleEdge.BOTTOM);
    jfreechart.addSubtitle(compositetitle);
    return jfreechart;
}

From source file:com.projity.pm.graphic.chart.ChartHelper.java

public static void removeAxisAndInsets(XYPlot plot) {
    plot.getRangeAxis().setVisible(false);
    plot.getDomainAxis().setVisible(false);
    plot.setDomainGridlinesVisible(false);
    plot.setInsets(new RectangleInsets(0, 0, BOTTOM_INSET, 0));
}

From source file:net.sf.maltcms.chromaui.charts.tools.ChartTools.java

/**
 *
 * @param plot/*  w  ww.j a  va2  s .c  om*/
 * @return
 */
public static XYPlot getPlot3(XYPlot plot) {
    XYPlot p = new XYPlot(plot.getDataset(), new NumberAxis(plot.getRangeAxis().getLabel()),
            new NumberAxis(plot.getDomainAxis().getLabel()), plot.getRenderer());
    p.setOrientation(PlotOrientation.HORIZONTAL);
    p.setDomainAxisLocation(AxisLocation.TOP_OR_RIGHT);
    Logger.getLogger(ChartTools.class.getName()).log(Level.INFO, "fixed auto range: {0}",
            plot.getRangeAxis().getRange().getUpperBound());
    p.getDomainAxis().setFixedAutoRange(500);

    return p;
}

From source file:umberto.WeightedClusterCoefficient.ChartUtils.java

public static void scaleLogChart(JFreeChart chart, XYSeries dSeries, boolean normalized) {
    XYPlot plot = (XYPlot) chart.getPlot();
    final LogAxis logyAxis = new LogAxis(plot.getRangeAxis().getLabel());
    final LogAxis logxAxis = new LogAxis(plot.getDomainAxis().getLabel());
    //Set y axis format.
    //        DecimalFormat formaty = (DecimalFormat) DecimalFormat.getNumberInstance(Locale.ENGLISH);
    //        formaty.applyPattern("#0.0000");

    //set y axis/* w w w .j a  v a2 s.c  o  m*/
    logyAxis.setBase(10);
    //        logyAxis.setNumberFormatOverride(formaty);
    logyAxis.setStandardTickUnits(LogAxis.createLogTickUnits(Locale.ENGLISH));
    //        logyAxis.setRange(0.01, 1.0);
    logyAxis.setAutoRange(true);
    plot.setRangeAxis(logyAxis);
    //set x axis
    logxAxis.setBase(10);
    logxAxis.setStandardTickUnits(LogAxis.createLogTickUnits(Locale.ENGLISH));
    logxAxis.setAutoRange(true);
    //logxAxis.setRange(0.00001, 1.0);//Se la voglio zoommare
    plot.setDomainAxis(logxAxis);
}