Curve (hwx.gui)#

class Curve(plot, x, y, style=None, color='auto', draggable=False, hoverable=False, onSelected=None, onDrag=None, onModified=None, hoverFormat=5, **kwds)#

Bases: Line

A curved line.

Method Table#

Name

Description

addSlider (self, **kwds)

Adds a curve slider.

clearMemoryCurve (self)

Clears original curve.

delete (self)

Removes this curve from the plot.

formatHoverText (self, x, y)

getNextUnusedColor (self)

Gets next unused color.

getTheClosestPoint (self, x, y)

Gets the closest CurvePoint for the specified x and y.

setHovered (self, points, showText=False, event=None)

Sets the curve points hovered.

setMarkers (self, points, markers, color, showText, event)

setMemoryCurve (self)

Shows original curve when dragging.

setSelected (self, points, showText=False, event=None)

Sets the curve points selected.

Example

from hwx import gui
from hwx.gui.XyPlot import XyPlot
from hwx.gui.XyPlot import Curve

plot = XyPlot(title="Plot with Curves")

# the (x, y) points of the curves
x = [1, 2, 4, 5, 6]
y = [1, 3, 4, 1, 7]
curve1 = Curve(plot, x=x, y=y, draggable=False, label="Curve1")
curve1.color = "red"
curve1.linestyle = "dashed"
# another way to define de curve points
y = ([1, 2, 4, 5, 6], [2, 4, 5, 2, 8])
plot.addCurve(x=x, y=y, draggable=False, label="Curve2")
show(plot)
getNextUnusedColor()#

Gets next unused color.

delete()#

Removes this curve from the plot.

getTheClosestPoint(x, y)#

Gets the closest CurvePoint for the specified x and y.

Parameters:
  • x (float) – Specified x value.

  • y (float) – Specified y value.

Returns:

The closest CurvePoint.

Return type:

CurvePoint

setHovered(points, showText=False, event=None)#

Sets the curve points hovered.

Parameters:
  • points (list[Point]) – The list of points to be set hovered.

  • showText (bool) – Determines whether to show hovered text.

  • event (MouseEvent) – MouseEvent to capture the hover.

setSelected(points, showText=False, event=None)#

Sets the curve points selected.

Parameters:
  • points (list[Point]) – The list of points to be set selected.

  • showText (bool) – Determines whether to show selected text.

  • event (MouseEvent) – MouseEvent to. capture the selection.

addSlider(**kwds)#

Adds a curve slider.

setMemoryCurve()#

Shows original curve when dragging.

clearMemoryCurve()#

Clears original curve.