Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pyqtgraph axis label gets covered for 2D plots #359

Open
sldesnoo-Delft opened this issue Oct 21, 2024 · 0 comments
Open

pyqtgraph axis label gets covered for 2D plots #359

sldesnoo-Delft opened this issue Oct 21, 2024 · 0 comments

Comments

@sldesnoo-Delft
Copy link

This is a similar issue as #134.
When I use a pyqtgraph PlotItem to add an ImageView, then the x-axis label gets partially covered.

image

The fix is to add zero padding to QGraphicsView:

QGraphicsView {
    padding: 0px;
}

Environment:

* OPERATING SYSTEM---------------------------------------------------------------
    - System........................ Windows
    - Release....................... 10
    - Platform...................... Windows-10-10.0.19045-SP0
    - Version....................... 10.0.19045
* PYTHON DISTRIBUTION------------------------------------------------------------
    - Version....................... 3.12.7
    - C Compiler.................... MSC v.1929 64 bit (AMD64)
    - C API Version................. 1013
    - Implementation................ cpython
    - Implementation Version........ 3.12.7
* QT BINDINGS--------------------------------------------------------------------
    - PyQt5 Version................. 5.15.11
    - PyQt5 Qt Version.............. 5.15.2
* QT ABSTRACTIONS----------------------------------------------------------------
    - qtpy Version.................. 2.4.1
    - qtpy Binding.................. pyqt5
    - qtpy Binding Variable......... os.environ['QT_API']
    - qtpy Import Name.............. qtpy
    - qtpy Status................... OK
    - pyqtgraph Version............. 0.13.7.4
    - pyqtgraph Binding............. Not set or inexistent
    - pyqtgraph Binding Variable.... os.environ['PYQTGRAPH_QT_LIB']
    - pyqtgraph Import Name......... pyqtgraph
    - pyqtgraph Status.............. OK
* PYTHON PACKAGES----------------------------------------------------------------
    - helpdev....................... 0.7.1
    - QDarkStyle.................... 3.2.3

Code to reproduce:

import numpy as np
import pyqtgraph as pg
import qdarkstyle
from PyQt5 import QtWidgets

class Plotter(QtWidgets.QWidget):
    def __init__(self):
        super().__init__()

        self.setMinimumSize(600, 400)
        self._layout = QtWidgets.QVBoxLayout()
        self.setLayout(self._layout)

        self.plot = pg.PlotItem()
        img = pg.ImageItem()
        img.setImage(np.diag(np.ones(200)))
        self.img_view = pg.ImageView(view=self.plot, imageItem=img)
        self._layout.addWidget(self.img_view)
        self.plot.getAxis('bottom').setLabel("X-axis")

        self.show()

apply_fix = False

app = pg.mkQApp()

app = QtWidgets.QApplication.instance()

dark_stylesheet = qdarkstyle.load_stylesheet()

if apply_fix:
    dark_stylesheet +=r'''
    QGraphicsView {
        padding: 0px;
    }
    '''
app.setStyleSheet(dark_stylesheet)

plotter = Plotter()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant