Matplotlib Widget and QT Issue

Good afternoon all,
I’m developing a GUI using QT Designer 4 and Python 2.7. The GUI will need to have several plots on it in order to show the data in the ways that I need. To accomplish this I’m using the matplotlib widget from within QT Designer. It all seems to work great, but I can’t seem to find a way to change the background color of the widget. Essentially, I’ve got a nicely laid out GUI with the default QT Designer light gray as the “background color”. Then I’ve got these matplotlib widgets which by default have a darker shade of gray/charcoal as their “background color”. How do I change the matplotlib widget bgcolor to the default light gray so as to match the rest of the GUI? Turning the background of the main GUI to the dark gray to match the matplotlib color is not an option. I kind of assumed the issue has to do with the matplotlib widget and not with QT Designer, hence the reason for posting in this mailing list.

Does anyone have any thoughts regarding this? Or can you point me to a documentation set that shows how to do this?

I think you’ll need to manually set the color of the figure. I.e.,
given a figure object “fig”:

fig.set_facecolor(...whatever Qt API gives you the default

background color…)

You could also experiment with

fig.set_frameon(False)

which will not draw a background rectangle at all for the figure --

but that could cause overdrawing problems (possibly, haven’t tried
it).

Mike
···

http://p.sf.net/sfu/intel-dev2devfeb


Matplotlib-users@lists.sourceforge.nethttps://lists.sourceforge.net/lists/listinfo/matplotlib-users

Michael,

I can get that to work rather easily on a matplotlib.pyplot figure via a patch. I haven’t had any luck getting that to work when using the MatplotlibWidget in Qt.

Essentially in my code, I’m doing the following (where fig_myData is the MatplotlibWidget instance):

result = self.ui.fig_myData.axes.imshow(self.myData, cmap=‘jet’, interpolation=‘nearest’, origin=‘lower’, aspect=‘auto’)

self.ui.fig_myData.draw()

What do I put in before the draw() statement? Something like self.ui.fig_myData.set_facecolor(‘#e0e0e0’) ? I’ve tried that exact line and the error I get is “MatplotlibWidget object has no attribute ‘set_facecolor’”.

Any ideas?

Thanks

···

On Fri, Feb 18, 2011 at 1:54 PM, Michael Droettboom <mdroe@…86…> wrote:

I think you'll need to manually set the color of the figure.  I.e.,

given a figure object “fig”:

fig.set_facecolor(...whatever Qt API gives you the default

background color…)

You could also experiment with



fig.set_frameon(False)



which will not draw a background rectangle at all for the figure --

but that could cause overdrawing problems (possibly, haven’t tried
it).

Mike
On 02/18/2011 02:26 PM, Jason Stone wrote:
    Good afternoon

all,
I’m developing a GUI using QT Designer 4 and Python 2.7.
The GUI will need to have several plots on it in order to
show the data in the ways that I need. To accomplish this I’m
using the matplotlib widget from within QT Designer. It all
seems to work great, but I can’t seem to find a way to change
the background color of the widget. Essentially, I’ve got a
nicely laid out GUI with the default QT Designer light gray as
the “background color”. Then I’ve got these matplotlib
widgets which by default have a darker shade of gray/charcoal
as their “background color”. How do I change the matplotlib
widget bgcolor to the default light gray so as to match the
rest of the GUI? Turning the background of the main GUI to
the dark gray to match the matplotlib color is not an option.
I kind of assumed the issue has to do with the matplotlib
widget and not with QT Designer, hence the reason for posting
in this mailing list.

      Does anyone have any thoughts regarding this?  Or can you

point me to a documentation set that shows how to do this?



The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb



Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:

Pinpoint memory and threading errors before they happen.

Find and fix more than 250 security defects in the development cycle.

Locate bottlenecks in serial and parallel code that limit performance.

http://p.sf.net/sfu/intel-dev2devfeb


Matplotlib-users mailing list

Matplotlib-users@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Jason,

Try adding a pyqt property ‘facecolor’ to your widget.

(This way you can set it also through the designer.)

Add something like this to the widget’s init method:

figFacecolor = QtCore.pyqtProperty(str, getfigfacecolor,

                            setfigfacecolor, resetfigfacecolor)

And then define the three methods.

Nadia