0

I am creating a graph with contain x and y value. The y axis in normal but x is with the logarithmic value. I used the library (jfreechart.jar) for making this logarithmic graph.

My question is how can in fine the exact value of x if for example y is 10? (the value of x is in logarithmic number)

private void interActionPerformed(java.awt.event.ActionEvent evt) {                                      


     final XYSeries s1 = new XYSeries("Series 1");
        s1.add(0.075,4.8);
        s1.add(0.15,13.9);
        s1.add(0.425,19.5);
        s1.add(0.6,22.1);
        s1.add(1.18,26.6);
        s1.add(2,29.5);
        s1.add(2.36,31.2);
        s1.add(4.75,38.6);
        s1.add(9.5,46.2);
        s1.add(19,62.4);
        s1.add(25,76.);
        s1.add(37.5,86.2);
        s1.add(50,100);

        final XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(s1);
        final JFreeChart chart = ChartFactory.createXYLineChart(
        "sieve analyese",          // chart title
        "sieve size",               // domain axis label
        "passing",                  // range axis label
        dataset,                  // data
        PlotOrientation.VERTICAL,
        true,                     // include legend
        true,
        false
    );
    final XYPlot plot = chart.getXYPlot();
    final LogarithmicAxis domainAxis = new LogarithmicAxis("particle size in milimeters");
    final NumberAxis rangeAxis = new NumberAxis("percent passing");
    plot.setDomainAxis(domainAxis);
    plot.setRangeAxis(rangeAxis);
     BarRenderer renderer = null;
     ChartFrame frame = new ChartFrame("sive chart", chart);
     frame.setVisible(true);
     frame.setSize(1000,600);
    chart.setBackgroundPaint(Color.lightGray);

    plot.setOutlinePaint(Color.RED);
}                              [chart of x and y value][1]
agentp
  • 6,849
  • 2
  • 19
  • 37
jack
  • 521
  • 2
  • 6
  • 9

2 Answers2

0

Use the below function to get the value of x from y

x = Math.log(y)
Andrews B Anthony
  • 1,381
  • 9
  • 27
  • From what I understand, in this question x is not just log(y). I think what OP wants to know is that what will be the value of x on the created graph for specified value of y. – Kamalesh Wankhede Apr 28 '16 at 11:31
  • yes it is ok, but my question is if y=10 what will be the value of x based on the graph? – jack Apr 28 '16 at 12:27
0

For exact value of X you should know exact dependence (function) of Y(X) or X(Y). For real-life data the kind of this function often is unknown, and one have to apply some approximation method.

Considering that your data are monotone (increasing), you can find an index of interval where given Y lie using binary search. For sample data you'll find 0-th interval between (0.075,4.8) and (0.15,13.9)

Then apply some interpolation method. The simplest approach - linear interpolation.

For you data set you might use quadratic interpolation with better accuracy - use 3 closest points to build parabola equation, and from this equation get X for given Y.

Community
  • 1
  • 1
MBo
  • 77,366
  • 5
  • 53
  • 86