XyPlot (hwx.gui)

Creates a 2D plot.

Inherits:

Properties

Public Methods

addCurve (self, y=[0], x=None, fit=True, **kwds)

addEventHandler (self, tool)

addXslider (self, x=0, **kwds)

addYslider (self, y=0, **kwds)

clear (self)

ensureVisible (self, x=None, y=None, points=None)

fit (self, zoom=None, larger=False)

formatAxis (self, value, axis)

formatHoverText (self, curve, x, y)

formatNumber (self, value, format=None)

getPointUnderMouse (self, event, curves=None, tolerance=None)

getSelectedPoints (self)

getTheClosestPoint (self, x, y)

pan (self, dx, dy)

redrawPlot (self, obj=None, name=None)

selectPoints (self, points)

setCursor (self, cursor, iconStrip=False, x=-1, y=-1)

setSnapping (self, on=True, xgrid=None, ygrid=None, snapPoints=None)

zoom (self, factor=1.5, point=None, axis=’both’)

zoomAtMouseEvent (self, event)

Property Details

property bgColor

Specifies the background color of the plot.

property border

Size of the border around the plot.

property fontSize

Size of the font in points.

property footer

Text at the bottom of the figure.

property title

Text on top of the plot.

property xlabel

Text along the x-axis.

property xlimits

Min and max limits of the x-axis.

property ylabel

Text along the y-axis.

property ylimits

Min and max limits of the y-axis.

property zeroLines

Highlights the axes.

Method Details

addCurve(self, y=[0], x=None, fit=True, **kwds)

Adds a curve to the plot.

In case x is None, it is set to x = list(range(len(y)))

param y

The y values of the curve.

type y

list[float]

param x

The x values of the curve.

type x

list[float]

param fit

Determines if curve gets fitted inside the plot.

type fit

bool

returns

The newly added Curve object.

rtype

Curve

addEventHandler(self, tool)

Adds a custom event handler to define the method associated to an event.

If the action returns True, other event handlers for the same event will be blocked.

This is useful if you want to listen for a mouse release and get the plot value instead of the mouse x/y.

addXslider(self, x=0, **kwds)

Adds a movable vertical line to the plot.

param x

The value where the slider will start from on the x-axis.

type x

float

returns

The new added XSlider object.

rtype

XSlider

addYslider(self, y=0, **kwds)

Adds a movable horizontal line to the plot.

param y

The value where the slider will start from on the y-axis.

type y

float

returns

The new added YSlider object.

rtype

YSlider

clear(self)

Resets the title, x-y labels and footer and remove all curves, sliders and tools, from the plot.

ensureVisible(self, x=None, y=None, points=None)

Scales the axes so they contains the x, y and points.

param x

Specified x value.

type x

float

param y

Specified y value.

type y

float

param points

Points to make visible. Points can be a list of CurvePoints of set to ‘selected’.

type points

Union[list[CurvePoints], str]

returns

A reference to the instance XyPlot object on which it was called.

rtype

XyPlot

fit(self, zoom=None, larger=False)

Rescales the axes so all curves are visible.

param zoom

Padding scale factor around the curves.

type zoom

float

param larger

Determines if it will be fitted only in the case the computed scale exceeds the current.

type larger

bool

returns

A reference to the instance XyPlot object on which it was called.

rtype

XyPlot

formatAxis(self, value, axis)

Called to format the x or y-axis major tick values.

param value

type value

float

param axis

‘x’ or ‘y’

type axis

str

returns

Value converted to a string

rtype

str

formatHoverText(self, curve, x, y)

Called to format the curve point text when hovered.

param curve

type curve

Curve

param x

X value to be formatted.

type x

float

param y

Y value to be formatted.

type y

float

returns

The formatted string with X and Y value.

rtype

str

formatNumber(self, value, format=None)

Formats the axis tick values using Inspire number formatting.

param value

The value to be formatted

type value

float

param format

The format to be followed.

type format

str

returns

formatted axis tick values.

rtype

str

getPointUnderMouse(self, event, curves=None, tolerance=None)

Gets a CurvePoint under the mouse if a point could be found or None.

param event

The event to get the mouse cursor location.

type event

MouseEvent

param curves

The curves to consider to get the point from. Defaults to None, considering all the curves in the plot.

type curves

list[Curve]

param tolerance

The tolerance value to set the pick radius. Defaults to None, considering line maker radius only.

type tolerance

float

returns

The CurvePoint under the mouse.

rtype

CurvePoint

getSelectedPoints(self)

Returns all the selected points from plot.

getTheClosestPoint(self, x, y)

Gets the CurvePoint closest to specified x, y for all visible curves.

param x

The x value.

type x

float

param y

The y value.

type y

float

returns

The closet CurvePoint to the specified x, y values.

rtype

CurvePoint

pan(self, dx, dy)

Translate the axes by the specified dx, dy.

param dx

Differential x value to pan the x-axis by.

type dx

float

param dy

Differential y value to pan the y-axis by.

type dy

float

returns

A reference to the instance XyPlot object on which it was called.

rtype

XyPlot

redrawPlot(self, obj=None, name=None)

Refreshes the plot in gui idle.

selectPoints(self, points)

Selects the specified points in the plot.

param points

The list of points to be selected.

type points

list[Point]

setCursor(self, cursor, iconStrip=False, x=- 1, y=- 1)

Sets the mouse cursor at specified x, y location inside the plot.

param cursor

Cursor file name

type cursor

str

param iconStrip

type iconStrip

bool

param x

The x location in the plot, to set the cursor at.

type x

float

param y

The y location in the plot, to set the cursor at.

type y

float

setSnapping(self, on=True, xgrid=None, ygrid=None, snapPoints=None)

Snap mouse moves to points/lines as the user moves the mouse.

param on

Determines the state of snapping.

type on

bool

param xgrid

Determines whether it snaps to x-axis

type xgrid

bool

param ygrid

Determines whether it snaps to y-axis.

type ygrid

bool

param snapPoints

The points/lines to snap to.

type snapPoints

list[CurvePoints]

returns

A reference to the instance XyPlot object on which it was called.

rtype

XyPlot

zoom(self, factor=1.5, point=None, axis='both')

Rescales the axes by the specified factor at the specified point.

param factor

The zoom factor. if factor > 1 the plot is zoomed out. If factor < 1 the plot is zoomed in.

type factor

float

param point

Specified point to zoom into. Defaults to None, and the plot is scaled at the center.

type point

Point

param axis

The axis to be zoomed into. Defaults to “both”, valid choices are ‘x’ and ‘y’.

type axis

str

returns

A reference to the instance XyPlot object on which it was called.

rtype

XyPlot

zoomAtMouseEvent(self, event)

Rescales the axes by the specified points.

param event

Mouse event to get start end end point of the window box select.

type event

uiMouseEvent

returns

A reference to the instance XyPlot object on which it was called.

rtype

XyPlot