Hi Patrick,

Thanks for all the info, will have a look shortly, and report back.

Michael


On Tuesday, May 17, 2022 at 7:58:44 PM UTC-7 Patrick wrote:

> Hi,
>
> I have successfully used both pyqtgraph and matplotlib together in a data 
> processing/analysis project. I used pyqtgraph for the most part, all the 
> interactive plots etc, and then matplotlib for the final step of generating 
> publication-quality plots. It's something I always wanted to open-source 
> but never really sorted out the details for that, but I'll try to summarise 
> here. Perhaps email me directly if you have problems and I may be able to 
> sort out and supply some better code.
>
> Imports look something like:
>
> # Do usual Qt imports, pyqtgraph and matplotlib
> from PyQt5 import QtWidgets, uic
> import pyqtgraph as pg
> import matplotlib as mpl
> mpl.use('Qt5Agg')
> # For matplotlib plots in the GUI
> from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as 
> FigureCanvas
> # For matplotlib plot exports to pdf
> from matplotlib.backends.backend_pdf import FigureCanvasPdf, PdfPages
>
> In relevant UI class, set up a matplotlib FigureCanvas widget to render 
> onto:
>
> self.resultplot_figureCanvas = 
> FigureCanvas(mpl.figure.Figure(constrained_layout=True))
> self.resultplots_groupBox.layout().addWidget(self.resultplot_figureCanvas)
>
> In appropriate place, render matplotlib plot to the FigureCanvas instead 
> of letting mpl.pyplot create one for you:
>
> fig = self.resultplot_figureCanvas.figure
> fig.clear()
> ax = fig.subplots(1, 1)
> ax.plot([1, 2, 3], [4, 5, 6])
> #...
> self.resultplot_figureCanvas.draw()
>
> If you want to render to a pdf, then render to a FigureCanvasPdf something 
> like:
>
> canvas = FigureCanvasPdf(mpl.figure.Figure(constrained_layout=True, 
> figsize=(figwidth, figheight)))
> fig = canvas.figure
> ax = fig.subplots(1, 1)
> ax.plot([1, 2, 3], [4, 5, 6])
> # ...
> fig.savefig("filename.pdf", bbox_inches="tight", dpi=150, 
> metadata=metadata_pdf)
>
> The application is a little old now (Qt5 etc), but hopefully that might 
> give you something to work with.
>
> Patrick
>
>
> On Wednesday, 18 May 2022 at 5:50:45 am UTC+9:30 ML___ wrote:
>
>> Hello,
>>
>> Thanks to all those who've worked on PyQtGraph.  I switched to it for a 
>> real time plotting app as I was bogging down Matplotlib.  
>> It's easy to use, highly flexible, and fast!
>>
>> I'm seeing a similar issue as was reported in 2012, where importing 
>> pyqtgraph stops matplotlib from showing plots:
>>
>> --------------------my code------------------------------
>> import matplotlib.pyplot as plt
>> plt.ion()
>> plt.show()
>> plt.plot([1,2,3,4])    # 1) call succeeds, interactive plot window is 
>> shown
>> import pyqtgraph  # 2) after this call the existing plot window from (1) 
>> is unresponsive
>> plt.plot([4,3,2,1])    # 3) function succeeds as in (1), but plot window 
>> is not updated, and remains unresponsive
>> -----------------------------------------------------------------
>>
>> I'm running Debian Testing (bookworm) recently updated
>> Python 3.10.4
>> pyqtgraph.__version__  = 0.12.4
>> matplotlib.__version__  = 3.5.1
>>
>> Regards,
>> Michael
>>
>>
>>
>>
>>
>>
>> On Monday, October 8, 2012 at 10:27:35 PM UTC-7 Jianbao Tao wrote:
>>
>>> Hi,
>>>
>>> I am playing with pyqtgraph recently. I am impressed by its speed. :-) 
>>> However, there is one thing that really bothers me: It doesn't appear  to 
>>> be compatible with matplotlib, which is very strange, considering the fact 
>>> that pyqtgraph and matplotlib have their own name space. Here is a snippet 
>>> that demonstrates that problem.
>>>
>>> #--------------------- code ----------------------------------
>>> import matplotlib.pyplot as plt
>>> import numpy as np
>>> x = np.arange(100)
>>> plt.plot(x)  # Working
>>> plt.show()
>>>
>>> import pyqtgraph
>>> plt.plot(x)  # Not working
>>> #----------------------- end of code -------------------------
>>>
>>> Cheers,
>>> Jianbao
>>>
>>>

-- 
You received this message because you are subscribed to the Google Groups 
"pyqtgraph" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pyqtgraph/146c388e-e8bd-496e-8a82-3f435ff19888n%40googlegroups.com.

Reply via email to