PyQtGraph may not be available in the interpreter.

This may not be possible

For the time being, do this,

The following code may not be executed from the terminal. I think it is a phenomenon due to the difference in OS.

Like this

Python_console


import pyqtgraph as pg
pg.plot([0,1,2],[3,4,5])

this.

Python_console


import pyqtgraph as pg
import numpy as np
pg.image(np.random.rand(10,10))

By the way, this too.

Python_console


import pyqtgraph as pg
pg.dbg()

I want this to happen

20161104-02.png 20161104-01.png 20161104-03.png With this, it seems that you can create an advanced application that users can operate from the python console, such as 3DCG blender. No, I wonder if I started studying python because of this in 3D. ... works normally.

However, even if this happens (for Windows)

Maybe it's just my environment ...

The window appears, but it looks like it's frozen. I think it's in the same state as it was on this Yahoo! Answers.

20161011-1.png (In addition to this, there were cases where the axes of the graph were displayed but frozen.)

By the way, when linked with PySide, it will be displayed properly even on a Windows PC in the environment where this happens. ([Save this as im.py for now and run it.](Http://qiita.com/yozi/items/71f5b43ea99258d5fb81#%E3%81%A8%E3%82%8A%E3%81%82% E3% 81% 88% E3% 81% 9A% E3% 81% 93% E3% 82% 8C% E3% 82% 92impy% E3% 81% A8% E3% 81% 97% E3% 81% A6% E4% BF% 9D% E5% AD% 98% E3% 81% 97% E5% AE% 9F% E8% A1% 8C% E3% 81% 99% E3% 82% 8B))

That doesn't mean you can't do it on Windows.

I tried to make it a little easier than it was in here.

python


import sys
import pyqtgraph as pg
plt = pg.plot([0,1,2],[3,4,5])
if __name__ == '__main__':
    if sys.flags.interactive != 1 or not hasattr(pg.QtCore, 'PYQT_VERSION'):
        pg.QtGui.QApplication.exec_()

I thought I couldn't do it again ... 20161011-2.png I can do it.

??? Is there such a case? (If you use matplotlib ...)

The cause is unknown, but it seems that pyqtgraph can be used once it is plotted with matplotlib. I noticed it by chance.

python


import matplotlib.pyplot as plt
plt.plot([0,1,2],[0,1,2])
plt.show()

Anyway, after deleting the window of matplotlib,

import pyqtgraph as pg
pg.plot([0,1,2],[3,4,5])

Then you can do it safely. Importing pyqtgraph seems to be okay even before matplotlib.

I don't know what role matplotlib plays.

It will be like this (for Ubuntu)

20161010screenshot27.png You can! One shot! !!

By the way, this is a graph that can be operated interactively.

--Left-click and drag to move left or right. --Right-click and drag to zoom. --From the menu that appears by right-clicking and pressing once, it also supports axis log display, image saving, plot data saving, etc.

By the way, I will compare it with matplotlib,

Python_console_session


import matplotlib.pyplot as plt
plt.plot([0,1,2],[3,4,5])
plt.show()

It takes 3 lines. 20161010screenshot28.png This can also be operated interactively. I will omit the details, It's like pressing the lower button → dragging to move the screen.

I like the operation of PyQtGraph on Ubuntu because it works faster.

Recommended Posts

PyQtGraph may not be available in the interpreter.
Methods available in the list
Django's auto_now may not be updated
PyQtGraph may not be available in the interpreter.
Qiitadon icon may not be changed by API
Django model: ManyToManyField
Django's auto_now may not be updated
The hostname command may be multifunctional
Run the Python interpreter in a script
Tkinter could not be imported in Python
Pipfile is not created in the current directory
Matters examined at the study session in May
Qiitadon icon may not be changed by API
What to do when is not in the sudoers file.This incident will be reported.
The story that sendmail that can be executed in the terminal did not work with cron
When the selected object in bpy.context.selected_objects is not returned
Japan may be Galapagos in terms of programming language
AssertionError in Poetry may be fixed by modifying pyproject.toml
Not being aware of the contents of the data in python
Modules that may go through the shell in Python
Do not pass self to ProcessPoolExecutor in the class
Kaggle Tutorial Titanic know-how to be in the top 2%
The story that yapf did not work in vscode
The escape symbol of'(Single quote) may be displayed as it is in Python's interactive mode.