plotwidget

Plot widget

class tuiview.plotwidget.PlotBarWidget(parent)[source]

Widget for making bar plots

getXDataRange()[source]

Get the range of the X data to be plotted. If value(s) have been set with SetXRange these are returned

getYDataRange()[source]

Get the range of the Y data to be plotted. If value(s) have been set with SetYRange these are returned

haveData()[source]

Returns True if data has been set

paintData(paint, minXData, minYData, xoffset, xscale, yoffset, yscale)[source]

Paints the bars - called from paintEvent in the baseclass

setBars(bars)[source]

Set the bars object to use

class tuiview.plotwidget.PlotBars(data, minVal, maxVal, pen=None, fillColor=3)[source]

Pass an instance of this to PlotBarWidget.setBars() data should be a numpy array containing the counts. minVal and maxVal describe the range of the data

class tuiview.plotwidget.PlotCurve(xdata, ydata, pen=None)[source]

Pass instances of these to PlotLineWidget.addCurve() xdata and ydata should be numpy arrays If pen not given will be white, 1 pixel wide

class tuiview.plotwidget.PlotLabel(xloc, yloc, txt, flags=<PyQt5.QtCore.Alignment object>, pen=None)[source]

Pass instances of these to PlotWidget.addLabel() xloc and yloc are in data units txt is text to display flags are those accepted by QPainter.drawText If pen not given will be white, 1 pixel wide

class tuiview.plotwidget.PlotLineWidget(parent)[source]

Widget for making line plots

addCurve(curve)[source]

Add an instance of PlotCurve to the list of curves to be plotted

getXDataRange()[source]

Get the range of the X data to be plotted. If value(s) have been set with SetXRange these are returned

getYDataRange()[source]

Get the range of the Y data to be plotted. If value(s) have been set with SetYRange these are returned

haveData()[source]

Returns True if data has been set

paintData(paint, minXData, minYData, xoffset, xscale, yoffset, yscale)[source]

Paints the curves - called from paintEvent in the baseclass

removeCurves()[source]

Remove all the curves

class tuiview.plotwidget.PlotTick(loc, txt, flags=None, pen=None)[source]

Pass lists of these to PlotWidget.setXTicks and PlotWidget.setYTicks if flags is None either DEFAULT_YTICK_FLAGS or DEFAULT_XTICK_FLAGS will be used depending on the direction if pen is None the default axes pen will be used

class tuiview.plotwidget.PlotWidget(parent)[source]

Lightweight plot widget base class Don’t instantiate directly - use one of the base classes.

addLabel(label)[source]

Add a PlotLabel to be drawn

drawLabels(paint, minXData, minYData, xoffset, xscale, yoffset, yscale)[source]

Draw the user supplied labels onto the plot

drawText(paint, xloc, yloc, txt, flags)[source]

Helper method to draw text in given device coords For some reason Qt doesn’t come with a method like this that moves the text around for given flags.

drawXTicks(paint, minXData, maxXData, xoffset, xscale, width, height)[source]

Draw the X-ticks

drawYTicks(paint, minYData, maxYData, yoffset, yscale, height)[source]

Draw the Y-ticks. Returns the size needed for the text

findLargestIntervalLabel(intervals, ndp)[source]
static formatInterval(interval, ndp)[source]
getSettingsFontSize()[source]

Get the default font size from settings

getXDataRange()[source]

Get the range of the X data to be plotted.

getYDataRange()[source]

Get the range of the Y data to be plotted.

haveData()[source]

Returns True if data has been set

static makeIntervals(start, end, nIntervals)[source]

Make a ‘pretty’ list of intervals. This was the hardest part. also returns number of decimals to display This is non-zero if floating point data

paintData(paint)[source]

To be implemented in sublass

paintEvent(event)[source]

This is the main part - calculation and drawing happen here. In theory the calculation should happen separately on resize etc and paint should be simpler, but can’t be bothered right now Delegates to paintData() in sublass to do actuall work

removeLabels()[source]

remove all labels

setBackgroundColor(color)[source]

Sets the background color for the widget

setFontSize(size)[source]

Set the font point size

setXRange(xmin=None, xmax=None)[source]

Set the X range. Pass None for autoscale for either or both

setXTicks(xticks=None)[source]

Pass a list of PlotTicks. None to reset.

setYRange(ymin=None, ymax=None)[source]

Set the Y range. Pass None for autoscale for either or both

setYTicks(yticks=None)[source]

Pass a list of PlotTicks. None to reset.

sizeHint()[source]

This has to be implemented otherwise plot is very small!