Pyqtgraph force axis labels to have decimal points

Viewed 1725

I am trying to get my axis labels to all have decimal points, even if they happen to be integers. See the below picture.

enter image description here

You'll notice that on the x-axis, whenever the value is an integer, it no longer displays the decimal. I would like "1" to read "1.0".

I have a method that is setting my plot style. It reads something like this

Plotstyle1

def set_plotstyle(p1, style):
    if style == 1:
        axlabel_font = QtGui.QFont()
        axlabel_font.setPixelSize(20)

        p1.showAxis('right')
        p1.showAxis('top')

        p1.showLabel('right', show=False)
        p1.showLabel('top', show=False)

        p1.showGrid(x=False, y=False)
        p1.setLogMode(x=False, y=False)
        p1.getAxis('left').tickFont = axlabel_font
        p1.getAxis('bottom').tickFont = axlabel_font
        p1.getAxis('left').labelFont = axlabel_font
        p1.getAxis('bottom').setHeight(70)
        p1.getAxis('left').setWidth(100)
        p1.getAxis('right').setWidth(60)
        p1.getAxis('left').setStyle(tickTextOffset=15)
        p1.getAxis('bottom').setStyle(tickTextOffset=15)
        p1.getAxis('top').setStyle(showValues=False)
        p1.getAxis('right').setStyle(showValues=False) 

If possible, I would like to set this feature within this method. Thanks!

1 Answers
Related