nael | 2020-11-04 07:14:06 UTC | #1
I'm plotting data stored in a Pandas dataframe as a Matplotlib graph with a Matplotlib toolbar, as explained in chapter 36 of the PySide2 book.
The toolbar's controls appear to have the same height as a QPushButton. Despite that, they appear really large compared to the rest of the interface, perhaps also because of their stronger black color. Is there any way to make them, say, the same height as a default line of text for instance?
Ideally I'd love to see them as a semi-transparent overlay on the graph's canvas itself, as they do in recent versions of MATLAB. But I haven't found any hint in the Matplotlib documentation that this might be possible.
Here is my current implementation of the graph in the following window:
import matplotlib # PySide2 imports done before matplotlib's from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg from matplotlib.backends.backend_qt5agg import NavigationToolbar2QT as NavigationToolbar from matplotlib.figure import Figure matplotlib.use("Qt5Agg") class PlotterWidget(QWidget): def __init__(self): super().__init__() # Create three "plot" QPushButton widgets # Create a maptlotlib FigureCanvas object, # which defines a single set of axes as its axes attribute self.canvas = MplCanvas(self, width=5, height=3, dpi=100) # Create toolbar for the figure: # * First argument: the canvas that the toolbar must control # * Second argument: the toolbar's parent (self, the PlotterWidget) toolbar = NavigationToolbar(self.canvas, self) # Define and apply widget layout layout = QVBoxLayout() layout.setContentsMargins(0, 0, 0, 0) layout.addLayout(<sublayout of three "plot" QPushButton here>) layout.addWidget(toolbar) layout.addWidget(self.canvas) self.setLayout(layout) # def slot methods for the three "plot" QPushButtons
logcbl211714 | 2021-07-23 14:34:56 UTC | #2
Hi, i'm also looking for a solution to control the size of the toolbar. Have you found any fix ?
nael | 2021-08-16 22:50:59 UTC | #3
Hi @logcbl211714, sadly I haven't made any progress on this issue as it's not been a priority issue. I remain interested in finding a way to fix that unsightly toolbar, though. Let me know if you find anything!