File: x12d.d

package info (click to toggle)
plplot 5.15.0%2Bdfsg-19
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 31,312 kB
  • sloc: ansic: 79,707; xml: 28,583; cpp: 20,033; ada: 19,456; tcl: 12,081; f90: 11,431; ml: 7,276; java: 6,863; python: 6,792; sh: 3,274; perl: 828; lisp: 75; makefile: 50; sed: 34; fortran: 5
file content (64 lines) | stat: -rw-r--r-- 1,692 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
//      Bar chart demo.
//

import std.string;

import plplot;

//--------------------------------------------------------------------------
// main
//
// Does a simple bar chart, using color fill.  If color fill is
// unavailable, pattern fill is used instead (automatic).
//--------------------------------------------------------------------------
int main( char[][] args )
{
    string text;

    // Parse and process command line arguments
    plparseopts( args, PL_PARSE_FULL );

    // Initialize plplot
    plinit();

    pladv( 0 );
    plvsta();
    plwind( 1980.0, 1990.0, 0.0, 35.0 );
    plbox( "bc", 1.0, 0, "bcnv", 10.0, 0 );
    plcol0( 2 );
    pllab( "Year", "Widget Sales (millions)", "#frPLplot Example 12" );

    PLFLT[] pos   = [ 0.0, 0.25, 0.5, 0.75, 1.0 ];
    PLFLT[] red   = [ 0.0, 0.25, 0.5, 1.0, 1.0 ];
    PLFLT[] green = [ 1.0, 0.5, 0.5, 0.5, 1.0 ];
    PLFLT[] blue  = [ 1.0, 1.0, 0.5, 0.25, 0.0 ];
    plscmap1l( 1, pos, red, green, blue );

    PLFLT[] y0 = [ 5.0, 15.0, 12.0, 24.0, 28.0, 30.0, 20.0, 8.0, 12.0, 3.0 ];
    for ( size_t i = 0; i < 10; i++ )
    {
        plcol1( i / 9.0 );
        plpsty( 0 );
        plfbox( ( 1980. + i ), y0[i] );
        text = format( "%.0f", y0[i] );
        plptex( ( 1980. + i + .5 ), ( y0[i] + 1. ), 1.0, 0.0, .5, text );
        text = format( "%d", 1980 + i );
        plmtex( "b", 1.0, ( ( i + 1 ) * .1 - .05 ), 0.5, text );
    }

    // Don't forget to call plend() to finish off!
    plend();
    return 0;
}


void plfbox( PLFLT x0, PLFLT y0 )
{
    PLFLT[4] x = [x0, x0, x0 + 1.0, x0 + 1.0];;
    PLFLT[4] y = [0.0, y0, y0, 0.0];

    plfill( x, y );
    plcol0( 1 );
    pllsty( 1 );
    plline( x, y );
}