Example usage for org.jfree.chart.plot PlotOrientation VERTICAL

List of usage examples for org.jfree.chart.plot PlotOrientation VERTICAL

Introduction

In this page you can find the example usage for org.jfree.chart.plot PlotOrientation VERTICAL.

Prototype

PlotOrientation VERTICAL

To view the source code for org.jfree.chart.plot PlotOrientation VERTICAL.

Click Source Link

Document

For a plot where the range axis is vertical.

Usage

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);/*from  w  ww. jav  a2 s .  c  om*/
    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:kcse_2013_results.BarChartExample.java

public static void main(String[] args) {
    // Create a simple Bar chart
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    dataset.setValue(6, "Profit", "Jane");
    dataset.setValue(7, "Profit", "Tom");
    dataset.setValue(8, "Profit", "Jill");
    dataset.setValue(5, "Profit", "John");
    dataset.setValue(12, "Profit", "Fred");
    JFreeChart chart = ChartFactory.createBarChart("Comparison between Salesman", "Salesman", "Profit", dataset,
            PlotOrientation.VERTICAL, false, true, false);

    final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    final int width = screenSize.width;
    final int height = screenSize.height;
    try {// w  w  w.  j  a  v  a  2s.  c o m
        ChartUtilities.saveChartAsJPEG(new File("C:\\Users\\Wachira\\Desktop\\chart.jpg"), chart, width,
                height);
    } catch (IOException e) {
        System.err.println("Problem occurred creating chart.");
    }
}

From source file:ricecompression.RiceCompression.java

/**
 * @param args the command line arguments
 *///from w  w w  .j  av  a 2s. c  o  m
public static void main(String[] args) {
    RiceCompression rice = new RiceCompression();
    XYSeries data = new XYSeries("RICE");
    for (int i = -1023; i < 1024; i++) {
        String riceCode = rice.compress(32, i);
        data.add(i, riceCode.length());
    }
    XYSeriesCollection collection = new XYSeriesCollection(data);
    JFreeChart grafica = ChartFactory.createXYLineChart("RICE", "Nmero a codificar", "Longitud del codi Rice",
            collection, PlotOrientation.VERTICAL, true, true, false);
    ChartPanel Panel = new ChartPanel(grafica);
    JFrame Ventana = new JFrame("JFreeChart");
    Ventana.getContentPane().add(Panel);
    Ventana.pack();
    Ventana.setVisible(true);
    Ventana.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}

From source file:com.jaxzin.iraf.demo.CdfInv.java

public static void main(String[] args) {
    final JFreeChart chart = ChartFactory.createLineChart("Inverse CDF", "", "", createData(400),
            PlotOrientation.VERTICAL, true, true, true);

    // Customize the chart
    customizeChart(chart);/*from ww w.j  av a2  s.co m*/

    final JPanel panel = new ChartPanel(chart, true);
    final JFrame frame = new JFrame("Demo");
    frame.getContentPane().add(panel);
    setupJFrame(frame);
}

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 . ja v a  2s. co m
    ChartFrame chartframe = new ChartFrame("Test", jfreechart);
    chartframe.pack();
    chartframe.setVisible(true);
}

From source file:com.jaxzin.iraf.demo.Main.java

public static void main(String[] args) {
    final JFreeChart chart = ChartFactory.createHistogram("Probability of Values", "Value", "Probability",
            createData(COUNT), PlotOrientation.VERTICAL, false, true, true);
    // Customize the chart
    customizeChart(chart);/* w  ww . ja va 2  s  . co  m*/

    final JPanel panel = new ChartPanel(chart, true);
    final JFrame frame = new JFrame("Demo");
    frame.getContentPane().add(panel);
    setupJFrame(frame);

    java.util.Timer t = new java.util.Timer();
    t.schedule(new DataUpdater(chart), DELAY, DELAY);
}

From source file:Trabalho_1.java

/**
 * @param args the command line arguments
 *//* w w  w . j a  va  2  s  .  com*/
public static void main(String[] args) {
    // TODO code application logic here
    Ambiente n = new Ambiente(51, 51);
    n.inicializa(100, 30);

    XYSeries series = new XYSeries("Lobos");
    XYSeries series1 = new XYSeries("Ovelhas");
    XYSeries series2 = new XYSeries("Vegetacao");

    for (int i = 0; i < 5000; i++) {
        n.iteracao(i);

        series.add(i, n.getLobos());
        series1.add(i, n.getOvelhas());
        series2.add(i, n.getVegetacao());

    }

    // Add the series to your data set
    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(series);
    dataset.addSeries(series1);
    dataset.addSeries(series2);

    XYSeriesCollection dataset2 = new XYSeriesCollection();
    dataset2.addSeries(series);
    dataset2.addSeries(series1);

    // Generate the graph
    JFreeChart chart = ChartFactory.createXYLineChart("Lobos, Ovelhas e Vegetacao", "Iteracoes",
            "Numero de Animais", dataset, PlotOrientation.VERTICAL, // Plot Orientation
            true, // Show Legend
            true, // Use tooltips
            false // Configure chart to generate URLs?
    );
    try {
        ChartUtilities.saveChartAsJPEG(new File("Grafico.jpg"), chart, 640, 480);
    } catch (IOException e) {
        System.err.println("Problem occurred creating chart.");
    }

    // Generate the graph
    JFreeChart chart2 = ChartFactory.createXYLineChart("Lobos e ovelhas", "Iteracoes", "Numero de Animais",
            dataset2, PlotOrientation.VERTICAL, // Plot Orientation
            true, // Show Legend
            true, // Use tooltips
            false // Configure chart to generate URLs?
    );
    try {
        ChartUtilities.saveChartAsJPEG(new File("Grafico2.jpg"), chart2, 640, 480);
    } catch (IOException e) {
        System.err.println("Problem occurred creating chart.");
    }
}

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

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

    final XYDataset data = new SampleXYDataset2();
    final JFreeChart chart = ChartFactory.createScatterPlot("Scatter Plot Demo", "X", "Y", data,
            PlotOrientation.VERTICAL, true, true, false);
    //        final Legend legend = chart.getLegend();
    //      if (legend instanceof StandardLegend) {
    //        final StandardLegend sl = (StandardLegend) legend;
    //      sl.setDisplaySeriesShapes(true);
    //}
    final NumberAxis domainAxis = (NumberAxis) chart.getXYPlot().getDomainAxis();
    domainAxis.setAutoRangeIncludesZero(false);
    chart.setBackgroundPaint(java.awt.Color.white);

    // ****************************************************************************
    // * 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.             *
    // ****************************************************************************

    // save it to an image
    try {
        final ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
        final File file1 = new File("scatter100.png");
        ChartUtilities.saveChartAsPNG(file1, chart, 600, 400, info);

        // write an HTML page incorporating the image with an image map
        final File file2 = new File("scatter100.html");
        final OutputStream out = new BufferedOutputStream(new FileOutputStream(file2));
        final PrintWriter writer = new PrintWriter(out);
        writer.println("<HTML>");
        writer.println("<HEAD><TITLE>JFreeChart Image Map Demo</TITLE></HEAD>");
        writer.println("<BODY>");
        //            ChartUtilities.writeImageMap(writer, "chart", info);
        writer.println("<IMG SRC=\"scatter100.png\" "
                + "WIDTH=\"600\" HEIGHT=\"400\" BORDER=\"0\" USEMAP=\"#chart\">");
        writer.println("</BODY>");
        writer.println("</HTML>");
        writer.close();

    } catch (IOException e) {
        System.out.println(e.toString());
    }

}

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

/**
 * Starting point for the demo.//from  ww w .  j av a 2 s. c  o  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:visualize.Visualize.java

public static void main(String[] args) throws NotEnoughDataPointsException, IllDefinedDataPointsException {
    XYSeries seriesQ = new XYSeries("quadratic");
    XYSeries seriesL = new XYSeries("linear");
    XYSeries seriesI = new XYSeries("intepolated");

    final ArrayList<Point> pointsQ = new ArrayList<Point>();

    for (double x = -5.0; x <= 5.0; x = x + 0.5)
        pointsQ.add(new Point(new double[] { x, 2.0 * x * x * x - 10 * x * x }));

    final LinearFunction fl = new LinearFunction();
    final HigherOrderPolynomialFunction fq = new HigherOrderPolynomialFunction(3);
    final InterpolatedPolynomial<LinearFunction, HigherOrderPolynomialFunction> fi = new InterpolatedPolynomial<LinearFunction, HigherOrderPolynomialFunction>(
            new LinearFunction(), fq.copy(), 0.5);

    fl.fitFunction(pointsQ);/* ww  w  .j av a  2  s  .c  o  m*/
    fq.fitFunction(pointsQ);
    fi.fitFunction(pointsQ);

    System.out.println(fl);
    System.out.println(fq);
    System.out.println(fi.interpolatedFunction);

    for (double x = -5.0; x <= 5.0; x = x + 0.5) {
        seriesQ.add(x, fq.predict(x));
        seriesL.add(x, fl.predict(x));
        seriesI.add(x, fi.predict(x));
    }

    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(seriesQ);
    dataset.addSeries(seriesL);
    dataset.addSeries(seriesI);

    JFreeChart chart = ChartFactory.createXYLineChart("XY Chart", "x-axis", "y-axis", dataset,
            PlotOrientation.VERTICAL, true, true, false);

    final XYPlot plot = chart.getXYPlot();
    final XYItemRenderer renderer = plot.getRenderer();
    renderer.setSeriesPaint(0, new Color(0, 0, 255));
    renderer.setSeriesStroke(0, new BasicStroke(0.5f));
    renderer.setSeriesPaint(1, new Color(255, 0, 0));
    renderer.setSeriesStroke(1, new BasicStroke(0.5f));
    renderer.setSeriesPaint(2, new Color(0, 200, 40));
    renderer.setSeriesStroke(2, new BasicStroke(1.5f));

    //chart.getXYPlot().setRenderer(new XYSplineRenderer(100));

    JPanel panel = new JPanel();
    ChartPanel chartPanel = new ChartPanel(chart);
    panel.add(chartPanel);

    JFrame frame = new JFrame();
    frame.setContentPane(panel);
    frame.validate();
    Dimension d = new Dimension(800, 500);
    frame.setSize(d);

    frame.setVisible(true);

    try {
        Thread.sleep(3000);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    System.out.println("starting");

    for (int lambda = 0; lambda <= 100; ++lambda) {
        fi.setLambda(lambda / 100.0);
        fi.fitFunction(pointsQ);
        System.out.println(fi.interpolatedFunction);

        dataset.getSeries(2).clear();
        for (double x = -5.0; x <= 5.0; x = x + 0.5)
            seriesI.add(x, fi.predict(x));

        try {
            Thread.sleep(100);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        //   makeScreenshot( lambda );
    }

}