src/main/java/eu/digitisation/math/Histogram.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();
        int xhigh = Arrays.max(X);
        int xlow = Arrays.min(X);
        int xrange = xhigh - xlow;
        int yhigh = Arrays.max(Y);
        int ylow = 0; //ArrayMath.min(Y);
        int yrange = yhigh - ylow;

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

        // draw title
        g.setColor(Color.DARK_GRAY);
        if (title != null) {
            g.drawString(title, margin, margin / 2);
        }

        // 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 = ylow - ylow % ystep; y <= yhigh; y += ystep) {
            int ypos = (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 = xlow - xlow % xstep; x <= xhigh; x += xstep) {
            int xpos = (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();
        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();
        int xhigh = Arrays.max(X);
        int xlow = Arrays.min(X);
        int xrange = xhigh - xlow;
        int yhigh = Arrays.max(Y);
        int ylow = 0; 
        int yrange = yhigh - ylow;
        g.setColor(Color.RED);
        for (int n = 0; n < X.length; ++n) {
            int xpos = (width * (X[n] - xlow)) / xrange;
            int ypos = (height * (Y[n] - ylow)) / yrange;
            g.fillRect(margin + xpos - 1, height + margin - ypos, 3, ypos);
        }
        g.setColor(Color.DARK_GRAY);
        if (title != null) {
            g.drawString(title, margin, margin / 2);
        }
        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 = ylow - ylow % ystep; y <= yhigh; y += ystep) {
            int ypos = (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 = xlow - xlow % xstep; x <= xhigh; x += xstep) {
            int xpos = (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();
        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 ( ) ; int xhigh = Arrays . max ( X ) ; int xlow = Arrays . min ( X ) ; int xrange = xhigh - xlow ; int yhigh = Arrays . max ( Y ) ; int ylow = 0 ; int yrange = yhigh - ylow ; g . setColor ( Color . RED ) ; for ( int n = 0 ; n < X . length ; ++ n ) { int xpos = ( width * ( X [ n ] - xlow ) ) / xrange ; int ypos = ( height * ( Y [ n ] - ylow ) ) / yrange ; g . fillRect ( margin + xpos - 1 , height + margin - ypos , 3 , ypos ) ; } g . setColor ( Color . DARK_GRAY ) ; if ( title != null ) { g . drawString ( title , margin , margin / 2 ) ; } 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 = ylow - ylow % ystep ; y <= yhigh ; y += ystep ) { int ypos = ( 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 = xlow - xlow % xstep ; x <= xhigh ; x += xstep ) { int xpos = ( 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 ( ) ; 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 title // draw X and Y axes // draw Y-tics // draw X-tics