Changing font/grid color in PlotWidget after creation

2,337 views
Skip to first unread message

JHallas

unread,
Oct 11, 2012, 7:44:52 PM10/11/12
to pyqt...@googlegroups.com
Hi,

I want to give the user the ability to change the color of the font and grid on a plot widget after it's already created.  I've found a straightforward way to change the background, but have more difficulty changing the other colors.  Any suggestions?

I saw this, but it only works before creation:
I guess I could create a new plot widget every time the color changes but that seems inelegant. 

Luke Campagnola

unread,
Oct 11, 2012, 8:04:46 PM10/11/12
to pyqt...@googlegroups.com
On Thu, Oct 11, 2012 at 7:44 PM, JHallas <jmha...@gmail.com> wrote:
Hi,

I want to give the user the ability to change the color of the font and grid on a plot widget after it's already created.  I've found a straightforward way to change the background, but have more difficulty changing the other colors.  Any suggestions?


Sure, something like this: 

plot.getAxis('bottom').setPen('w') 

This will change the axes, grid lines, and axis labels. 
You can also explicitly provide color to the axis labels by including HTML in the text:

p.setLabel('bottom', 'Label with <span style="color: #f00">color</span>')


Luke

JHallas

unread,
Oct 12, 2012, 5:20:51 PM10/12/12
to pyqt...@googlegroups.com
Hi,

Works great.  Any quick way to access color settings of the title?
Reply all
Reply to author
Forward
0 new messages