KlynPlotWidget
classin packageklyn.gui.windows.charts
public class KlynPlotWidget extends Canvas
└ Canvas
└ KlynPlotWidget

Embeddable scientific plot, drawn with the Klyn Painter (2D, pie or 3D scatter). The default style uses a white figure, 5% data margins, outward ticks, a ten-color cycle and point-based line sizes. No external plotting library is needed by applications. In 3D, drag with the left mouse button to rotate, middle to pan and right to zoom. These interactions also work when the plot is embedded in a layout.

chart = KlynPlotWidget()
chart.plot([0.0, 1.0, 2.0], [0.0, 1.0, 4.0], label="square")
window.centralWidget.add(chart)
Properties
Modifier and Type Member Description
public readonly property projection
projection as String
Projection selected at construction: "2d" or "3d".
public readonly property seriesCount
seriesCount as Int
Number of plotted datasets; a pie counts as one.
public property title
title as String
Plot title, distinct from the native window title.
public property xLabel
xLabel as String
Horizontal axis label.
public property yLabel
yLabel as String
Vertical axis label.
public property zLabel
zLabel as String
Third axis label; available on a 3D chart.
Inherited Properties
propertyInherited Properties from Widget: accentColor, acceptFileDrops, backgroundColor, borderColor, bottom, canFocus, cornerRadius, cursor, font, foregroundColor, hasFocus, height, isEnabled, isHovered, isManaged, isPressed, isTabStop, isVisible, layoutParams, margin, maxHeight, maxWidth, minHeight, minWidth, parent, preferredHeight, preferredWidth, resolvedStyleCache, resolvedStyleCacheAppearanceMode, resolvedStyleCacheFont, resolvedStyleCacheRevision, resolvedStyleCacheStateKey, resolvedStyleCacheStyleClass, resolvedStyleCacheZoomRevision, right, size, sizePolicy, styleClass, toolTip, width, window, x, y
Inherited Events
eventInherited Events from Widget: filesDropped, focusGained, focusLost, keyPressed, keyReleased, mouseMoved, mousePressed, mouseReleased, mouseWheel, paintRequested, resized
Constructors
Modifier and Type Member Description
public KlynPlotWidget
KlynPlotWidget(projection as String = "2d")
Creates a 640x480 plot canvas.
Methods
Modifier and Type Member Description
public autoscale
autoscale() as Void
Restores automatic limits on both axes.
public clear
clear() as Void
Removes curves or a pie and resets color cycles and axes.
public colorbar
colorbar(label as String = "", visible as Boolean = true) as Void
Displays the most recently inserted scalar-colored scatter's scale.
public exportImage
exportImage(path as Path, width as Int = 640, height as Int = 480) as Void
Exports the plot without changing its widget geometry.
public grid
grid(visible as Boolean = true) as Void
Shows or hides major grid lines.
public legend
legend(location as String = "best", visible as Boolean = true) as Void
Shows a legend, choosing a low-overlap corner by default.
public override paint
paint(painter as Painter) as Void
Draws into the assigned widget bounds.
public pie
pie(values as IList<Double>, labels as IList<String> = null, explode as IList<Double> = null, autopct as String = "", shadow as Boolean = false, startAngle as Double = 0.0, counterClockwise as Boolean = true, colors as IList<String> = null) as Void
Displays a circular pie from copied, non-negative weights in list order.
public pie
pie(values as NDArray<Double>, labels as IList<String> = null, explode as IList<Double> = null, autopct as String = "", shadow as Boolean = false, startAngle as Double = 0.0, counterClockwise as Boolean = true, colors as IList<String> = null) as Void
Displays a pie from a copied one-dimensional array, with the list overload's options.
public plot
plot(x as IList<Double>, y as IList<Double>, format as String = "", label as String = "", color as String = "", lineWidth as Double = 1.5) as Void
Adds a curve from lists, with the same options as the NDArray overload.
public plot
plot(x as NDArray<Double>, y as NDArray<Double>, format as String = "", label as String = "", color as String = "", lineWidth as Double = 1.5) as Void
Adds a curve from one-dimensional arrays; inputs are copied.
public resetView
resetView() as Void
Restores the default 3D camera, pan and zoom without removing data.
public scatter
scatter(x as IList<Double>, y as IList<Double>, label as String = "", color as String = "", size as Double = 36.0, values as IList<Double> = null, sizes as IList<Double> = null, colorMap as String = "coolwarm", vmin as Double = nan, vmax as Double = nan, sortByValue as Boolean = false) as Void
Adds circular markers from lists.
public scatter
scatter(x as IList<Double>, y as IList<Double>, z as IList<Double>, label as String = "", color as String = "", size as Double = 20.0) as Void
Adds a 3D scatter series from copied lists, with the same options as arrays.
public scatter
scatter(x as NDArray<Double>, y as NDArray<Double>, label as String = "", color as String = "", size as Double = 36.0, values as IList<Double> = null, sizes as IList<Double> = null, colorMap as String = "coolwarm", vmin as Double = nan, vmax as Double = nan, sortByValue as Boolean = false) as Void
Adds circular markers from one-dimensional arrays.
public scatter
scatter(x as NDArray<Double>, y as NDArray<Double>, z as NDArray<Double>, label as String = "", color as String = "", size as Double = 20.0) as Void
Adds a 3D scatter series, copying one-dimensional arrays of equal length.
public scatter
scatter<T>(x as NDArray<T>, y as NDArray<T>, label as String = "", color as String = "", size as Double = 36.0, values as NDArray<T> = null, sizes as NDArray<T> = null, colorMap as String = "coolwarm", vmin as Double = nan, vmax as Double = nan, sortByValue as Boolean = false) as Void
Adds a scatter directly from typed numeric vectors and optional attribute tensors.
public view
view(elevation as Double = 30.0, azimuth as Double = -60.0) as Void
Sets the 3D camera angles in degrees, looking at the centre of the data box.
public xLim
xLim(low as Double, high as Double) as Void
Sets finite increasing x limits.
public yLim
yLim(low as Double, high as Double) as Void
Sets finite increasing y limits.
public zLim
zLim(low as Double, high as Double) as Void
Sets finite increasing z limits on a 3D chart.
Inherited Methods
methodInherited Methods from Widget: applyThemeMetrics, blur, containsPoint, emitFilesDropped, emitFocusGained, emitFocusLost, emitKeyPressed, emitKeyReleased, emitMouseMoved, emitMousePressed, emitMouseReleased, emitMouseWheel, handleTabKey, notifyPaintRequested, paint, paintClipped, paintForeground, paintOverlay, preferredSizeIncludesContentZoom, repaint, requestFocus, resolvePreferredHeight, resolvePreferredWidth, resolvedFont, setBounds