How can I set the backgroundcolor of text with set_backgroundcolor ?

Thanks John. This works great. I think, however, that

    > set_backgroundcolor would be useful. It should be easy to
    > fix. If nobody speaks up, I will take a crack at it, Mark

What do you have in mind, a simple convenience function that does

    def set_backgroundcolor(self, color):
        """
        Set the background color of the text by updating the bbox facecolor

        ACCEPTS: any matplotlib color
        """
        if self._bbox is None:
            self._bbox = dict(facecolor=color, edgecolor=color)
        else:
            self._bbox.update(dict(facecolor=color))

I'm not too opposed to it, but it does violate the maxim "There should be one--
and preferably only one --obvious way to do it." Of course, we
violate this throughout mpl offerings lots of convenience functions,
but it is something to bear in mind.

Thanks for writing the convenience function John !
I think there is a large group (like the students in my class) who use matplotlib as a simple tool to make beautiful graphs. To compete with matlab we need to keep simple tasks simple. I personally think that this convenience function is a good one to add. Probably under pylab.
Anybody else want to weigh in?
Mark

···

On 1/3/07, John Hunter <jdhunter@…4…> wrote:

“Mark” == Mark Bakker <
markbak@…287…> writes:

> Thanks John. This works great.  I think, however, that
> set_backgroundcolor would be useful.  It should be easy to
> fix.  If nobody speaks up, I will take a crack at it, Mark

What do you have in mind, a simple convenience function that does

def set_backgroundcolor(self, color):
    """
    Set the background color of the text by updating the bbox facecolor


    ACCEPTS: any matplotlib color
    """
    if self._bbox is None:
        self._bbox = dict(facecolor=color, edgecolor=color)
    else:
        self._bbox.update(dict(facecolor=color))

I’m not too opposed to it, but it does violate the maxim “There should be one–
and preferably only one --obvious way to do it.” Of course, we
violate this throughout mpl offerings lots of convenience functions,

but it is something to bear in mind.