I can run this code in Pycharm in a standard Python Console of a clean project:
import numpy as np
import pyqtgraph as pg
data = np.random.normal(size=1000)
pg.plot(data, title="Simplest possible plotting example")
pg.QtGui.QApplication.exec_()
I was now trying to customize the X axis to support datetime, so I've used this code I've found online:
class TimeAxisItem(pg.AxisItem):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.setLabel(text='Time', units=None)
self.enableAutoSIPrefix(False)
def tickStrings(self, values, scale, spacing):
return [datetime.datetime.fromtimestamp(value).strftime("%H:%M") for value in values]
And tried to use it with this:
x = np.random.normal(size=10)
y = np.arange(np.datetime64('2017-01-01'), np.datetime64('2017-01-11'))
pg.plot({'x': x, 'y': y}, axisItems={'bottom': TimeAxisItem(orientation='bottom')})
However, this (and many other codes I've found around to display datetime in the X axis) doesn't work. If I launch either from the Python console or from "Run" or "Debug" menu, I get this error:
Process finished with exit code -1073741819 (0xC0000005)
I've already tried this: Pycharm 4.0.3 crash any PyQt program while using Debug
Why is this?
User contributions licensed under CC BY-SA 3.0