I'm new to plplot. I noticed that the background color is not being changed when the device is set to 'mem'. So far as I can tell, this is because pl_bop isn't doing anything; look at plD_bop_mem in drivers/mem.c . So I changed plD_bop_mem as follows:

void plD_bop_mem(PLStream *pls)
  int i;
  unsigned char *mem = (unsigned char *)pls->dev;
  for (i = 0; i < pls->phyxma*pls->phyyma*3;) {
    mem[i++] = pls->cmap0[0].r;
    mem[i++] = pls->cmap0[0].g;
    mem[i++] = pls->cmap0[0].b;

and it works properly now (note that plsmem stores the -x and -y dimensions of the memory in phyxma and phyyma).