szymon_prz
szymon_prz

Reputation: 560

JFreeChart XYPlot point (0,0) is always drawing

i have a program that draws a polynomial, calculated by newton's interpolation. I'm adding points and this program draws calculated polynomial. But i have a problem with point (0,0), i always gets this point but i shouldn't. Here's example screen from program:

https://i.sstatic.net/80z0g.png

and my code for calculating x[] and y[]

public void calculate(){
    if(listaPunktow.size()>1){
        double dolX=minimumX();
        double goraX=maksimumX();
        double dolY=minimumY();
        double goraY=maksimumY();
        int szerokosc=wykresPanel.getWidth();
        wykresPanel.domainAxis.setRange(dolX, goraX);
        wykresPanel.rangeAxis.setRange(dolY, goraY);
        double skala = wykresPanel.domainAxis.getRange().getLength();
        x=new double[szerokosc];
        y=new double[szerokosc];
        double k=dolX;
        for(int i=-wykresPanel.getWidth()/2; i<wykresPanel.getWidth()/2-25; i++){
            k+=skala/szerokosc;

            x[i+wykresPanel.getWidth()/2]=k;
            double wartoscY=interpolacja.valueInX(k, listaPunktow);
            y[i+wykresPanel.getWidth()/2]=wartoscY;
            System.out.println("x="+k+" y="+wartoscY);
        }
        wykresPanel.createSeries(x, y);

    }

i'm getting this output for x[] and y[]

http://pastebin.com/pKZ8SAE5

please tell me how to fix this (0,0) point

Upvotes: 0

Views: 49

Answers (1)

David Gilbert
David Gilbert

Reputation: 4477

My guess would be that the last item in your x[] and y[] arrays is never populated in your loop so it takes the default value 0.0, then your createSeries() method adds that item to the dataset.

Upvotes: 1

Related Questions