can't use label styling

146 views
Skip to first unread message

Samuel Bader

unread,
Aug 1, 2014, 3:52:10 PM8/1/14
to pyqt...@googlegroups.com
Hello,

I'm just trying out PyQtGraph for the first time today (PyQtGraph 0.9.8, Windows 64, Python version 2.7.6), and trying to get some basic examples running.  I'm having trouble adding styles to labels, even just using code straight from other messages in this group or from the documentation.


# Imports

import numpy.random as nprand

import pyqtgraph as pg


# Create a window with one plot

win=pg.GraphicsWindow()

pi=win.addPlot(row=0,col=0)

pi.plot(nprand.random_integers(0,high=10,size=50))


# Set labels on that plot

pi.setLabels(title="Bad component i-v",left="Current [mA]")

labelStyle = {'color': '#FFF', 'font-size': '14pt'}

pi.getAxis("bottom").setLabel('Voltage', units='V', **labelStyle)



This code shows the title and the left axis label, but not the bottom label.  If I remove ", **labelStyle", then it works (but, of course, with no styling!).  Any suggestions?


Thanks,

Sam

Luke Campagnola

unread,
Aug 1, 2014, 4:29:57 PM8/1/14
to pyqt...@googlegroups.com
On Fri, Aug 1, 2014 at 3:52 PM, Samuel Bader <samuel.ja...@gmail.com> wrote:
# Set labels on that plot

pi.setLabels(title="Bad component i-v",left="Current [mA]")

labelStyle = {'color': '#FFF', 'font-size': '14pt'}

pi.getAxis("bottom").setLabel('Voltage', units='V', **labelStyle)


This code shows the title and the left axis label, but not the bottom label.  If I remove ", **labelStyle", then it works (but, of course, with no styling!).  Any suggestions?


Mysterious!
On Linux, I get the expected result. On Win 7, I am able to change the color but not the font size. On your system, no text at all. Sounds like a Qt bug..

Does it work if you supply only a color?



Samuel Bader

unread,
Aug 1, 2014, 5:51:49 PM8/1/14
to pyqt...@googlegroups.com
No, it doesn't seem to like any items inside of labelStyling.

Though if I do this:

pi.getAxis("bottom").setLabel('<span style="color: red;font-size: 30pt">Voltage</span>', units='V')

I get the text to be large and colored.  (Understandably, the units are not.)

Best,
Sam

---
Samuel James Bader

Ph.D. Candidate
Applied & Engineering Physics
Cornell University



--
You received this message because you are subscribed to a topic in the Google Groups "pyqtgraph" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/pyqtgraph/9pwTS7goAfw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to pyqtgraph+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyqtgraph/CACZXET_-AAx5KQDMPrZmERQZyoBxC6%3D05UU3KUtodfCAtWgWGg%40mail.gmail.com.

For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages