Module audian.yaxisitem
Classes
class YAxisItem (*args, **kwargs)
-
GraphicsItem showing a single plot axis with ticks, values, and label. Can be configured to fit on any side of a plot, Can automatically synchronize its displayed scale with ViewBox items. Ticks can be extended to draw a grid. If maxTickLength is negative, ticks point into the plot.
=============== =============================================================== Arguments: orientation one of 'left', 'right', 'top', or 'bottom' maxTickLength (px) maximum length of ticks to draw. Negative values draw into the plot, positive values draw outward. linkView (ViewBox) causes the range of values displayed in the axis to be linked to the visible range of a ViewBox. showValues (bool) Whether to display values adjacent to ticks pen (QPen) Pen used when drawing axis and (by default) ticks textPen (QPen) Pen used when drawing tick labels. tickPen (QPen) Pen used when drawing ticks. text The text (excluding units) to display on the label for this axis. units The units for this axis. Units should generally be given without any scaling prefix (eg, 'V' instead of 'mV'). The scaling prefix will be automatically prepended based on the range of data displayed. args All extra keyword arguments become CSS style options for the tag which will surround the axis label and units. =============== ===============================================================
Expand source code
class YAxisItem(pg.AxisItem): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.setPen('white') def setLogMode(self, *args, **kwargs): # no log mode! pass def tickSpacing(self, minVal, maxVal, size): diff = abs(maxVal - minVal) if diff == 0: return [] # hight of ytick labels: xwidth = QFontMetrics(self.font()).averageCharWidth() # minimum spacing: max_ticks = max(2, int(size / (3*xwidth))) min_spacing = diff / max_ticks p10unit = 10 ** floor(log10(min_spacing)) # major ticks: factors = [1.0, 2.0, 5.0, 10.0, 20.0, 50.0, 100.0] for fac in factors: spacing = fac * p10unit if spacing >= min_spacing: break # minor ticks: factors = [100.0, 10.0, 1.0, 0.1] for fac in factors: minor_spacing = fac * p10unit if minor_spacing < spacing: break return [(spacing, 0), (minor_spacing, 0)]
Ancestors
- pyqtgraph.graphicsItems.AxisItem.AxisItem
- pyqtgraph.graphicsItems.GraphicsWidget.GraphicsWidget
- pyqtgraph.graphicsItems.GraphicsItem.GraphicsItem
- PyQt5.QtWidgets.QGraphicsWidget
- PyQt5.QtWidgets.QGraphicsObject
- PyQt5.QtCore.QObject
- PyQt5.QtWidgets.QGraphicsItem
- PyQt5.QtWidgets.QGraphicsLayoutItem
- sip.wrapper
- sip.simplewrapper
Methods
def setLogMode(self, *args, **kwargs)
-
Set log scaling for x and/or y axes.
If two positional arguments are provided, the first will set log scaling for the x axis and the second for the y axis. If a single positional argument is provided, it will set the log scaling along the direction of the AxisItem. Alternatively, x and y can be passed as keyword arguments.
If an axis is set to log scale, ticks are displayed on a logarithmic scale and values are adjusted accordingly. (This is usually accessed by changing the log mode of a :func:
PlotItem <pyqtgraph.PlotItem.setLogMode>
.) The linked ViewBox will be informed of the change. def tickSpacing(self, minVal, maxVal, size)
-
Return values describing the desired spacing and offset of ticks.
This method is called whenever the axis needs to be redrawn and is a good method to override in subclasses that require control over tick locations.
The return value must be a list of tuples, one for each set of ticks::
[ (major tick spacing, offset), (minor tick spacing, offset), (sub-minor tick spacing, offset), ... ]