Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plot mixes Y and X values when there are only two points per lineplot #21

Open
lcoulet opened this issue Aug 18, 2015 · 2 comments
Open

Comments

@lcoulet
Copy link

lcoulet commented Aug 18, 2015

When the lineplot is created and there are only two points in the line, the library mixes xvalues and yvalues (it takes x1 and y1 from x[] and x2 and y2 from y[] instead of x1,x2 from x[] and y1,y2 from y[])

I discovered this with a plot that looked like this:

        public class TestPlot {
            public static void main(String[] argv){
                Plot2DPanel plot = new Plot2DPanel();
                double[] xVals1={1.439552797E12};
                double[] yVals1={78.01681253978265};
                plot.addLinePlot("group1",xVals1, yVals1);

                double[] xVals2={1.439547397E12,1.439549977E12};
                double[] yVals2={132.63444272447055,123.83742313295052};
                plot.addLinePlot("group2",xVals2, yVals2);

                double[] xVals3={1.439547337E12,1.439552977E12};
                double[] yVals3={125.65397959192407,77.27720607952492};
                plot.addLinePlot("group4",xVals3, yVals3);

                double[] xVals4={1.439547397E12,1.439548177E12,1.439548297E12};
                double[] yVals4={129.3471436797041,133.2500131743693,149.82183519985475};
                plot.addLinePlot("group5",xVals4, yVals4);

                double[] xVals6={1.439547877E12,1.439548657E12};
                double[] yVals6={72.8865784844678,71.04753151587994};
                plot.addLinePlot("group9",xVals6, yVals6);

                plot.addLegend(plot.NORTH);
                plot.setToolTipText("DATA");
                JFrame frame = new JFrame("Demo data");
                frame.setContentPane(plot);
                frame.setSize(800, 600);
                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                frame.setVisible(true);
            }
        }

And the result is completely wromd due to x and y totally different scales:
clipboard

This is very disrturbing and looks like a bug.

@wamson
Copy link

wamson commented Aug 26, 2015

It is a BUG. The code "convertXY(X,Y)" of Plot2DCanvas may cause the bug.

@lcoulet
Copy link
Author

lcoulet commented Aug 26, 2015

Yes I also figured out. The fact is the convertXY is also used for arrays of X,Y values, as the arrays have 2 points it is converting as arrays of X,Y values.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants