If you have multiple Qt versions in your environment, you can force
pyqtgraph to use a specific binding by setting the PYQTGRAPH_QT_LIB
environment variable:

https://github.com/pyqtgraph/pyqtgraph/blob/master/pyqtgraph/Qt/__init__.py#L23

Unfortunately, this functionality isn't documented, but we have no plans in
removing it.  Having multiple Qt bindings is an issue for people who
install matplotlib using the conda defaults channel (which installs PyQt5
5.9, which pyqtgraph does not support).  A couple of other workarounds, in
that case, involve installing matplotlib via pip, or installing the
conda-forge variant of matplotlib.

On Sat, May 21, 2022 at 9:28 PM ML___ <[email protected]> wrote:

> Hi,
>
> So I have matplotlib and pyqtgraph coexisting.   Not sure exactly what
> changed, but had something to do with pyqtgraph auto selecting
> pyqt5.  Got my imports in order and now my app works as desired with
> pyside2, and separate matplotlibs scripts work as well.
>
> Michael
>
>
>
>
> On Friday, May 20, 2022 at 12:10:04 PM UTC-7 ML___ wrote:
>
>> 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/64a22a45-ebaf-4d01-a9fa-80e314e48103n%40googlegroups.com
> <https://groups.google.com/d/msgid/pyqtgraph/64a22a45-ebaf-4d01-a9fa-80e314e48103n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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/CA%2BnduTFM6-axeT-%3DmOTwmwgToheOYpf%3DJ84tTfqQJa0%2B46KSuA%40mail.gmail.com.

Reply via email to