5

Here is my code.

from pyqtgraph.Qt import QtGui
import numpy as np
import pyqtgraph.opengl as gl
from netCDF4 import Dataset
import sys

def main():

    app = QtGui.QApplication(sys.argv)
    w=gl.GLViewWidget()
    w.show()
    w.setCameraPosition(distance=150)

    #just my data
    data=Dataset('200707.nc')


    prec=data.variables['Prec'][5,:59,:59]

    p = gl.GLSurfacePlotItem(z=prec[:] ,shader='heightColor')
    p.shader()['colorMap'] = np.array([0.2, 2, 0.5, 0.2, 1, 1, 0.2, 0, 2])


    w.addItem(p)
    sys.exit(app.exec_())

if __name__ == '__main__':

    main()

I think the issue could be in the library's interaction with my Mac's pixel layout. Really not sure what it could be or how to resolve it. Should I looking into using a different program?

ImportanceOfBeingErnest
  • 321,279
  • 53
  • 665
  • 712
jcarilli
  • 71
  • 4
  • Could you provide a proper problem description? What exactly *is* the problem? How should the code behave like instead? – ImportanceOfBeingErnest Aug 08 '17 at 16:39
  • @ImportanceOfBeingErnest The issue is the plot this graphs is centered in the bottom left quadrant of the window- not the center. http://i.imgur.com/H4WoMfn.png – jcarilli Aug 08 '17 at 23:22
  • @ImportanceOfBeingErnest I have the same problem on my MacBook Pro 2016 15 inch running MacOS Sierra 10.12.6 and Python 3.6. To reproduce it, get a Mac, `sudo pip3 install PyOpenGL pyqtgragh` and run the examples as described in the documentation. That is, `import pyqtgraph.examples; pyqtgraph.examples.run()` in a Python console. Then, in the window that appears, select any of the "3D Graphcs" examples, and you will see that instead of the graph occupying the whole window as it should do, it only occupies the bottom-left quadrant,. – Ray Aug 15 '17 at 11:23
  • My friend tried it on Linux and it was fine, and another friend tried it on another Mac and it was the same problem. It looks like a Mac problem. – Ray Aug 15 '17 at 11:31
  • I don't have a mac available and will surely never use one in the future; I therefore cannot help here. But @Ray if you understood the question, maybe you can edit it such that the problem becomes more apparent. – ImportanceOfBeingErnest Aug 15 '17 at 11:42
  • Update, it looks like a scaling issue due to 4K and High DPI. I rescaled my (external) monitor and it displayed fine. – Ray Aug 15 '17 at 11:58

2 Answers2

0

I had the same problem on my Macbook Pro. I think something from the version of PyQtGraph you have installed isn't allowing for proper scaling on your (and most Mac) devices.

I haven't really messed around too much, but to get around this I created a new Python environment in Anaconda (to make sure any other dependencies aren't causing this) and installed the version of PyQtGraph that's available through Conda. I don't know if other versions through other sources will work as well, but this one seems to work for me.

If you have Anaconda installed on your computer, simply do the following:

  • Create a new Python environment. conda create -n env_name python=py_ver anaconda
  • Source to your environment. source activate env_name
  • Install PyQtGraph. conda install -c anaconda pyqtgraph

Now when you run your program, it should scale properly.

0

Had a problem like this after installing vispy on osx. Turns out I just needed to install the latest version of pyqt5 and the problem went away.

pip install pyqt5