Skip to content

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

Description

@lcoulet

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions