raiseException("Plot data must be 1 or 2D ndarray (data shape is %s)"%str(data.shape))
ifx==None:
iflen(args)==1:
kargs['y']=args[0]
eliflen(args)==2:
kargs['x']=args[0]
kargs['y']=args[1]
if'y'notinkargsorkargs['y']isNone:
kargs['y']=np.array([])
if'x'notinkargsorkargs['x']isNone:
kargs['x']=np.arange(len(kargs['y']))
forkin['x','y']:
data=kargs[k]
ifisinstance(data,list):
kargs['k']=np.array(data)
ifnotisinstance(data,np.ndarray)ordata.ndim>1:
raiseException("Plot data must be 1D ndarray.")
if'complex'instr(data.dtype):
raiseException("Can not plot complex data types.")
else:
if'complex'instr(data.dtype)+str(x.dtype):
raiseException("Can not plot complex data types.")
ifdata.ndim==2:### If data is 2D array, then assume x and y values are in first two columns or rows.
ifxisnotNone:
raiseException("Plot data may be 2D only if no x argument is supplied.")
ax=0
ifdata.shape[0]>2anddata.shape[1]==2:
ax=1
ind=[slice(None),slice(None)]
ind[ax]=0
y=data[tuple(ind)]
ind[ax]=1
x=data[tuple(ind)]
elifdata.ndim==1:
y=data
prof.mark("data checks")
self.setCacheMode(QtGui.QGraphicsItem.NoCache)## Disabling and re-enabling the cache works around a bug in Qt 4.6 causing the cached results to display incorrectly
#self.setCacheMode(QtGui.QGraphicsItem.NoCache) ## Disabling and re-enabling the cache works around a bug in Qt 4.6 causing the cached results to display incorrectly
## Test this bug with test_PlotWidget and zoom in on the animated plot
self.prepareGeometryChange()
ifcopy:
self.yData=y.view(np.ndarray).copy()
else:
self.yData=y.view(np.ndarray)
ifxisNone:
self.xData=np.arange(0,self.yData.shape[0])
else:
ifcopy:
self.xData=x.view(np.ndarray).copy()
else:
self.xData=x.view(np.ndarray)
self.yData=kargs['y'].view(np.ndarray)
self.xData=kargs['x'].view(np.ndarray)
prof.mark('copy')
ifself.xData.shape!=self.yData.shape:
raiseException("X and Y arrays must be the same shape--got %s and %s."%(str(x.shape),str(y.shape)))