Note that there are some explanatory texts on larger screens.

plurals
  1. POResize an axis fitting another with JFreechart
    primarykey
    data
    text
    <p>i'm trying to make an overlaid plot, And my problem is that i can't bring the second plot to fit the second one. Here is my first plot : <img src="https://i.stack.imgur.com/LqxSF.png" alt="enter image description here"></p> <p>And here the second one : <img src="https://i.stack.imgur.com/MvkcR.png" alt="enter image description here"></p> <p>And when i try to fit both, here is what i get :</p> <p><img src="https://i.stack.imgur.com/ZgIt2.png" alt="enter image description here"></p> <p>So basically, i would like to fit the whole second plot between 0 and 30, how can i do this <strong>without losing any data</strong>?</p> <p>First I tried using <code>plot.mapDatasetToRangeAxis()</code></p> <p>Then i tried with : </p> <pre><code> domain.setRange(0.00, 30.0); domain.setTickUnit(new NumberTickUnit(1)); </code></pre> <p>But i couldn't bring neither the first, nor the second one to work as i wish. Do you have any other ideas? (except buying <a href="http://www.jfree.org/jfreechart/devguide.html" rel="nofollow noreferrer">this</a> - which i can't afford right now as a student). Any help will be greatly appreciated :)</p> <p>Oh and by the way the <strong>x-axis is a speed</strong> (forgot to draw it on the plot).</p> <p>So here a very ugly photomontage of the kind of result i wish to have (with fitting units on the x and y axis) : Sorry for my Gimp skills, which are beyond bad. <img src="https://i.stack.imgur.com/9hj39.jpg" alt="enter image description here"></p> <p>Here is what i did :</p> <pre><code> private JFreeChart createOverlaidChart() { final NumberAxis domainAxis = new NumberAxis("Speed (m / s)"); final ValueAxis rangeAxis = new NumberAxis("Power (kw)"); // create plot ... final IntervalXYDataset data0 = createDataset0(); final XYItemRenderer renderer0 = new XYBarRenderer(0.20); // change "new XYBarRenderer(0.20)" to "StandardXYItemRenderer()" if you want to change type of graph final XYPlot plot = new XYPlot(data0, domainAxis, rangeAxis, renderer0); // add a second dataset and renderer... final IntervalXYDataset data1 = createDataset1(); final XYLineAndShapeRenderer renderer1 = new XYLineAndShapeRenderer(false, true); // arguments of new XYLineAndShapeRenderer are to activate or deactivate the display of points or line. Set first argument to true if you want to draw lines between the points for e.g. plot.setDataset(1, data1); plot.setRenderer(1, renderer1); // add a third dataset and renderer... final IntervalXYDataset data2 = createDataset2(); final XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer(true, true); // arguments of new XYLineAndShapeRenderer are to activate or deactivate the display of points or line. Set first argument to true if you want to draw lines between the points for e.g. plot.setDataset(2, data2); plot.setRenderer(2, renderer2); plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); // return a new chart containing the overlaid plot... return new JFreeChart("Test", JFreeChart.DEFAULT_TITLE_FONT, plot, true); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload