Using a graph on two tabs.
Solved
Qt for Python
-
I realize that a widget can appear in only one place. In the past I used matplotlib to create a fig and then the code below to put one instance of it on one tab (Plot) and another instance, a different name, on another tab (Gallery). The first replaces whatever had been on the tab before. The second goes to the end of whatever is on the tab. I now want to do the same thing except using pyqtgraph rather than matplotlib. Is there a way to do that? Just substituting a new_fig for fig gets an attribute error. Here's the original code:
def plot_to_gui(self, fig):# Add the plot to the Plot tab (replace the current plot) canvas_plot = FigureCanvas(fig) width, height = ( int(fig.get_size_inches()[0] * fig.dpi), int(fig.get_size_inches()[1] * fig.dpi)) canvas_plot.setFixedSize(width, height) canvas_plot.draw() self.tab_plot_scroll_area.setWidget(canvas_plot) # # # Add the plot to the Gallery tab (append to existing plots) canvas_gallery = FigureCanvas(fig) canvas_gallery.setFixedSize(width, height) canvas_gallery.draw() self.tab_gallery_layout.addWidget(canvas_gallery) # Add a spacer at the end to push plots to the top spacer = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding) self.tab_gallery_layout.addItem(spacer) plt.close(fig)
-
-
For solution see "Attribute Error...."