src/main/java/eu/digitisation/math/Plot.java
public void show(int width, int height, int margin) {
        BufferedImage bim
                = new BufferedImage(width + 2 * margin,
                        height + 2 * margin,
                        BufferedImage.TYPE_INT_ARGB);
        Graphics2D g = bim.createGraphics();
        double xhigh = Arrays.max(X);
        double xlow = Arrays.min(X);
        double xrange = xhigh - xlow;
        double yhigh = Arrays.max(Y);
        double ylow = 0; //ArrayMath.min(Y);
        double yrange = yhigh - ylow;

        // draw bars
        g.setColor(Color.RED);
        for (int n = 0; n < X.length; ++n) {
            int xpos = (int)((width * (X[n] - xlow)) / xrange);
            int ypos = (int)((height * (Y[n] - ylow)) / yrange);
            g.fillRect(margin + xpos - 1, height + margin - ypos, 3, ypos);
        }

        // draw X and Y axes
        g.setColor(Color.BLUE);
        g.drawRect(margin, margin, width, height);

        // draw Y-tics
        int e = (int) Math.ceil(Math.log(yrange) / Math.log(10)) - 1;
        int ystep = (e > 0) ? pow(10, e) : 1;
        for (int y = ystep * (int)(ylow/ystep); y <= yhigh; y += ystep) {
            int ypos = (int)((height * (y - ylow)) / yrange);
            g.drawString(String.valueOf(y) + "-", 0, height + margin - ypos);
        }

        // draw X-tics
        e = (int) Math.ceil(Math.log(xrange) / Math.log(10)) - 1;
        int xstep = (e > 0) ? pow(10, e) : 1;
        for (int x = xstep * (int)(xlow/xstep); x <= xhigh; x += xstep) {
            int xpos = (int)((width * (x - xlow)) / xrange);
            g.drawString(String.valueOf(x) , margin + xpos - 6 * e, height + margin + 12);
            g.drawLine(margin + xpos, height + margin,
                    margin + xpos, height + margin - 5);
        }

        g.dispose();
        System.out.println("Showing on screen");
        eu.digitisation.image.Display.draw(bim);
    }
/**
     * Display histogram on screen
     *
     * @param width display width (in pixels)
     * @param height display height (in pixels)
     * @param margin display margins (in pixels)
     */
Display histogram on screen
@param width display width (in pixels)
@param height display height (in pixels)
@param margin display margins (in pixels)
Display histogram on screen @param width display width ( in pixels ) @param height display height ( in pixels ) @param margin display margins ( in pixels )
public void show(int width, int height, int margin) {
        BufferedImage bim
                = new BufferedImage(width + 2 * margin,
                        height + 2 * margin,
                        BufferedImage.TYPE_INT_ARGB);
        Graphics2D g = bim.createGraphics();
        double xhigh = Arrays.max(X);
        double xlow = Arrays.min(X);
        double xrange = xhigh - xlow;
        double yhigh = Arrays.max(Y);
        double ylow = 0; 
        double yrange = yhigh - ylow;
        g.setColor(Color.RED);
        for (int n = 0; n < X.length; ++n) {
            int xpos = (int)((width * (X[n] - xlow)) / xrange);
            int ypos = (int)((height * (Y[n] - ylow)) / yrange);
            g.fillRect(margin + xpos - 1, height + margin - ypos, 3, ypos);
        }
        g.setColor(Color.BLUE);
        g.drawRect(margin, margin, width, height);
        int e = (int) Math.ceil(Math.log(yrange) / Math.log(10)) - 1;
        int ystep = (e > 0) ? pow(10, e) : 1;
        for (int y = ystep * (int)(ylow/ystep); y <= yhigh; y += ystep) {
            int ypos = (int)((height * (y - ylow)) / yrange);
            g.drawString(String.valueOf(y) + "-", 0, height + margin - ypos);
        }
        e = (int) Math.ceil(Math.log(xrange) / Math.log(10)) - 1;
        int xstep = (e > 0) ? pow(10, e) : 1;
        for (int x = xstep * (int)(xlow/xstep); x <= xhigh; x += xstep) {
            int xpos = (int)((width * (x - xlow)) / xrange);
            g.drawString(String.valueOf(x) , margin + xpos - 6 * e, height + margin + 12);
            g.drawLine(margin + xpos, height + margin,
                    margin + xpos, height + margin - 5);
        }
        g.dispose();
        System.out.println("Showing on screen");
        eu.digitisation.image.Display.draw(bim);
    }
public void show ( int width , int height , int margin ) { BufferedImage bim = new BufferedImage ( width + 2 * margin , height + 2 * margin , BufferedImage . TYPE_INT_ARGB ) ; Graphics2D g = bim . createGraphics ( ) ; double xhigh = Arrays . max ( X ) ; double xlow = Arrays . min ( X ) ; double xrange = xhigh - xlow ; double yhigh = Arrays . max ( Y ) ; double ylow = 0 ; double yrange = yhigh - ylow ; g . setColor ( Color . RED ) ; for ( int n = 0 ; n < X . length ; ++ n ) { int xpos = ( int ) ( ( width * ( X [ n ] - xlow ) ) / xrange ) ; int ypos = ( int ) ( ( height * ( Y [ n ] - ylow ) ) / yrange ) ; g . fillRect ( margin + xpos - 1 , height + margin - ypos , 3 , ypos ) ; } g . setColor ( Color . BLUE ) ; g . drawRect ( margin , margin , width , height ) ; int e = ( int ) Math . ceil ( Math . log ( yrange ) / Math . log ( 10 ) ) - 1 ; int ystep = ( e > 0 ) ? pow ( 10 , e ) : 1 ; for ( int y = ystep * ( int ) ( ylow / ystep ) ; y <= yhigh ; y += ystep ) { int ypos = ( int ) ( ( height * ( y - ylow ) ) / yrange ) ; g . drawString ( String . valueOf ( y ) + "-" , 0 , height + margin - ypos ) ; } e = ( int ) Math . ceil ( Math . log ( xrange ) / Math . log ( 10 ) ) - 1 ; int xstep = ( e > 0 ) ? pow ( 10 , e ) : 1 ; for ( int x = xstep * ( int ) ( xlow / xstep ) ; x <= xhigh ; x += xstep ) { int xpos = ( int ) ( ( width * ( x - xlow ) ) / xrange ) ; g . drawString ( String . valueOf ( x ) , margin + xpos - 6 * e , height + margin + 12 ) ; g . drawLine ( margin + xpos , height + margin , margin + xpos , height + margin - 5 ) ; } g . dispose ( ) ; System . out . println ( "Showing on screen" ) ; eu . digitisation . image . Display . draw ( bim ) ; }
Display histogram on screen
 @param width display width (in pixels)
 @param height display height (in pixels)
 @param margin display margins (in pixels)
Display histogram on screen @param width display width ( in pixels ) @param height display height ( in pixels ) @param margin display margins ( in pixels )
//ArrayMath.min(Y); // draw bars // draw X and Y axes // draw Y-tics // draw X-tics