#1 PGPlot BG color control


In all the documentation for PGPlot, there is nothing
that indicates that it is possible to change the
background color of the graphing window or if you're
making a pic file, be able to change it there as well.
It seems that white and black seems to be flip flopped
when I'm trying to save graphs as a gif file using the
OO type programming for PGPlot and it would be very
usefull if it was possible to have anything else but a
black background for the graph. I'm trying to use this
utility to make graphs for a scientific web site and
white would be a much preferable color. If there's a
way to already do this, I'd love to know and if not,
would it be possible to add this feature?



  • Craig DeForest

    Craig DeForest - 2003-10-17

    Logged In: YES

    Hey, Jeremy,

    Sorry to have not noticed your query for a while.
    Unfortunately, it appears to me that background color
    control was not a priority to the designers of the original
    pgplot package. There are a couple of different ways for
    you to get What You Want.

    (A) Save the graphic as a file, then reload it and invert it
    manually (what a pain).

    (B) Use pgenv() explicitly, and draw the background manually
    using poly() or rect() [rect was not present -- I have just
    checked it into CVS!] , then set the axis color and such
    with the COLOR option

    (C) Use PLPlot instead. PGPLOT is sort of a legacy package,
    and PLPlot has more active development and (I believe)
    better control over colors. I know that Doug Hunt, who also
    runs a scientific website with a PDL backend, uses PLPlot as
    his package of choice.

  • Nobody/Anonymous

    Logged In: NO

    I beleive there is another way changing the colour table
    with the pgscr command of the low level PGPLOT package.
    There you can change the colors associated with the color

    Here is an example to plot the background red. The
    background has color index 0 and the pen has color index 1.

    #!/usr/bin/perl-x -w

    use PDL;
    use PDL::Graphics::PGPLOT::Window;
    use PGPLOT;

    # Change background to red!!



    More details at

    Xavier Calbet

  • Chris Marshall

    Chris Marshall - 2009-05-01

    I've reduced the priority of this request to reflect the probably deprecation of PGPLOT in the overall PDL graphics strategy. The hope is that PLplot functionality will replace PGPLOT functions.

  • Chris Marshall

    Chris Marshall - 2009-05-01
    • priority: 5 --> 1

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks