title: Auto-Scale Y-Axis in JfreeChart
body: <p>I am using <code>JFreeChart</code> to create candlestick charts in my Java app. However, my charts end up looking like this:</p>
  
  <p><img src="https://i.stack.imgur.com/dZozA.png" alt="capturebhx">
  <a href="http://imageshack.us/photo/my-images/69/capturebhx.png/" rel="noreferrer">http://imageshack.us/photo/my-images/69/capturebhx.png/</a></p>
  
  <p>I would like to have the Y-axis automatically scaled so that the chart looks more like this:</p>
  
  <p><img src="https://i.stack.imgur.com/R5ILP.png" alt="capture2wl">
  <a href="http://imageshack.us/photo/my-images/717/capture2wl.png/" rel="noreferrer">http://imageshack.us/photo/my-images/717/capture2wl.png/</a></p>
  
  <p>I think <code>org.jfree.chart.axis.NumberAxis.configure()</code> will do this, but I'm not sure. I can't seem to find a way to tie my <code>JFreeChart</code>object, or <code>ChartPanel</code> object to this <code>NumberAxis</code> object. Please help me, I am lost and have been looking for a long time to try and tie these objects together. Or, if you can find another way, that'd be great too!</p>
  
  <p>Some code:</p>
  
  <pre><code>...
  private DefaultHighLowDataset dataset;
  private JFreeChart chart;
  private ChartPanel chart_panel;
  
  ...
  
  // creates dataset, then chart from dataset, then chart_panel from chart
  dataset = new DefaultHighLowDataset("", date, high, low, open, close, volume);
  chart = ChartFactory.createCandlestickChart("Blank", "Time", "Price", dataset, false);
  chart_panel = new ChartPanel(chart); // what you see in the images
  ...
  </code></pre>