PyKst documentation

PyKst is a python interface to kst. With PyKst, scripts can control and share data with a kst session.

Installation

You will want the version of pykst.py that goes with your version of kst2. Until packaging (and the API) are settled, this may mean compiling kst2 from source.

pykst.py can use either PySide or PyQT4. Make sure one is installed, and edit the begining of pykst.py accordingly (make sure the one you want to use is enabled, and the other is commented out.)

Then run setup.py to install things properly. In linux this is:

sudo python2.7 setup.py install

PyKst depends on python2.7 or greater, and modern versions of NumPy and SciPy.

Examples

PyKst can be used control kst, as one would with the GUI. The following (minimal) example tells kst to plot sin(x) from -10 to 10. The results are identical to having used create->equation from within kst:

import pykst as kst

# start a kst session with the arbitrary name "TestSinX"
client=kst.Client("TestSinX")

# inside kst, create the x vector and the equation
v1 = client.new_generated_vector(-10, 10, 1000)
e1 = client.new_equation(v1, "sin(x)")

# inside kst, create a curve, a plot, and add the curve to the plot
c1 = client.new_curve(e1.x(), e1.y())
p1 = client.new_plot()
p1.add(c1)

kst can be also be used to plot numpy arrays, as in this example:

#!/usr/bin/python2.7
import pykst as kst
import numpy as np

# create a pair of numpy arrays
x = np.linspace( -10, 10, 1000)
y = np.sin(x)

# start a kst session with the arbitrary name "NumpyVector"
client=kst.Client("NumpyVector")

# copy the numpy arrays into kst
V1 = client.new_editable_vector(x, name="X") # the name is for the label
V2 = client.new_editable_vector(y, name="sin(X)") # the name is for the label

# inside kst, create a curve, a plot, and add the curve to the plot
c1 = client.new_curve(V1, V2)
p1 = client.new_plot()
p1.add(c1)

Alternativly, one can use a (tiny) subset of matplotlib.pyplot called pykstplot. This interface is conceptually incompatible with the native interface, and is described at the end of this document. As an example:

#!/usr/bin/python2.7
import pykstplot as plt
#import matplotlib.pyplot as plt
import numpy as np

x = np.linspace( -10, 10, 100)
y = np.sin(x)
z = np.cos(x)

plt.subplot(221)
plt.plot(x,y*y, linewidth=2, color = "green", linestyle="-.", label="greenline")
plt.subplot(122)
plt.plot(x,y,"k.")
plt.subplot(223)
plt.plot(x,z,"m*", markersize=6, color="blue")
plt.subplot(221, axisbg="lightblue")
plt.plot(x,z)
plt.xlabel("X axis")
plt.ylabel("Y axis")
plt.title("Title")

plt.figure()
plt.plot([1,3,7,15])

plt.show()

#plt.savefig("pltdemo.eps")

Clients

class pykst.Client(server_name='')[source]

An interface to a running kst session.

A client provides a connection to a running kst session. The constructor creates a connection to either a running kst session with name <server_name>, or if none exists, a new one. If server_name is not specified, it creates a connection with an unnamed kst session, or if none exists, a new unnamed session.

The Client provides functions which effect the entire kst session, provides convenience functions to create objects within kst (eg, client.new_generated_vector(0, 1, 6)), and provides convenience functions to access objects already within kst (eg, client.vector("V2"). This is the suggested method.

Alternatively, the constructor for every class inside pykst accepts an instance of Client which it uses to interact with a kst session.

To connect to a kst session named kstSession (starting kst if necessary):

import pykst as kst
client = kst.Client("kstSession")
SVG(name)[source]

Returns a SVG from kst given its name.

See SVG

arrow(name)[source]

Returns an Arrow from kst given its name.

See Arrow

box(name)[source]

Returns a Box from kst given its name.

See Box

circle(name)[source]

Returns a Circle from kst given its name.

See Circle

cleanup_layout(columns='Auto')[source]

Cleanup layout in the current tab.

If columns is not set, use auto-layout.

clear()[source]

Clears all objects from kst.

Equivalent to file->close from the menubar inside kst.

count_from_end()[source]

Equivalent to “Range>Count From End” from the menubar inside kst.

curve(name)[source]

Returns a Curve from kst given its name.

See Curve

data_matrix(name)[source]

Returns a DataMatrix from kst given its name.

See DataMatrix

data_vector(name)[source]

Returns a DataVector from kst given its name.

See DataVector

datasource_scalar(name)[source]

Returns a DataSource Scalar from kst given its name.

See DataSourceScalar

datasource_string(name)[source]

Returns a datasource string from kst given its name.

See DataSourceString

editable_matrix(name)[source]

Returns an Editable Matrix from kst given its name.

See EditableMatrix

editable_vector(name)[source]

Returns an Editable Vector from kst given its name.

See EditableVector

ellipse(name)[source]

Returns an ellipse from kst given its name.

See Ellipse

equation(name)[source]

Returns an Equation from kst given its name.

See Equation

export_graphics_file(filename, graphics_format=None, width=1280, height=1024, display=2, all_tabs=False, autosave_period=0)[source]

export the kst session as a set of graphics files.

Parameters:
  • filename – the name of the file to be saved
  • graphics_format – the format to be used. if None, the format is determined from the filename extension.
  • width – width of the plot, in pixels, if required by the display setting.
  • height – the height of the plot, in pixels, if required by the display setting.
  • display – how the dimensions are interpreted.
  • all_tabs – if True, all tabs are exported as <filename>_<tabname>.<ext>
  • autosave_period – save the image every <autosave_period> seconds. If 0, only save once.

display determines the shape of the plot. Values are

0   Width set by user, maintain aspect ratio
1   Height set by user, maintain aspect ratio
2   Width and Height set by user.
3   a Width x Width square plot.
flag_filter(name)[source]

Returns a flag_filter from kst given its name.

See FlagFilter

generated_scalar(name)[source]

Returns a Generated Scalar from kst given its name.

See GeneratedScalar

generated_string(name)[source]

Returns a generated string from kst given its name.

See GeneratedString

generated_vector(name)[source]

Returns a GeneratedVector from kst given its name.

See GeneratedVector

get_SVG_list()[source]

Get a list of all SVGs in kst.

See SVG

get_arrow_list()[source]

Get a list of all arrows in kst.

See Arrow

get_box_list()[source]

Get a list of all boxes in kst.

See Box

get_circle_list()[source]

Get a list of all ciircles in kst.

See Circle

get_data_vector_list()[source]

returns data vectors from kst.

get_editable_vector_list()[source]

returns editable vectors from kst.

get_ellipse_list()[source]

Get a list of all ellipse in kst.

See Ellipse

get_generated_vector_list()[source]

returns generated vectors from kst.

get_label_list()[source]

Get a list of all labels in kst.

See Label

get_legend_list()[source]

Get a list of all legends in kst.

See Legend

get_line_list()[source]

Get a list of all lines in kst.

See Line

get_matrix_list()[source]

returns matrixes from kst.

get_picture_list()[source]

Get a list of all pictures in kst.

See Picture

get_plot_list()[source]

Get a list of all plots in kst.

See Plot

get_scalar_list()[source]

returns the scalar names from kst

get_vector_list()[source]

returns vectors from kst.

hide_window()[source]

Hide the kst window.

pyKst operations which effect the display are far faster when the window is hidden.

Restore with show_window() or maximize_window().

histogram(name)[source]

Returns a histogram from kst given its name.

See Histogram

image(name)[source]

Returns an Image from kst given its name.

See Image

label(name)[source]

Returns a Label from kst given its name.

See Label

legend(name)[source]

Returns a Legend from kst given its name.

See Legend

line(name)[source]

Returns a Line from kst given its name.

See Line

linear_fit(name)[source]

Returns a linear fit from kst given its name.

See LinearFit

maximize_window()[source]

Maximize the kst window.

minimize_window()[source]

Minimize the kst window.

new_SVG(filename, pos=(0.1, 0.1), width=0.1, rot=0, name='')[source]

Create a New SVG in kst.

See SVG

new_arrow(start=(0, 0), end=(1, 1), arror_at_start=False, arrow_at_end=True, arrow_size=12.0, stroke_style=1, stroke_width=1, stroke_brush_color='black', stroke_brush_style=1, stroke_cap_style=1, name='')[source]

Create a New Arrow in kst.

See Arrow

new_box(pos=(0.1, 0.1), size=(0.1, 0.1), rot=0, fill_color='white', fill_style=1, stroke_style=1, stroke_width=1, stroke_brush_color='black', stroke_brush_style=1, stroke_join_style=1, stroke_cap_style=1, fix_aspect=False, name='')[source]

Create a New Box in kst.

See Box

new_circle(pos=(0.1, 0.1), diameter=0.1, fill_color='white', fill_style=1, stroke_style=1, stroke_width=1, stroke_brush_color='grey', stroke_brush_style=1, name='')[source]

Create a New Circle in kst.

See Circle

new_cross_spectrum(V1, V2, fft_size=10, sample_rate=1.0, name='')[source]

Create a cross spectrum object in kst.

See CrossSpectrum

new_curve(x_vector, y_vector, name='')[source]

Create a New Curve in kst.

See Curve

new_data_matrix(filename, field, start_x=0, start_y=0, num_x=-1, num_y=-1, min_x=0, min_y=0, dx=1, dy=1, name='')[source]

Create a New DataMatrix in kst.

See DataMatrix

new_data_vector(filename, field, start=0, num_frames=-1, skip=0, boxcarFirst=False, name='')[source]

Create a New DataVector in kst.

See DataVector

new_datasource_scalar(filename, field, name='')[source]

Create a New DataSource Scalar in kst.

See DataSourceScalar

new_datasource_string(filename, field, name='')[source]

Create a New Data Source String in kst.

See DataSourceString

new_editable_matrix(np_array=None, name='')[source]

Create a New Editable Matrix in kst.

See EditableMatrix

new_editable_vector(np_array=None, name='')[source]

Create a New Editable Vector in kst.

See EditableVector

new_ellipse(pos=(0.1, 0.1), size=(0.1, 0.1), rot=0, fill_color='white', fill_style=1, stroke_style=1, stroke_width=1, stroke_brush_color='black', stroke_brush_style=1, fix_aspect=False, name='')[source]

Create a New Ellipse in kst.

See Ellipse

new_equation(x_vector, equation, interpolate=True, name='')[source]

Create a new Equation in kst.

See Equation

new_flag_filter(y_vector, flag, mask='0xffffff', valid_is_zero=True, name='')[source]

Create a flag filter inside kst.

See FlagFilter

new_generated_scalar(value, name='')[source]

Create a New Generated Scalar in kst.

See GeneratedScalar

new_generated_string(string, name='')[source]

Create a new generated string in kst.

See GeneratedString

new_generated_vector(x0, x1, n, name='')[source]

Create a New GeneratedVector in kst.

See GeneratedVector

new_histogram(vector, bin_min=0, bin_max=1, num_bins=60, normalization=0, auto_bin=True, name='')[source]

Create a new histogram in kst.

See Histogram

new_image(matrix, name='')[source]

Create a new Image in kst.

See Image

new_label(text, pos=(0.5, 0.5), rot=0, font_size=12, bold=False, italic=False, font_color='black', font_family='Serif', name='')[source]

Create a New Label in kst.

See Label

new_legend(plot, name='')[source]

Create a new Legend in a plot in kst.

See :class:’Legend’

new_line(start=(0, 0), end=(1, 1), stroke_style=1, stroke_width=1, stroke_brush_color='black', stroke_brush_style=1, stroke_cap_style=1, name='')[source]

Create a New Line in kst.

See Line

new_linear_fit(x_vector, y_vector, weightvector=0, name='')[source]

Create a New Linear Fit in kst.

See LinearFit

new_picture(filename, pos=(0.1, 0.1), width=0.1, rot=0, name='')[source]

Create a New Picture in kst.

See Picture

new_plot(pos=(0.1, 0.1), size=(0, 0), rot=0, font_size=0, columns=0, fill_color='white', fill_style=1, stroke_style=1, stroke_width=1, stroke_brush_color='black', stroke_brush_style=1, stroke_join_style=1, stroke_cap_style=1, fix_aspect=False, auto_position=True, name='')[source]

Create a New Plot in kst.

See Plot

new_polynomial_fit(order, x_vector, y_vector, weightvector=0, name='')[source]

Create a New Polynomial Fit in kst.

See PolynomialFit

new_spectrum(vector, sample_rate=1.0, interleaved_average=False, fft_length=10, apodize=True, remove_mean=True, vector_units='', rate_units='Hz', apodize_function=0, sigma=1.0, output_type=0, name='')[source]

Create a new Spectrum in kst.

See Spectrum

new_sum_filter(y_vector, step_dX, name='')[source]

Create a cumulative sum filter inside kst.

See SumFilter

new_tab()[source]

Create a new tab in the current document and switch to it.

new_vector_scalar(filename, field, frame=-1, name='')[source]

Create a New VectorScalar in kst.

See VectorScalar

open_kst_file(filename)[source]

open a .kst file in kst.

picture(name)[source]

Returns a Picture from kst given its name.

See Picture

plot(name)[source]

Returns a Plot from kst given its name.

See Plot

polynomial_fit(name)[source]

Returns a polynomial fit from kst given its name.

See PolynomialFit

quit()[source]

Tell the kst window to terminate

After this, client will no longer be valid.

read_to_end()[source]

Equivalent to “Range>Read To End” from the menubar inside kst.

save_kst_file(filename)[source]

save a .kst file in kst.

screen_back()[source]

Equivalent to “Range>Back One Screen” from the menubar inside kst.

screen_forward()[source]

Equivalent to “Range>Forward One Screen” from the menubar inside kst.

set_datasource_option(option, value, filename, data_source='Ascii File')[source]

Sets the value of a data source configuration option.

Parameters:
  • option – the name of the option - eg “”Data Start”
  • value – True or False
  • filename – the name of the file or 0 to set global default
  • data_source – the type of data source

Examples:

Tell kst that trial1.csv is a file with the field names in row 1 and units in row 2:

import pykst as kst
client = kst.Client()
client.set_datasource_option("Column Delimiter", ",", "trial1.csv")
client.set_datasource_option("Column Type", 2, "trial1.csv")
client.set_datasource_option("Data Start", 3-1, "trial1.csv")
client.set_datasource_option("Fields Line", 1-1, "trial1.csv")
client.set_datasource_option("Read Fields", True, "trial1.csv")
client.set_datasource_option("Units Line", 2-1, "trial1.csv")
client.set_datasource_option("Read Units", True, "trial1.csv")

Configuration options supported by the ASCII data source (default) are:

"ASCII Time format"
"Column Delimiter"
"Column Type"
"Column Width"
"Column Width is const"
"Comment Delimiters"
"Data Rate for index"
"Data Start"
"Default INDEX Interpretation"
"Fields Line"
"Filename Pattern"
"Index"
"Limit file buffer size"
"NaN value"
"Read Fields"
"Read Units"
"Size of limited file buffer"
"Units Line"
"Use Dot"
"Use threads when parsing Ascii data"
"date/time offset"
"relative offset"
"updateType"
"use an explicit date/time offset"
"use file time/date as offset"
"use relative file time offset"
set_paused()[source]

Equivalent to checking “Range>Pause” from the menubar inside kst.

set_tab(tab)[source]

Set the index of the current tab.

tab must be greater or equal to 0 and less than tabCount().

set_tab_text(new_name)[source]

Set the text of the current tab.

show_window()[source]

unminimize and show the kst window.

spectrum(name)[source]

Returns a spectrum from kst given its name.

See Spectrum

tab_count()[source]

Get the number of tabs open in the current document.

unset_paused()[source]

Equivalent to unchecking “Range>Pause” from the menubar inside kst.

vector_scalar(name)[source]

Returns a VectorScalar from kst given its name.

See VectorScalar

Primitives

Scalars, Vectors, Matrices, and Strings (Primitives) can be used in your scripts to share data with kst. All methods are pass-by-value: for example, if you get a value of a scalar and change it, the data inside kst is not changed. You need to explicitly call setValue().

Scalars

class pykst.DataSourceScalar(client, filename, field, name='', new=True)[source]

A scalar read from a data source inside kst.

This class represents a scalar you would create via “Create>Scalar>Read from Data Source” from the menubar inside kst.

Parameters:
  • filename – The name of the file/data source to read the scalar from.
  • field – the name of the field in the data source.

To read “CONST1” from the data source “tmp.dat” into kst:

import pykst as kst
client = kst.Client()
x = client.new_datasource_scalar("tmp.dat", "CONST1")
change(filename, field)[source]

Change a DataSource Scalar.

Change the file and field of a DataSourceScalar in kst.

Parameters:
  • filename – The name of the file/data source to read the scalar from.
  • field – the name of the field in the data source.
description_tip()

Returns a string describing the object

field()[source]

Returns the field.

file()[source]

Returns the data source file name.

name()

Returns the name of the object from inside kst.

set_name(name)

Set the name of the object inside kst.

type_str()

Returns the type of the object from inside kst.

value()

Returns the scalar.

class pykst.VectorScalar(client, filename, field, frame=-1, name='', new=True)[source]

A scalar in kst read from a vector from a data source.

This class represents a scalar you would create via “Create>Scalar>Read from vector” from the menubar inside kst.

Parameters:
  • filename – The name of the file/data source to read the scalar from.
  • field – the name of the vector in the data source.
  • frame – which frame of the vector to read the scalar from. frame = -1 (the default) reads from the end of the file.

To read the last value of the vector INDEX from the file “tmp.dat” into kst:

import pykst as kst
client = kst.Client()
x = client.new_vector_scalar("tmp.dat", "INDEX", -1)
change(filename, field, frame)[source]

Change a Vector Scalar in kst.

Change the file, field and frame of a VectorScalar in kst.

Parameters:
  • filename – The name of the file/data source to read the scalar from.
  • field – the name of the vector in the data source.
  • frame – which frame of the vector to read the scalar from. frame = -1 reads from the end of the file.
description_tip()

Returns a string describing the object

field()[source]

Returns the field.

file()[source]

Returns the data source file name.

frame()[source]

Returns the fame.

name()

Returns the name of the object from inside kst.

set_name(name)

Set the name of the object inside kst.

type_str()

Returns the type of the object from inside kst.

value()

Returns the scalar.

class pykst.GeneratedScalar(client, value, name='', new=True)[source]

A scalar constant inside kst.

This class represents a scalar you would create via “Create>Scalar>Generate” from the menubar inside kst.

Parameters:value – the value to assign to the scalar constant.

To import the scalar of value 42 into kst:

import pykst as kst
client = kst.Client()
s = client.new_generated_scalar(42)
description_tip()

Returns a string describing the object

name()

Returns the name of the object from inside kst.

set_name(name)

Set the name of the object inside kst.

set_value(val)[source]

set the value of the string inside kst.

type_str()

Returns the type of the object from inside kst.

value()

Returns the scalar.

Vectors

class pykst.DataVector(client, filename, field, start=0, num_frames=-1, skip=0, boxcarFirst=False, name='', new=True)[source]

A vector in kst, read from a data source.

This class represents a vector you would create via “Create>Vector>Read from Data Source” from the menubar inside kst.

The parameters of this function mirror the parameters within “Create>Vector>Read from Data Source”.

Parameters:
  • filename – The name of the file/data source to read the scalar from.
  • field – the name of the vector in the data source.
  • start – The starting index of the vector. start = -1 for count from end.
  • num_frames – The number of frames to read. num_frames = -1 for read to end.
  • skip – The number of frames per sample read. skip = 0 to read every sample.
  • boxcarFirst – apply a boxcar filter before skiping.

To create a vector from “tmp.dat” with field “INDEX” from frame 3 to frame 10, reading a sample every other frame without a boxcar filter:

import pykst as kst
client = kst.Client()
v = client.new_data_vector("tmp.dat", "INDEX", 3, 10, 2, False)
boxcar_first()[source]

True if boxcar filtering has been applied before skipping.

change(filename, field, start, num_frames, skip, boxcarFirst)[source]

Change the parameters of a data vector.

Parameters:
  • filename – The name of the file/data source to read the scalar from.
  • field – the name of the vector in the data source.
  • start – The starting index of the vector. start = -1 for count from end.
  • num_frames – The number of frames to read. num_frames = -1 for read to end.
  • skip – The number of frames per sample read. skip = 0 to read every sample.
  • boxcarFirst – apply a boxcar filter before skiping.
change_frames(start, num_frames, skip, boxcarFirst)[source]

Change the parameters of a data vector.

Parameters:
  • start – The starting index of the vector. start = -1 for count from end.
  • num_frames – The number of frames to read. num_frames = -1 for read to end.
  • skip – The number of frames per sample read. skip = 0 to read every sample.
  • boxcarFirst – apply a boxcar filter before skiping.
description_tip()

Returns a string describing the object

field()[source]

Returns the fieldname.

filename()[source]

Returns the filename.

get_numpy_array()

get a numpy array which contains the kst vector values

length()

Returns the number of samples in the vector.

max()

Returns the maximum value in the vector.

mean()

Returns the mean of the vector.

min()

Returns the minimum value in the vector.

n_frames()[source]

Returns the number of frames to be read. -1 means read to end.

name()

Returns the name of the object from inside kst.

set_name(name)

Set the name of the object inside kst.

skip()[source]

Returns number of frames to be skipped between samples read.

start()[source]

Returns the index of first frame in the vector. -1 means count from end.

type_str()

Returns the type of the object from inside kst.

value(index)

Returns element i of this vector.

class pykst.GeneratedVector(client, x0=0, x1=1, n=100, name='', new=True)[source]

Create a generated vector in kst.

This class represents a vector you would create via “Create>Vector>Generate” from the menubar inside kst.

Parameters:
  • x0 – The first value in the vector.
  • x1 – The last value in the vector.
  • n – The number of evenly spaced values in the vector.

To create the vector {0, 0.2, 0.4, 0.6, 0.8, 1.0}:

import pykst as kst
client = kst.Client()
v = client.new_generated_vector(0, 1, 6)
change(x0, x1, n)[source]

Change the parameters of a Generated Vector inside kst.

Parameters:
  • x0 – The first value in the vector.
  • x1 – The last value in the vector.
  • n – The number of evenly spaced values in the vector.
description_tip()

Returns a string describing the object

get_numpy_array()

get a numpy array which contains the kst vector values

length()

Returns the number of samples in the vector.

max()

Returns the maximum value in the vector.

mean()

Returns the mean of the vector.

min()

Returns the minimum value in the vector.

name()

Returns the name of the object from inside kst.

set_name(name)

Set the name of the object inside kst.

type_str()

Returns the type of the object from inside kst.

value(index)

Returns element i of this vector.

class pykst.EditableVector(client, np_array=None, name='', new=True)[source]

A vector in kst, which is editable from python.

This vector in kst can be created from a numpy array, (with ‘’load()’‘) or edited point by point (with ‘’setValue()’‘). “Create>Vector>Generate” from the menubar inside kst.

Parameters:np_array – initialize the vector in kst to this (optional) 1D numpy array.

To create a from the num py array np:

import pykst as kst
client = kst.Client()
v = client.new_editable_vector(np)
description_tip()

Returns a string describing the object

get_numpy_array()

get a numpy array which contains the kst vector values

length()

Returns the number of samples in the vector.

load(np_array)[source]

sets the value of the vector to that of the float64 1D np array

max()

Returns the maximum value in the vector.

mean()

Returns the mean of the vector.

min()

Returns the minimum value in the vector.

name()

Returns the name of the object from inside kst.

set_name(name)

Set the name of the object inside kst.

type_str()

Returns the type of the object from inside kst.

value(index)

Returns element i of this vector.

Matrices

class pykst.DataMatrix(client, filename, field, start_x=0, start_y=0, num_x=-1, num_y=-1, min_x=0, min_y=0, dx=1, dy=1, name='', new=True)[source]

Create a Data Matrix which reads from a data source inside kst.

This class represents a matrix you would create via “Create>Vector>Read from Data Source” from the menubar inside kst. The parameters of this function mirror the parameters within “Create>Matrix>Read from Data Source”.

Parameters:
  • filename – The name of the file/data source to read the scalar from.
  • field – the name of the vector in the data source.
  • start_x/start_y – the x/y index to start reading from. start_x/Y = -1 to count from the right/bottom.
  • num_x/num_y – the number of columns/rows to read. num_x/Y = -1 to read to the end.
  • min_x/min_y – Hint to Images of the coordinates corresponding to the the left/bottom of the Matrix
  • dx/dy – Hint to Images of the spacing between points.

To create a matrix from ‘foo.png’ with field ‘1’:

import pykst as kst
client = kst.Client()
v = client.new_data_matrix("foo.png", "1")
change(filename, field, start_x=0, start_y=0, num_x=-1, num_y=-1, min_x=0, min_y=0, dx=1, dy=1)[source]

Change the parameters if a Data Matrix inside kst.

Parameters:
  • filename – The name of the file/data source to read the scalar from.
  • field – the name of the vector in the data source.
  • start_x/start_y – the x/y index to start reading from. start_x/y = -1 to count from the right/bottom.
  • num_x/num_y – the number of columns/rows to read. num_x/Y = -1 to read to the end.
  • min_x/min_y – Hint to Images of the coordinates corresponding to the the left/bottom of the Matrix
  • dx/dy – Hint to Images of the spacing between points.
description_tip()

Returns a string describing the object

dx()

Returns the X spacing of the matrix, for when the matrix is used in an image.

dy()

Returns the Y spacing of the matrix, for when the matrix is used in an image.

field()[source]

Returns the fieldname.

filename()[source]

Returns the filename.

get_numpy_array()

get a numpy array which contains the kst matrix values

height()

Returns the Y dimension of the matrix.

length()

Returns the number of elements in the matrix.

max()

Returns the maximum value in the matrix.

mean()

Returns the mean of the matrix.

min()

Returns the minimum value in the matrix.

min_x()

Returns the minimum X location of the matrix, for when the matrix is used in an image.

min_y()

Returns the minimum X location of the matrix, for when the matrix is used in an image.

name()

Returns the name of the object from inside kst.

set_name(name)

Set the name of the object inside kst.

start_x()[source]

Returns the X index of the matrix in the file

start_y()[source]

Returns the Y index of the matrix in the file

type_str()

Returns the type of the object from inside kst.

value(i_x, i_y)

Returns element (i_x, i_y} of this matrix.

width()

Returns the X dimension of the matrix.

Strings

class pykst.DataSourceString(client, filename, field, name='', new=True)[source]

A string read from a data source inside kst.

This class represents a string you would create via “Create>String>Read from Data Source” from the menubar inside kst.

Parameters:
  • filename – The name of the file/data source to read the string from.
  • field – the name of the field in the data source.

To read “File path” from the data source “tmp.dat” into kst:

import pykst as kst
client = kst.Client()
s = client.new_datasource_string("tmp.dat", "File Path")
change(filename, field)[source]

Change a DataSource String.

Change the file and field of a DataSourceString in kst.

Parameters:
  • filename – The name of the file/data source to read the string from.
  • field – the name of the field in the data source.
description_tip()

Returns a string describing the object

name()

Returns the name of the object from inside kst.

set_name(name)

Set the name of the object inside kst.

type_str()

Returns the type of the object from inside kst.

value()

Returns the string.

class pykst.GeneratedString(client, string, name='', new=True)[source]

A string constant inside kst.

This class represents a string you would create via “Create>String>Generated” from the menubar inside kst.

Parameters:string – The value of the string.

To import the string “Hello World” into kst:

import pykst as kst
client = kst.Client()
s = client.new_generatedString("Hello World")
description_tip()

Returns a string describing the object

name()

Returns the name of the object from inside kst.

set_name(name)

Set the name of the object inside kst.

set_value(val)[source]

set the value of the string inside kst.

type_str()

Returns the type of the object from inside kst.

value()

Returns the string.

Data Objects

Data Objects are objects which transform primitives into other primitives.

Equations

class pykst.Equation(client, xvector, equation, interpolate=True, name='', new=True)[source]

An equation inside kst.

Parameters:
  • xvector – the x vector of the equation
  • equation – the equation

Vectors inside kst are refered to as [vectorname] or [scalarname].

description_tip()

Returns a string describing the object

name()

Returns the name of the object from inside kst.

set_equation(equation)[source]

set the equation of an existing equation

set_inpterpolate(interpolate)[source]

set whether all vectors are interpolated to the highest resolution vector.

set_name(name)

Set the name of the object inside kst.

set_x(xvector)[source]

set the x vector of an existing equation. xvector is a kst vector.

type_str()

Returns the type of the object from inside kst.

x()[source]

a vector containing the x vector

y()[source]

a vector containing the equation

Spectra

class pykst.Spectrum(client, vector, sample_rate=1.0, interleaved_average=False, fft_length=10, apodize=True, remove_mean=True, vector_units='', rate_units='Hz', apodize_function=0, sigma=1.0, output_type=0, name='', new=True)[source]

An spectrum inside kst.

Parameters:
  • vector – the vector to take the spectrum of
  • sample_rate – the sample rate of the vector
  • interleaved_average – average spectra of length fft_length
  • fft_length – the fft is 2^fft_length long if interleaved_average is true.
  • apodize – if true, apodize the vector first
  • remove_mean – if true, remove mean first
  • vector_unints – units of the input vector - for labels.
  • rate_units – the units of the sample rate - for labels.
  • apodize_function – index of the apodization function - see apodize_function()
  • sigma – only used if gausian apodization is selected.
  • output_type – index for the output type - see output_type()

The apodize function is:

0: default          1: Bartlett
2: Window           3: Connes
4: Cosine           5: Gaussian
6: Hamming          7: Hann
8: Welch            9: Uniform

The output type is:

0: Amplitude Spectral Density  1: Power Spectral Density
2: AmplitudeSpectrum           3: Power Spectrum
apodize()[source]

apodize before taking spectra, if set

apodize_function()[source]

the index of the apodize function.

The apodize funcition is:

0: default          1: Bartlett
2: Window           3: Connes
4: Cosine           5: Gaussian
6: Hamming          7: Hann
8: Welch            9: Uniform
description_tip()

Returns a string describing the object

fft_length()[source]

ffts are 2^fft_length() long if interleaved_average is set

gaussian_sigma()[source]

the width, if apodize_funcion_index() is 5 (gaussian).

interleaved_average()[source]

average spectra of length fft_length()

name()

Returns the name of the object from inside kst.

output_type()[source]

the index of the spectrum output type.

The output type is:

0: Amplitude Spectral Density  1: Power Spectral Density
2: AmplitudeSpectrum           3: Power Spectrum
rate_units()[source]

the units of the sample rate. For labels

remove_mean()[source]

remove mean before taking spectra, if set

sample_rate()[source]

the sample rate assumed for the spectra.

set_name(name)

Set the name of the object inside kst.

set_vector(xvector)[source]

set the input vector

type_str()

Returns the type of the object from inside kst.

vector_units()[source]

the units of the input vector. For labels

x()[source]

a vector containing the frequency bins

y()[source]

a vector containing the spectrum

Histograms

class pykst.Histogram(client, vector, bin_min, bin_max, num_bins, normalization=0, auto_bin=False, name='', new=True)[source]

A Histogram inside kst.

Parameters:
  • vector – the vector to take the histogram of
  • bin_min – the low end of the lowest bin
  • bin_max – the high end of the highest bin
  • num_bins – the number of bins
  • normalization – see below
  • auto_bin – if True, set xmin and xmax based on the vector

The normalization types are:

0: Number in the bin     1: Percent in the bin
2: Fraction in the bin   3: Peak is normalized to 1.0
auto_bin()[source]

if True, xmin and xmax are set based on the vector

bin_max()[source]

the high end of the lowest bin

bin_min()[source]

the low end of the lowest bin

change(vector, bin_min, bin_max, num_bins, normalization=0, auto_bin=False)[source]

Change Histogram parameters.

Parameters:
  • vector – the vector to take the histogram of
  • bin_min – the low end of the lowest bin
  • bin_max – the high end of the highest bin
  • num_bins – the number of bins
  • normalization – See Histogram
  • auto_bin – if True, set xmin and xmax based on the vector
description_tip()

Returns a string describing the object

name()

Returns the name of the object from inside kst.

normalization()[source]

how the bins are normalized

See Histogram

num_bins()[source]

the number of bins

set_name(name)

Set the name of the object inside kst.

type_str()

Returns the type of the object from inside kst.

x()[source]

a vector containing the bin centers

y()[source]

a vector containing the histogram values

Linear Fit

class pykst.LinearFit(client, xvector, yvector, weightvector=0, name='', new=True)[source]

A linear fit inside kst.

If weightvector is 0, then the fit is unweighted.

covariance()

a vector containing the Covariance of the fit

description_tip()

Returns a string describing the object

fit()

a vector containing the fit

intercept()[source]

The intercept of the fit.

name()

Returns the name of the object from inside kst.

parameters()

a vector containing the Parameters of the fit

reduced_chi2()

a scalar containing the Parameters of the fit

residuals()

a vector containing the Parameters of the fit

set_name(name)

Set the name of the object inside kst.

slope()[source]

The slope of the fit.

type_str()

Returns the type of the object from inside kst.

Polynomial Fit

class pykst.PolynomialFit(client, order, xvector, yvector, weightvector=0, name='', new=True)[source]

A Polynomial fit inside kst.

Parameters:order – The order of the fit
covariance()

a vector containing the Covariance of the fit

description_tip()

Returns a string describing the object

fit()

a vector containing the fit

name()

Returns the name of the object from inside kst.

parameters()

a vector containing the Parameters of the fit

reduced_chi2()

a scalar containing the Parameters of the fit

residuals()

a vector containing the Parameters of the fit

set_name(name)

Set the name of the object inside kst.

type_str()

Returns the type of the object from inside kst.

Flag Filter

class pykst.FlagFilter(client, yvector, flag, mask='0xffffff', valid_is_zero=True, name='', new=True)[source]

a flagged vector inside kst

The output is the input when flag == 0, or NaN if flag is non-0.

description_tip()

Returns a string describing the object

name()

Returns the name of the object from inside kst.

output()

a vector containing the output of the filter

set_name(name)

Set the name of the object inside kst.

type_str()

Returns the type of the object from inside kst.

Relations

Relations are objects which can be added to a plot.

Curves

class pykst.Curve(client, x_vector, y_vector, name='', new=True)[source]

A Curve inside kst.

This class represents a string you would create via “Create>Curve” from the menubar inside kst. The parameters of this function mirror the parameters within “Create>Curve”.

Parameters:
  • x_vector – The vector which specifies the X coordinates of each point.
  • x_vector – The vector which specifies the Y coordinates of each point.

Use the convenience function in client to create a curve in kst session “client” of vectors v1 and v2:

c1 = client.new_curve(v1, v2)
bar_fill_color()[source]

Returns the bar fill color.

color()[source]

Returns the curve color.

description_tip()

Returns a string describing the object

has_bars()[source]

Returns True if the line has historgram bars.

has_head()[source]

Returns True if the last point has a special marker.

has_lines()[source]

Returns True if the line has lines.

has_points()[source]

Returns True if the line has points.

head_color()[source]

Returns the curve head color.

head_type()[source]

Returns index of the head point type. See set_point_type.

line_style()[source]

Returns the index of the line style. See set_line_style.

line_width()[source]

Returns the width of the line.

max_x()

Returns the max X value of the curve or image.

max_y()

Returns the max Y value of the curve or image.

min_x()

Returns the min X value of the curve or image.

min_y()

Returns the min Y value of the curve or image.

name()

Returns the name of the object from inside kst.

point_density()[source]

Returns the density of points shown. see set_point_density.

point_size()[source]

Returns the size of the points.

point_type()[source]

Returns index of the point type. See set_point_type.

set_bar_fill_color(color)[source]

Set the fill color of the histogram bars, if any.

Colors are given by a name such as red or a hex number such as #FF0000.

set_color(color)[source]

Set the color of the points and lines.

Colors are given by a name such as red or a hex number such as #FF0000.

set_has_bars(has=True)[source]

Set whether histogram bars are drawn.

set_has_head(has=True)[source]

Set whether a point at the head of the line is drawn

set_has_lines(has=True)[source]

Set whether lines are drawn.

set_has_points(has=True)[source]

Set whether individual points are drawn on the curve

set_head_color(color)[source]

Set the color of the Head marker, if any.

Colors are given by a name such as red or a hex number such as #FF0000.

set_head_type(x)[source]

Sets the head point type. See set_point_type for details.

set_line_style(lineStyle)[source]

Sets the line type.

0 is SolidLine, 1 is DashLine, 2 is DotLine, 3 is DashDotLine, and 4 isDashDotDotLine,

set_line_width(x)[source]

Sets the width of the curve’s line.

set_name(name)

Set the name of the object inside kst.

set_point_density(density)[source]

Sets the point density.

When show_points is true, this option can be used to only show a subset of the points, for example, to use point types to discriminate between different curves.. This does not effect ‘lines’, where every point is always connected.

density can be from 0 (all points) to 4.

set_point_size(x)[source]

Sets the size of points, if they are drawn.

set_point_type(point_type)[source]

Sets the point type.

The available point types are:

0:  X                       1: open square
2:  open circle,           3: filled circle
4:  downward open triangle  5: upward open triangle
6:  filled square           7: +
8:  *                       9: downward filled triangle
10: upward filled triangle 11: open diamond
12: filled diamond
set_x_error(vector, vectorminus=0)[source]

Set the X Error flags for the curve.

The error bars are symetric if vectorminus is not set.

set_y_error(vector, vectorminus=0)[source]

Set the Y Error flags for the curve.

The error bars are symetric if vectorminus is not set.

show_edit_dialog()

shows the edit dialog for the curve or image.

type_str()

Returns the type of the object from inside kst.

x_error_vector()[source]

Returns the +x error vector of the curve.

FIXME: should figure out what kind of vector this is and return that.

x_minus_error_vector()[source]

Returns the -x error vector of the curve.

FIXME: should figure out what kind of vector this is and return that.

x_vector()[source]

Returns the x vector of the curve.

FIXME: should figure out what kind of vector this is and return that.

y_error_vector()[source]

Returns the +y error vector of the curve.

FIXME: should figure out what kind of vector this is and return that.

y_minus_error_vector()[source]

Returns the -y error vector of the curve.

FIXME: should figure out what kind of vector this is and return that.

y_vector()[source]

Returns the y vector of the curve.

FIXME: should figure out what kind of vector this is and return that.

Images

class pykst.Image(client, matrix, name='', new=True)[source]

An image inside kst.

This class represents an image you would create via “Create>Image” from the menubar inside kst. The parameters of this function mirror the parameters within “Create>Curve”.

Parameters:matrix – The matrix which defines the image.

Use the convenience function in client to create an image in kst session “client” of Matrix m:

i1 = client.new_image(m)
description_tip()

Returns a string describing the object

max_x()

Returns the max X value of the curve or image.

max_y()

Returns the max Y value of the curve or image.

max_z()[source]

Returns the max Z value of the curve or image.

min_x()

Returns the min X value of the curve or image.

min_y()

Returns the min Y value of the curve or image.

min_z()[source]

Returns the max Z value of the curve or image.

name()

Returns the name of the object from inside kst.

set_auto_range(saturated=0)[source]

Automatically set the z range of the color map

Parameters:saturated – The colormap range is set so that this fraction of the points in the matrix are saturated.

Equal numbers of points are saturated at both ends of the color map.

set_matrix(matrix)[source]

change the matrix which is the source of the image.

set_name(name)

Set the name of the object inside kst.

set_palette(palette)[source]

set the palette, selected by index.

The available palettes are:

0: Grey
1:  Red
2:  Spectrum
3:  EOS-A
4:  EOS-B
5:  8 colors
6:  Cyclical Spectrum

Note: this is not the same order as the dialog.

set_range(zmin, zmax)[source]

sets the z range of the color map.

show_edit_dialog()

shows the edit dialog for the curve or image.

type_str()

Returns the type of the object from inside kst.

Annotations

Annotations along with interactive items (see the next section) can be used to turn kst into a graphing calculator, a tetris client, and maybe even a web browser...

class pykst.Label(client, text, pos=(0.5, 0.5), rot=0, font_size=12, bold=False, italic=False, font_color='black', font_family='Serif', name='', new=True)[source]

A label inside kst.

Parameters:
  • text – the text of the label. Supports scalars, equations, and a LaTeX subset.
  • pos – a 2 element tuple (x, y) specifying the position. (0, 0) is top left. (1, 1) is bottom right.
  • rot – rotation of the label in degrees.
  • font_size – size of the label in points, when the printed at the reference size.
  • font_color – Colors are given by a name such as red or a hex number such as #FF0000.
  • font_family – The font family. eg, TimeNewRoman.

Scalars and scalar equations can be displayed live in labels. When the scalar is updated, the label is updated.

The format is:

Scalar:         [scalarname]         eg [GYRO1:Mean(X4)]
Vector Element: [vectorName[index]]  eg [GYRO1 (V2)[4]]
Equation:       [=equation]          eg [=[GYRO1:Mean(X4)]/[GYRO1:Sigma (X4)]]

These numerical fields can be formatted by appending a C printf format embedded in { } immediately after the field. For example:

[GYRO1:Mean(X4)]{%4.2f}

Labels in kst support a derrivitive subset of LaTeX. For example, to display the equation for the area of a circle, you could set the label to A=2\pir^2. Unlike LaTeX, it is not necessary to enter math mode using $. Also, unlike LaTeX, variables are not automatically displayed in italic font. If desired, this must be done explicitly using \\textit{}.

Greek letters: \\name or \\Name. eg: \\alpha

Other symbols: \\approx, \\cdot, \\ge, \\geq, \\inf, \\approx, \\cdot, \\ge, \\geq, \\inf, \\int, \\le, \\leq, \\ne, \\n, \\partial, \\prod, \\pm, \\sum, \\sqrt

Font effects: \\textcolor{colorname}{colored text}, \\textbf{bold text}, \\textit{italicized text}, \\underline{underlined text}, \\overline{overlined text}.

Other:x^y, x_y, \\t, \\n, \\[

This class represents a label you would create via “Create>Annotations>Label” from the menubar inside kst.

Use the convenience function in Client to create a label “Test Label” in kst:

import pykst as kst
client = kst.Client()
L = client.new_label("Test Label", (0.25, 0.25), font_size=18)
description_tip()

Returns a string describing the object

name()

Returns the name of the object from inside kst.

remove()

This removes the object from Kst.

set_font_bold(bold=True)[source]

. . .

set_font_color(color)[source]

Colors are given by a name such as red or a hex number such as #FF0000

set_font_family(family)[source]

set the font family. eg, TimeNewRoman.

set_font_italic(italic=True)[source]

. . .

set_label_font_size(size)[source]

size of the label in points, when the printed at the reference size.

set_lock_pos_to_data(lock=True)

if lock is True, and the item is in a plot, then the position of the item will be locked to the data coordinates in the plot. The item will move with zooming and scrolling.

If lock is False, or the item is not in a plot, then the item will be fixed to the geometry of the window, and zooming/scrolling will not change its position.

set_name(name)

Set the name of the object inside kst.

set_parent_auto()

Set the parent of the viewitem to an existing view item which fully contains it. Once reparented, moving/resizing the parent will also move/resize the child.

By default view items created by pyKst are parented by the toplevel view unless this method is called, or if the item is moved/resized in the GUI.

set_parent_toplevel()

Set the parent of the viewitem to the toplevel view.

By default view items created by pyKst are parented by the toplevel view unless set_parent_auto() is called, or if the item is moved/resized in the GUI.

set_pos(pos)

Set the center position of the item.

Parameters:pos – a 2 element tuple (x, y) specifying the position. The Top Left of the parent is (0, 0). The Bottom Right of the parent is (1, 1)
set_rotation(rot)

Set the rotation of the item.

This is equivalent to setting Dimensions>Rotation within a view item dialog.

set_text(text)[source]

Set text displayed by the label.

Scalars and scalar equations can be displayed live in labels. When the scalar is updated, the label is updated. The format is:

Scalar:         [scalarname]         eg [GYRO1:Mean(X4)]
Vector Element: [vectorName[index]]  eg [GYRO1 (V2)[4]]
Equation:       [=equation]          eg [=[GYRO1:Mean(X4)]/[GYRO1:Sigma (X4)]]

Labels in kst support a derrivitive subset of LaTeX. For example, to display the equation for the area of a circle, you could set the label to A=2\pir^2. Unlike LaTeX, it is not necessary to enter math mode using $. Also, unlike LaTeX, variables are not automatically displayed in italic font. If desired, this must be done explicitly using \\textit{}.

Greek letters: \\name or \\Name. eg: \\alpha

Other symbols: \\approx, \\cdot, \\ge, \\geq, \\inf, \\approx, \\cdot, \\ge, \\geq, \\inf, \\int, \\le, \\leq, \\ne, \\n, \\partial, \\prod, \\pm, \\sum, \\sqrt

Font effects: \\textcolor{colorname}{colored text}, \\textbf{bold text}, \\textit{italicized text}, \\underline{underlined text}, \\overline{overlined text}.

Other:x^y, x_y, \\t, \\n, \\[

subplot(*args)

Set the item position according to the given grid definition.

Typical call signature:

subplot(nrows, ncols, plot_number)

Where nrows and ncols are used to notionally split the figure into nrows * ncols sub-axes, and plot_number is used to identify the particular subplot that this function is to create within the notional grid. plot_number starts at 1, increments across rows first and has a maximum of nrows * ncols.

In the case when nrows, ncols and plot_number are all less than 10, a convenience exists, such that the a 3 digit number can be given instead, where the hundreds represent nrows, the tens represent ncols and the units represent plot_number. For instance:

subplot(211)

place the plot in the top grid location (i.e. the first) in a 2 row by 1 column notional grid (no grid actually exists, but conceptually this is how the returned subplot has been positioned).

class pykst.Legend(client, plot, name='', new=True)[source]

A legend in a plot in kst.

: param plot: a plot in kst. Use the convenience function in Client to create a legend in kst:

 import pykst as kst
 client = kst.Client()
...
 P1 = client.new_plot()
 L1 = client.new_legend(P1)
description_tip()

Returns a string describing the object

name()

Returns the name of the object from inside kst.

remove()

This removes the object from Kst.

set_fill_color(color)

Set the fill/background color.

Colors are given by a name such as red or a hex number such as #FF0000.

set_fill_style(style)

Set the background fill style.

This is equivalent to setting the index of Apperance>Fill>Style within a view item dialog in kst.:

0:  NoBrush          1:  SolidPattern
2:  Dense1Pattern    3:  Dense2Pattern
4:  Dense3Pattern    5:  Dense4Pattern
6:  Dense5Pattern    7:  Dense6Pattern
8:  Dense7Pattern    9:  HorPattern
11: VerPattern       12: CrossPattern,
13: BDiagPattern     14: FDiagPattern.
set_font_bold(bold=True)[source]

. . .

set_font_color(color)[source]

Colors are given by a name such as red or a hex number such as #FF0000

set_font_family(family)[source]

set the font family. eg, TimeNewRoman.

set_font_italic(italic=True)[source]

. . .

set_font_size(size)[source]

size of the label in points, when the printed at the reference size.

set_lock_pos_to_data(lock=True)

if lock is True, and the item is in a plot, then the position of the item will be locked to the data coordinates in the plot. The item will move with zooming and scrolling.

If lock is False, or the item is not in a plot, then the item will be fixed to the geometry of the window, and zooming/scrolling will not change its position.

set_name(name)

Set the name of the object inside kst.

set_parent_auto()

Set the parent of the viewitem to an existing view item which fully contains it. Once reparented, moving/resizing the parent will also move/resize the child.

By default view items created by pyKst are parented by the toplevel view unless this method is called, or if the item is moved/resized in the GUI.

set_parent_toplevel()

Set the parent of the viewitem to the toplevel view.

By default view items created by pyKst are parented by the toplevel view unless set_parent_auto() is called, or if the item is moved/resized in the GUI.

set_pos(pos)

Set the center position of the item.

Parameters:pos – a 2 element tuple (x, y) specifying the position. The Top Left of the parent is (0, 0). The Bottom Right of the parent is (1, 1)
set_rotation(rot)

Set the rotation of the item.

This is equivalent to setting Dimensions>Rotation within a view item dialog.

set_stroke_brush_color(color)

Set the color for lines for the item.

Colors are given by a name such as red or a hex number such as #FF0000.

set_stroke_brush_style(style)

Set the brush style for lines for the item.

This is equivalent to setting the index of Apperance>Stroke>Brush Style within a view item dialog in kst.

This sets the brush type for lines in the item, and not for the fill, so values other than 1 (SolidPattern) only make sense for wide lines and are rarely used:

0:  NoBrush          1:  SolidPattern
2:  Dense1Pattern    3:  Dense2Pattern
4:  Dense3Pattern    5:  Dense4Pattern
6:  Dense5Pattern    7:  Dense6Pattern
8:  Dense7Pattern    9:  HorPattern
11: VerPattern       12: CrossPattern,
13: BDiagPattern     14: FDiagPattern.
set_stroke_cap_style(style)

Set the cap style for the ends of lines in the item.

This is equivalent to setting the index of Apperance>Stroke>Cap Style within a view item dialog in kst.

0 is FlatCap, 1 is SquareCap, and 2 is RoundCap.

set_stroke_join_style(style)

Set the style by which lines are joined in the item.

This is equivalent to setting the index of Apperance>Stroke>Join Style within a view item dialog in kst.

0 is MiterJoin, 1 is BevelJoin, 2 is RoundJoin, and 3 is SvgMiterJoin.

set_stroke_style(style)

Set the stroke style of lines for the item.

This is equivalent to setting the index of Apperance>Stroke>Style within a view item dialog in kst:

0: SolidLine       1: DashLine
2: DotLine         3: DashDotLine
4: DashDotDotLine  5: CustomDashLine
set_stroke_width(width)

Set the width of lines for the item.

subplot(*args)

Set the item position according to the given grid definition.

Typical call signature:

subplot(nrows, ncols, plot_number)

Where nrows and ncols are used to notionally split the figure into nrows * ncols sub-axes, and plot_number is used to identify the particular subplot that this function is to create within the notional grid. plot_number starts at 1, increments across rows first and has a maximum of nrows * ncols.

In the case when nrows, ncols and plot_number are all less than 10, a convenience exists, such that the a 3 digit number can be given instead, where the hundreds represent nrows, the tens represent ncols and the units represent plot_number. For instance:

subplot(211)

place the plot in the top grid location (i.e. the first) in a 2 row by 1 column notional grid (no grid actually exists, but conceptually this is how the returned subplot has been positioned).

class pykst.Box(client, pos=(0.1, 0.1), size=(0.1, 0.1), rot=0, fill_color='white', fill_style=1, stroke_style=1, stroke_width=1, stroke_brush_color='black', stroke_brush_style=1, stroke_join_style=1, stroke_cap_style=1, fix_aspect=False, name='', new=True)[source]

A floating box inside kst.

Parameters:
  • pos – a 2 element tuple (x, y) specifying the position. (0, 0) is top left. (1, 1) is bottom right.
  • size – a 2 element tuple (w, h) specifying the size. (1, 1) is the size of the window.
  • rotation – rotation of the label in degrees.
  • fill_color – the background color.
  • fill_style – the background fill style. See set_fill_style.
  • stroke_style – see set_stroke_style
  • stroke_width – the pen width for the box outline.
  • stroke_brush_color – the box outline color
  • stroke_brush_style – see set_stroke_brush_style
  • stroke_join_style – see set_stroke_join_style
  • stroke_cap_style – see set_stroke_cap_style
  • fix_aspect – if true, the box will have a fixed aspect ratio.

Colors are given by a name such as red or a hex number such as #FF0000.

This class represents a box you would create via “Create>Annotations>Box” from the menubar inside kst.

Use the convenience function in Client to create a box in kst:

import pykst as kst
client = kst.Client()
...
B = client.new_box((0.25, 0.25), (0.2, 0.1), fill_color="blue")
description_tip()

Returns a string describing the object

name()

Returns the name of the object from inside kst.

remove()

This removes the object from Kst.

set_fill_color(color)

Set the fill/background color.

Colors are given by a name such as red or a hex number such as #FF0000.

set_fill_style(style)

Set the background fill style.

This is equivalent to setting the index of Apperance>Fill>Style within a view item dialog in kst.:

0:  NoBrush          1:  SolidPattern
2:  Dense1Pattern    3:  Dense2Pattern
4:  Dense3Pattern    5:  Dense4Pattern
6:  Dense5Pattern    7:  Dense6Pattern
8:  Dense7Pattern    9:  HorPattern
11: VerPattern       12: CrossPattern,
13: BDiagPattern     14: FDiagPattern.
set_fixed_aspect_ratio(fixed=True)

if True, fix the aspect ratio of the item to its current value.

This is equivalent to checking Dimensions>Fix aspect ratio within a view item dialog in kst.

set_lock_pos_to_data(lock=True)

if lock is True, and the item is in a plot, then the position of the item will be locked to the data coordinates in the plot. The item will move with zooming and scrolling.

If lock is False, or the item is not in a plot, then the item will be fixed to the geometry of the window, and zooming/scrolling will not change its position.

set_name(name)

Set the name of the object inside kst.

set_parent_auto()

Set the parent of the viewitem to an existing view item which fully contains it. Once reparented, moving/resizing the parent will also move/resize the child.

By default view items created by pyKst are parented by the toplevel view unless this method is called, or if the item is moved/resized in the GUI.

set_parent_toplevel()

Set the parent of the viewitem to the toplevel view.

By default view items created by pyKst are parented by the toplevel view unless set_parent_auto() is called, or if the item is moved/resized in the GUI.

set_pos(pos)

Set the center position of the item.

Parameters:pos – a 2 element tuple (x, y) specifying the position. The Top Left of the parent is (0, 0). The Bottom Right of the parent is (1, 1)
set_rotation(rot)

Set the rotation of the item.

This is equivalent to setting Dimensions>Rotation within a view item dialog.

set_size(size)

Set the size of the item.

Parameters:size – a 2 element tuple (w, h) specifying the size.

Elements go from 0 to 1. If the aspect ratio is fixed, then h is ignored.

This is equivalent to setting Dimensions>Position within a view item dialog in kst.

set_stroke_brush_color(color)

Set the color for lines for the item.

Colors are given by a name such as red or a hex number such as #FF0000.

set_stroke_brush_style(style)

Set the brush style for lines for the item.

This is equivalent to setting the index of Apperance>Stroke>Brush Style within a view item dialog in kst.

This sets the brush type for lines in the item, and not for the fill, so values other than 1 (SolidPattern) only make sense for wide lines and are rarely used:

0:  NoBrush          1:  SolidPattern
2:  Dense1Pattern    3:  Dense2Pattern
4:  Dense3Pattern    5:  Dense4Pattern
6:  Dense5Pattern    7:  Dense6Pattern
8:  Dense7Pattern    9:  HorPattern
11: VerPattern       12: CrossPattern,
13: BDiagPattern     14: FDiagPattern.
set_stroke_cap_style(style)

Set the cap style for the ends of lines in the item.

This is equivalent to setting the index of Apperance>Stroke>Cap Style within a view item dialog in kst.

0 is FlatCap, 1 is SquareCap, and 2 is RoundCap.

set_stroke_join_style(style)

Set the style by which lines are joined in the item.

This is equivalent to setting the index of Apperance>Stroke>Join Style within a view item dialog in kst.

0 is MiterJoin, 1 is BevelJoin, 2 is RoundJoin, and 3 is SvgMiterJoin.

set_stroke_style(style)

Set the stroke style of lines for the item.

This is equivalent to setting the index of Apperance>Stroke>Style within a view item dialog in kst:

0: SolidLine       1: DashLine
2: DotLine         3: DashDotLine
4: DashDotDotLine  5: CustomDashLine
set_stroke_width(width)

Set the width of lines for the item.

subplot(*args)

Set the item position according to the given grid definition.

Typical call signature:

subplot(nrows, ncols, plot_number)

Where nrows and ncols are used to notionally split the figure into nrows * ncols sub-axes, and plot_number is used to identify the particular subplot that this function is to create within the notional grid. plot_number starts at 1, increments across rows first and has a maximum of nrows * ncols.

In the case when nrows, ncols and plot_number are all less than 10, a convenience exists, such that the a 3 digit number can be given instead, where the hundreds represent nrows, the tens represent ncols and the units represent plot_number. For instance:

subplot(211)

place the plot in the top grid location (i.e. the first) in a 2 row by 1 column notional grid (no grid actually exists, but conceptually this is how the returned subplot has been positioned).

class pykst.Circle(client, pos=(0.1, 0.1), diameter=0.1, fill_color='white', fill_style=1, stroke_style=1, stroke_width=1, stroke_brush_color='grey', stroke_brush_style=1, name='', new=True)[source]

A floating circle inside kst.

Parameters:
  • pos – a 2 element tuple (x, y) specifying the position. (0, 0) is top left. (1, 1) is bottom right.
  • diameter – the diameter of the circle. 1 is the width of the window.
  • fill_color – the background color.
  • fill_style – the background fill style. See set_fill_style.
  • stroke_style – see set_stroke_style
  • stroke_width – the pen width for the circle outline.
  • stroke_brush_color – the circle outline color
  • stroke_brush_style – see set_stroke_brush_style

Colors are given by a name such as red or a hex number such as #FF0000.

This class represents a circle you would create via “Create>Annotations>Circle” from the menubar inside kst.

Use the convenience function in Client to create a circle in kst:

import pykst as kst
client = kst.Client()
...
Cr = client.new_circle((0.5, 0.5), 0.2, fill_color="red")
description_tip()

Returns a string describing the object

name()

Returns the name of the object from inside kst.

remove()

This removes the object from Kst.

set_diameter(diameter)[source]

set the diamter of the circle.

The width of the window is 1.0.

set_fill_color(color)

Set the fill/background color.

Colors are given by a name such as red or a hex number such as #FF0000.

set_fill_style(style)

Set the background fill style.

This is equivalent to setting the index of Apperance>Fill>Style within a view item dialog in kst.:

0:  NoBrush          1:  SolidPattern
2:  Dense1Pattern    3:  Dense2Pattern
4:  Dense3Pattern    5:  Dense4Pattern
6:  Dense5Pattern    7:  Dense6Pattern
8:  Dense7Pattern    9:  HorPattern
11: VerPattern       12: CrossPattern,
13: BDiagPattern     14: FDiagPattern.
set_lock_pos_to_data(lock=True)

if lock is True, and the item is in a plot, then the position of the item will be locked to the data coordinates in the plot. The item will move with zooming and scrolling.

If lock is False, or the item is not in a plot, then the item will be fixed to the geometry of the window, and zooming/scrolling will not change its position.

set_name(name)

Set the name of the object inside kst.

set_parent_auto()

Set the parent of the viewitem to an existing view item which fully contains it. Once reparented, moving/resizing the parent will also move/resize the child.

By default view items created by pyKst are parented by the toplevel view unless this method is called, or if the item is moved/resized in the GUI.

set_parent_toplevel()

Set the parent of the viewitem to the toplevel view.

By default view items created by pyKst are parented by the toplevel view unless set_parent_auto() is called, or if the item is moved/resized in the GUI.

set_pos(pos)

Set the center position of the item.

Parameters:pos – a 2 element tuple (x, y) specifying the position. The Top Left of the parent is (0, 0). The Bottom Right of the parent is (1, 1)
set_rotation(rot)

Set the rotation of the item.

This is equivalent to setting Dimensions>Rotation within a view item dialog.

set_stroke_brush_color(color)

Set the color for lines for the item.

Colors are given by a name such as red or a hex number such as #FF0000.

set_stroke_brush_style(style)

Set the brush style for lines for the item.

This is equivalent to setting the index of Apperance>Stroke>Brush Style within a view item dialog in kst.

This sets the brush type for lines in the item, and not for the fill, so values other than 1 (SolidPattern) only make sense for wide lines and are rarely used:

0:  NoBrush          1:  SolidPattern
2:  Dense1Pattern    3:  Dense2Pattern
4:  Dense3Pattern    5:  Dense4Pattern
6:  Dense5Pattern    7:  Dense6Pattern
8:  Dense7Pattern    9:  HorPattern
11: VerPattern       12: CrossPattern,
13: BDiagPattern     14: FDiagPattern.
set_stroke_style(style)

Set the stroke style of lines for the item.

This is equivalent to setting the index of Apperance>Stroke>Style within a view item dialog in kst:

0: SolidLine       1: DashLine
2: DotLine         3: DashDotLine
4: DashDotDotLine  5: CustomDashLine
set_stroke_width(width)

Set the width of lines for the item.

subplot(*args)

Set the item position according to the given grid definition.

Typical call signature:

subplot(nrows, ncols, plot_number)

Where nrows and ncols are used to notionally split the figure into nrows * ncols sub-axes, and plot_number is used to identify the particular subplot that this function is to create within the notional grid. plot_number starts at 1, increments across rows first and has a maximum of nrows * ncols.

In the case when nrows, ncols and plot_number are all less than 10, a convenience exists, such that the a 3 digit number can be given instead, where the hundreds represent nrows, the tens represent ncols and the units represent plot_number. For instance:

subplot(211)

place the plot in the top grid location (i.e. the first) in a 2 row by 1 column notional grid (no grid actually exists, but conceptually this is how the returned subplot has been positioned).

class pykst.Ellipse(client, pos=(0.1, 0.1), size=(0.1, 0.1), rot=0, fill_color='white', fill_style=1, stroke_style=1, stroke_width=1, stroke_brush_color='black', stroke_brush_style=1, fix_aspect=False, name='', new=True)[source]

A floating ellipse inside kst.

Parameters:
  • pos – a 2 element tuple (x, y) specifying the position. (0, 0) is top left. (1, 1) is bottom right.
  • size – a 2 element tuple (w, h) specifying the size. (1, 1) is the size of the window.
  • fill_color – the background color.
  • fill_style – the background fill style. See set_fill_style.
  • stroke_style – see set_stroke_style
  • stroke_width – the pen width for the ellipse outline.
  • stroke_brush_color – the ellipse outline color
  • stroke_brush_style – see set_stroke_brush_style

Colors are given by a name such as red or a hex number such as #FF0000.

This class represents an ellipse you would create via “Create>Annotations>Ellipse” from the menubar inside kst.

Use the convenience function in Client to create an Ellipse in kst:

import pykst as kst
client = kst.Client()
...
E = client.new_ellipse((0.25, 0.25), (0.2, 0.1), fill_color="green")
description_tip()

Returns a string describing the object

name()

Returns the name of the object from inside kst.

remove()

This removes the object from Kst.

set_fill_color(color)

Set the fill/background color.

Colors are given by a name such as red or a hex number such as #FF0000.

set_fill_style(style)

Set the background fill style.

This is equivalent to setting the index of Apperance>Fill>Style within a view item dialog in kst.:

0:  NoBrush          1:  SolidPattern
2:  Dense1Pattern    3:  Dense2Pattern
4:  Dense3Pattern    5:  Dense4Pattern
6:  Dense5Pattern    7:  Dense6Pattern
8:  Dense7Pattern    9:  HorPattern
11: VerPattern       12: CrossPattern,
13: BDiagPattern     14: FDiagPattern.
set_fixed_aspect_ratio(fixed=True)

if True, fix the aspect ratio of the item to its current value.

This is equivalent to checking Dimensions>Fix aspect ratio within a view item dialog in kst.

set_lock_pos_to_data(lock=True)

if lock is True, and the item is in a plot, then the position of the item will be locked to the data coordinates in the plot. The item will move with zooming and scrolling.

If lock is False, or the item is not in a plot, then the item will be fixed to the geometry of the window, and zooming/scrolling will not change its position.

set_name(name)

Set the name of the object inside kst.

set_parent_auto()

Set the parent of the viewitem to an existing view item which fully contains it. Once reparented, moving/resizing the parent will also move/resize the child.

By default view items created by pyKst are parented by the toplevel view unless this method is called, or if the item is moved/resized in the GUI.

set_parent_toplevel()

Set the parent of the viewitem to the toplevel view.

By default view items created by pyKst are parented by the toplevel view unless set_parent_auto() is called, or if the item is moved/resized in the GUI.

set_pos(pos)

Set the center position of the item.

Parameters:pos – a 2 element tuple (x, y) specifying the position. The Top Left of the parent is (0, 0). The Bottom Right of the parent is (1, 1)
set_rotation(rot)

Set the rotation of the item.

This is equivalent to setting Dimensions>Rotation within a view item dialog.

set_size(size)

Set the size of the item.

Parameters:size – a 2 element tuple (w, h) specifying the size.

Elements go from 0 to 1. If the aspect ratio is fixed, then h is ignored.

This is equivalent to setting Dimensions>Position within a view item dialog in kst.

set_stroke_brush_color(color)

Set the color for lines for the item.

Colors are given by a name such as red or a hex number such as #FF0000.

set_stroke_brush_style(style)

Set the brush style for lines for the item.

This is equivalent to setting the index of Apperance>Stroke>Brush Style within a view item dialog in kst.

This sets the brush type for lines in the item, and not for the fill, so values other than 1 (SolidPattern) only make sense for wide lines and are rarely used:

0:  NoBrush          1:  SolidPattern
2:  Dense1Pattern    3:  Dense2Pattern
4:  Dense3Pattern    5:  Dense4Pattern
6:  Dense5Pattern    7:  Dense6Pattern
8:  Dense7Pattern    9:  HorPattern
11: VerPattern       12: CrossPattern,
13: BDiagPattern     14: FDiagPattern.
set_stroke_style(style)

Set the stroke style of lines for the item.

This is equivalent to setting the index of Apperance>Stroke>Style within a view item dialog in kst:

0: SolidLine       1: DashLine
2: DotLine         3: DashDotLine
4: DashDotDotLine  5: CustomDashLine
set_stroke_width(width)

Set the width of lines for the item.

subplot(*args)

Set the item position according to the given grid definition.

Typical call signature:

subplot(nrows, ncols, plot_number)

Where nrows and ncols are used to notionally split the figure into nrows * ncols sub-axes, and plot_number is used to identify the particular subplot that this function is to create within the notional grid. plot_number starts at 1, increments across rows first and has a maximum of nrows * ncols.

In the case when nrows, ncols and plot_number are all less than 10, a convenience exists, such that the a 3 digit number can be given instead, where the hundreds represent nrows, the tens represent ncols and the units represent plot_number. For instance:

subplot(211)

place the plot in the top grid location (i.e. the first) in a 2 row by 1 column notional grid (no grid actually exists, but conceptually this is how the returned subplot has been positioned).

class pykst.Line(client, start=(0, 0), end=(1, 1), stroke_style=1, stroke_width=1, stroke_brush_color='black', stroke_brush_style=1, stroke_cap_style=1, name='', new=True)[source]

A floating line inside kst.

Parameters:
  • start – a 2 element tuple (x, y) specifying the position of the start of the line. (0, 0) is top left of the window, and (1, 1) is bottom right.
  • end – a 2 element tuple (x, y) specifying the position of the end of the line. (0, 0) is top left of the window, and (1, 1) is bottom right.
  • length – The length of the line. 1 is the width of the window.
  • rot – rotation of the line in degrees.
  • stroke_style – see set_stroke_style
  • stroke_width – the pen width for the ellipse outline.
  • stroke_brush_color – the ellipse outline color
  • stroke_brush_style – see set_stroke_brush_style
  • stroke_cap_style – see set_stroke_cap_style

Colors are given by a name such as red or a hex number such as #FF0000.

This class represents a line you would create via “Create>Annotations>Line” from the menubar inside kst.

Colors are given by a name such as red or a hex number such as #FF0000”.

Use the convenience function in Client to create a line in kst:

import pykst as kst
client = kst.Client()
...
Ln = client.new_line((0.25, 0.25), (0.5, 0.5))
description_tip()

Returns a string describing the object

name()

Returns the name of the object from inside kst.

remove()

This removes the object from Kst.

set_endpoints(start=(0, 0), end=(1, 1))[source]

set the endpoints of the line.

If lock_pos_to_data has been set True, and the item parent is a plot, then the coordinates are in terms the data’s coordinates. Otherwise, the coordinates, between 0 and 1, are relative to the dimensions of the parent object.

set_length(length)[source]

set the length of the line.

The length, between 0 and 1, is as a fraction of the width of the parent item.

set_lock_pos_to_data(lock=True)

if lock is True, and the item is in a plot, then the position of the item will be locked to the data coordinates in the plot. The item will move with zooming and scrolling.

If lock is False, or the item is not in a plot, then the item will be fixed to the geometry of the window, and zooming/scrolling will not change its position.

set_name(name)

Set the name of the object inside kst.

set_parent_auto()

Set the parent of the viewitem to an existing view item which fully contains it. Once reparented, moving/resizing the parent will also move/resize the child.

By default view items created by pyKst are parented by the toplevel view unless this method is called, or if the item is moved/resized in the GUI.

set_parent_toplevel()

Set the parent of the viewitem to the toplevel view.

By default view items created by pyKst are parented by the toplevel view unless set_parent_auto() is called, or if the item is moved/resized in the GUI.

set_pos(pos)

Set the center position of the item.

Parameters:pos – a 2 element tuple (x, y) specifying the position. The Top Left of the parent is (0, 0). The Bottom Right of the parent is (1, 1)
set_rotation(rot)

Set the rotation of the item.

This is equivalent to setting Dimensions>Rotation within a view item dialog.

set_stroke_brush_color(color)

Set the color for lines for the item.

Colors are given by a name such as red or a hex number such as #FF0000.

set_stroke_brush_style(style)

Set the brush style for lines for the item.

This is equivalent to setting the index of Apperance>Stroke>Brush Style within a view item dialog in kst.

This sets the brush type for lines in the item, and not for the fill, so values other than 1 (SolidPattern) only make sense for wide lines and are rarely used:

0:  NoBrush          1:  SolidPattern
2:  Dense1Pattern    3:  Dense2Pattern
4:  Dense3Pattern    5:  Dense4Pattern
6:  Dense5Pattern    7:  Dense6Pattern
8:  Dense7Pattern    9:  HorPattern
11: VerPattern       12: CrossPattern,
13: BDiagPattern     14: FDiagPattern.
set_stroke_cap_style(style)

Set the cap style for the ends of lines in the item.

This is equivalent to setting the index of Apperance>Stroke>Cap Style within a view item dialog in kst.

0 is FlatCap, 1 is SquareCap, and 2 is RoundCap.

set_stroke_style(style)

Set the stroke style of lines for the item.

This is equivalent to setting the index of Apperance>Stroke>Style within a view item dialog in kst:

0: SolidLine       1: DashLine
2: DotLine         3: DashDotLine
4: DashDotDotLine  5: CustomDashLine
set_stroke_width(width)

Set the width of lines for the item.

subplot(*args)

Set the item position according to the given grid definition.

Typical call signature:

subplot(nrows, ncols, plot_number)

Where nrows and ncols are used to notionally split the figure into nrows * ncols sub-axes, and plot_number is used to identify the particular subplot that this function is to create within the notional grid. plot_number starts at 1, increments across rows first and has a maximum of nrows * ncols.

In the case when nrows, ncols and plot_number are all less than 10, a convenience exists, such that the a 3 digit number can be given instead, where the hundreds represent nrows, the tens represent ncols and the units represent plot_number. For instance:

subplot(211)

place the plot in the top grid location (i.e. the first) in a 2 row by 1 column notional grid (no grid actually exists, but conceptually this is how the returned subplot has been positioned).

class pykst.Arrow(client, start=(0, 0), end=(1, 1), arror_at_start=False, arrow_at_end=True, arrow_size=12.0, stroke_style=1, stroke_width=1, stroke_brush_color='black', stroke_brush_style=1, stroke_cap_style=1, name='', new=True)[source]

A floating arrow inside kst.

Parameters:
  • pos – a 2 element tuple (x, y) specifying the position of the center of the line. (0, 0) is top left. (1, 1) is bottom right.
  • length – The length of the line. 1 is the width of the window.
  • rot – rotation of the line in degrees.
  • arror_at_start – if True, draw an arrow at the start of the line.
  • arrow_at_end – if True, draw an arrow at the end of the line.
  • arrow_size – the size of the arrow.
  • stroke_style – see set_stroke_style.
  • stroke_width – the pen width for the ellipse outline.
  • stroke_brush_color – the ellipse outline color
  • stroke_brush_style – see set_stroke_brush_style
  • stroke_cap_style – see set_stroke_cap_style

Colors are given by a name such as red or a hex number such as #FF0000.

This class represents an arrow you would create via “Create>Annotations>Arrow” from the menubar inside kst.

Use the convenience function in Client to create an arrow in kst:

import pykst as kst
client = kst.Client()
...
Ln = client.new_arrow((0.25, 0.25), 0.2, rot=15, arror_at_start=True)
description_tip()

Returns a string describing the object

name()

Returns the name of the object from inside kst.

remove()

This removes the object from Kst.

set_arrow_at_end(arrow=True)[source]

Set whether an arrow head is shown at the end of the line

set_arrow_at_start(arrow=True)[source]

Set whether an arrow head is shown at the start of the line

set_endpoints(start=(0, 0), end=(1, 1))[source]

set the endpoints of the arrow.

If lock_pos_to_data has been set True, and the item parent is a plot, then the coordinates are in terms the data’s coordinates. Otherwise, the coordinates, between 0 and 1, are relative to the dimensions of the parent object.

set_length(length)[source]

set the length of the line.

The width of the window is 1.0.

set_lock_pos_to_data(lock=True)

if lock is True, and the item is in a plot, then the position of the item will be locked to the data coordinates in the plot. The item will move with zooming and scrolling.

If lock is False, or the item is not in a plot, then the item will be fixed to the geometry of the window, and zooming/scrolling will not change its position.

set_name(name)

Set the name of the object inside kst.

set_parent_auto()

Set the parent of the viewitem to an existing view item which fully contains it. Once reparented, moving/resizing the parent will also move/resize the child.

By default view items created by pyKst are parented by the toplevel view unless this method is called, or if the item is moved/resized in the GUI.

set_parent_toplevel()

Set the parent of the viewitem to the toplevel view.

By default view items created by pyKst are parented by the toplevel view unless set_parent_auto() is called, or if the item is moved/resized in the GUI.

set_pos(pos)

Set the center position of the item.

Parameters:pos – a 2 element tuple (x, y) specifying the position. The Top Left of the parent is (0, 0). The Bottom Right of the parent is (1, 1)
set_rotation(rot)

Set the rotation of the item.

This is equivalent to setting Dimensions>Rotation within a view item dialog.

set_stroke_brush_color(color)

Set the color for lines for the item.

Colors are given by a name such as red or a hex number such as #FF0000.

set_stroke_brush_style(style)

Set the brush style for lines for the item.

This is equivalent to setting the index of Apperance>Stroke>Brush Style within a view item dialog in kst.

This sets the brush type for lines in the item, and not for the fill, so values other than 1 (SolidPattern) only make sense for wide lines and are rarely used:

0:  NoBrush          1:  SolidPattern
2:  Dense1Pattern    3:  Dense2Pattern
4:  Dense3Pattern    5:  Dense4Pattern
6:  Dense5Pattern    7:  Dense6Pattern
8:  Dense7Pattern    9:  HorPattern
11: VerPattern       12: CrossPattern,
13: BDiagPattern     14: FDiagPattern.
set_stroke_cap_style(style)

Set the cap style for the ends of lines in the item.

This is equivalent to setting the index of Apperance>Stroke>Cap Style within a view item dialog in kst.

0 is FlatCap, 1 is SquareCap, and 2 is RoundCap.

set_stroke_style(style)

Set the stroke style of lines for the item.

This is equivalent to setting the index of Apperance>Stroke>Style within a view item dialog in kst:

0: SolidLine       1: DashLine
2: DotLine         3: DashDotLine
4: DashDotDotLine  5: CustomDashLine
set_stroke_width(width)

Set the width of lines for the item.

subplot(*args)

Set the item position according to the given grid definition.

Typical call signature:

subplot(nrows, ncols, plot_number)

Where nrows and ncols are used to notionally split the figure into nrows * ncols sub-axes, and plot_number is used to identify the particular subplot that this function is to create within the notional grid. plot_number starts at 1, increments across rows first and has a maximum of nrows * ncols.

In the case when nrows, ncols and plot_number are all less than 10, a convenience exists, such that the a 3 digit number can be given instead, where the hundreds represent nrows, the tens represent ncols and the units represent plot_number. For instance:

subplot(211)

place the plot in the top grid location (i.e. the first) in a 2 row by 1 column notional grid (no grid actually exists, but conceptually this is how the returned subplot has been positioned).

class pykst.Picture(client, filename, pos=(0.1, 0.1), width=0.1, rot=0, name='', new=True)[source]

A floating image inside kst.

Parameters:
  • filename – the file which holds the image to be shown.
  • pos – a 2 element tuple (x, y) specifying the position of the center of the picture. (0, 0) is top left. (1, 1) is bottom right.
  • width – The width of the picture. 1 is the width of the window.
  • rot – rotation of the picture in degrees.

This class represents a picture you would create via “Create>Annotations>Picture” from the menubar inside kst.

Use the convenience function in Client to create a picture in kst:

import pykst as kst
client = kst.Client()
...
pic = client.new_picture("image.jpg", (0.25, 0.25), 0.2)

BUG: the aspect ratio of the picture is wrong.

description_tip()

Returns a string describing the object

name()

Returns the name of the object from inside kst.

remove()

This removes the object from Kst.

set_fixed_aspect_ratio(fixed=True)

if True, fix the aspect ratio of the item to its current value.

This is equivalent to checking Dimensions>Fix aspect ratio within a view item dialog in kst.

set_lock_pos_to_data(lock=True)

if lock is True, and the item is in a plot, then the position of the item will be locked to the data coordinates in the plot. The item will move with zooming and scrolling.

If lock is False, or the item is not in a plot, then the item will be fixed to the geometry of the window, and zooming/scrolling will not change its position.

set_name(name)

Set the name of the object inside kst.

set_parent_auto()

Set the parent of the viewitem to an existing view item which fully contains it. Once reparented, moving/resizing the parent will also move/resize the child.

By default view items created by pyKst are parented by the toplevel view unless this method is called, or if the item is moved/resized in the GUI.

set_parent_toplevel()

Set the parent of the viewitem to the toplevel view.

By default view items created by pyKst are parented by the toplevel view unless set_parent_auto() is called, or if the item is moved/resized in the GUI.

set_picture(pic)[source]

BUG: aspect ratio is not changed. There is no parellel for this function within the kst GUI.

set_pos(pos)

Set the center position of the item.

Parameters:pos – a 2 element tuple (x, y) specifying the position. The Top Left of the parent is (0, 0). The Bottom Right of the parent is (1, 1)
set_rotation(rot)

Set the rotation of the item.

This is equivalent to setting Dimensions>Rotation within a view item dialog.

set_size(size)

Set the size of the item.

Parameters:size – a 2 element tuple (w, h) specifying the size.

Elements go from 0 to 1. If the aspect ratio is fixed, then h is ignored.

This is equivalent to setting Dimensions>Position within a view item dialog in kst.

set_width(width)[source]

set the width of the picture.

The width of the window is 1.0.

subplot(*args)

Set the item position according to the given grid definition.

Typical call signature:

subplot(nrows, ncols, plot_number)

Where nrows and ncols are used to notionally split the figure into nrows * ncols sub-axes, and plot_number is used to identify the particular subplot that this function is to create within the notional grid. plot_number starts at 1, increments across rows first and has a maximum of nrows * ncols.

In the case when nrows, ncols and plot_number are all less than 10, a convenience exists, such that the a 3 digit number can be given instead, where the hundreds represent nrows, the tens represent ncols and the units represent plot_number. For instance:

subplot(211)

place the plot in the top grid location (i.e. the first) in a 2 row by 1 column notional grid (no grid actually exists, but conceptually this is how the returned subplot has been positioned).

class pykst.SVG(client, filename, pos=(0.1, 0.1), width=0.1, rot=0, name='', new=True)[source]

A floating svg image inside kst.

Parameters:
  • filename – the file which holds the svg image to be shown.
  • pos – a 2 element tuple (x, y) specifying the position of the center of the picture. (0, 0) is top left. (1, 1) is bottom right.
  • width – The width of the picture. 1 is the width of the window.
  • rot – rotation of the picture in degrees.

This class represents a picture you would create via “Create>Annotations>SVG” from the menubar inside kst.

Use the convenience function in Client to create an SVG picture in kst:

import pykst as kst
client = kst.Client()
...
svg1 = client.new_SVG("image.svg", (0.25, 0.25), 0.2)
description_tip()

Returns a string describing the object

name()

Returns the name of the object from inside kst.

remove()

This removes the object from Kst.

set_fixed_aspect_ratio(fixed=True)

if True, fix the aspect ratio of the item to its current value.

This is equivalent to checking Dimensions>Fix aspect ratio within a view item dialog in kst.

set_lock_pos_to_data(lock=True)

if lock is True, and the item is in a plot, then the position of the item will be locked to the data coordinates in the plot. The item will move with zooming and scrolling.

If lock is False, or the item is not in a plot, then the item will be fixed to the geometry of the window, and zooming/scrolling will not change its position.

set_name(name)

Set the name of the object inside kst.

set_parent_auto()

Set the parent of the viewitem to an existing view item which fully contains it. Once reparented, moving/resizing the parent will also move/resize the child.

By default view items created by pyKst are parented by the toplevel view unless this method is called, or if the item is moved/resized in the GUI.

set_parent_toplevel()

Set the parent of the viewitem to the toplevel view.

By default view items created by pyKst are parented by the toplevel view unless set_parent_auto() is called, or if the item is moved/resized in the GUI.

set_pos(pos)

Set the center position of the item.

Parameters:pos – a 2 element tuple (x, y) specifying the position. The Top Left of the parent is (0, 0). The Bottom Right of the parent is (1, 1)
set_rotation(rot)

Set the rotation of the item.

This is equivalent to setting Dimensions>Rotation within a view item dialog.

set_size(size)

Set the size of the item.

Parameters:size – a 2 element tuple (w, h) specifying the size.

Elements go from 0 to 1. If the aspect ratio is fixed, then h is ignored.

This is equivalent to setting Dimensions>Position within a view item dialog in kst.

set_width(width)[source]

set the width of the picture.

The width of the window is 1.0.

subplot(*args)

Set the item position according to the given grid definition.

Typical call signature:

subplot(nrows, ncols, plot_number)

Where nrows and ncols are used to notionally split the figure into nrows * ncols sub-axes, and plot_number is used to identify the particular subplot that this function is to create within the notional grid. plot_number starts at 1, increments across rows first and has a maximum of nrows * ncols.

In the case when nrows, ncols and plot_number are all less than 10, a convenience exists, such that the a 3 digit number can be given instead, where the hundreds represent nrows, the tens represent ncols and the units represent plot_number. For instance:

subplot(211)

place the plot in the top grid location (i.e. the first) in a 2 row by 1 column notional grid (no grid actually exists, but conceptually this is how the returned subplot has been positioned).

class pykst.Plot(client, pos=(0, 0), size=(0, 0), rot=0, font_size=0, columns=0, fill_color='white', fill_style=1, stroke_style=1, stroke_width=1, stroke_brush_color='black', stroke_brush_style=1, stroke_join_style=1, stroke_cap_style=1, fix_aspect=False, auto_position=True, name='', new=True)[source]

A plot inside kst.

Parameters:
  • pos – a 2 element tuple (x, y) specifying the position. (0, 0) is top left. (1, 1) is bottom right.
  • size – a 2 element tuple (w, h) specifying the size. (1, 1) is the size of the window.
  • font_size – font size for labels in the plot. kst default if 0.
  • rotation – rotation of the label in degrees.
  • columns – auto-place the plot, reformatting into this many columns.
  • fill_color – the background color.
  • fill_style – the background fill style. See set_fill_style.
  • stroke_style – see set_stroke_style
  • stroke_width – the pen width for the plot outline.
  • stroke_brush_color – the plot outline color
  • stroke_brush_style – see set_stroke_brush_style
  • stroke_join_style – see set_stroke_join_style
  • stroke_cap_style – see set_stroke_cap_style
  • fix_aspect – if true, the plot will have a fixed aspect ratio.
  • auto_postion – if True (the default) the plot will be auto-placed. Ignored if pos is set.

Colors are given by a name such as red or a hex number such as #FF0000.

This class represents a Plot you would create via “Create>Annotations>Plot” from the menubar inside kst.

To create an plot in kst and plot a curve curve1:

import pykst as kst
client = kst.Client()
...
P1 = client.new_plot((0.25, 0.25), (0.5, 0.5))
P1.add(curve1)
add(relation)[source]

Add a curve or an image to the plot.

clear_x_axis_interpretation()[source]

do not intepret the x axis as time

description_tip()

Returns a string describing the object

name()

Returns the name of the object from inside kst.

normalize_x_to_y()[source]

Adjust the X zoom range so X and Y have the same scale per unit (square pixels)

remove()

This removes the object from Kst.

set_bottom_label(label='')[source]

Set the plot bottom label

set_bottom_label_auto()[source]

Set the bottom label to auto generated.

set_fill_color(color)

Set the fill/background color.

Colors are given by a name such as red or a hex number such as #FF0000.

set_fill_style(style)

Set the background fill style.

This is equivalent to setting the index of Apperance>Fill>Style within a view item dialog in kst.:

0:  NoBrush          1:  SolidPattern
2:  Dense1Pattern    3:  Dense2Pattern
4:  Dense3Pattern    5:  Dense4Pattern
6:  Dense5Pattern    7:  Dense6Pattern
8:  Dense7Pattern    9:  HorPattern
11: VerPattern       12: CrossPattern,
13: BDiagPattern     14: FDiagPattern.
set_fixed_aspect_ratio(fixed=True)

if True, fix the aspect ratio of the item to its current value.

This is equivalent to checking Dimensions>Fix aspect ratio within a view item dialog in kst.

set_global_font(family='', font_size=0, bold=False, italic=False)[source]

Set the global plot font.

By default, the axis labels all use this, unless they have been set to use their own.

If the parameter ‘family’ is empty, the font family will be unchanged. If the parameter ‘font_size’ is 0, the font size will be unchanged. The font will be bold if parameter ‘bold’ is set to ‘bold’ or ‘True’. The font will be italic if parameter ‘italic’ is set to ‘italic’ or ‘True’.

set_left_label(label='')[source]

Set the plot left label

set_left_label_auto()[source]

Set the left label to auto generated.

set_lock_pos_to_data(lock=True)

if lock is True, and the item is in a plot, then the position of the item will be locked to the data coordinates in the plot. The item will move with zooming and scrolling.

If lock is False, or the item is not in a plot, then the item will be fixed to the geometry of the window, and zooming/scrolling will not change its position.

set_log_x(log_mode=True)[source]

Set X axis to log mode.

set_log_y(log_mode=True)[source]

Set Y axis to log mode.

set_name(name)

Set the name of the object inside kst.

set_parent_auto()

Set the parent of the viewitem to an existing view item which fully contains it. Once reparented, moving/resizing the parent will also move/resize the child.

By default view items created by pyKst are parented by the toplevel view unless this method is called, or if the item is moved/resized in the GUI.

set_parent_toplevel()

Set the parent of the viewitem to the toplevel view.

By default view items created by pyKst are parented by the toplevel view unless set_parent_auto() is called, or if the item is moved/resized in the GUI.

set_pos(pos)

Set the center position of the item.

Parameters:pos – a 2 element tuple (x, y) specifying the position. The Top Left of the parent is (0, 0). The Bottom Right of the parent is (1, 1)
set_right_label(label='')[source]

Set the plot right label

set_right_label_auto()[source]

Set the right label to auto generated.

set_rotation(rot)

Set the rotation of the item.

This is equivalent to setting Dimensions>Rotation within a view item dialog.

set_size(size)

Set the size of the item.

Parameters:size – a 2 element tuple (w, h) specifying the size.

Elements go from 0 to 1. If the aspect ratio is fixed, then h is ignored.

This is equivalent to setting Dimensions>Position within a view item dialog in kst.

set_stroke_brush_color(color)

Set the color for lines for the item.

Colors are given by a name such as red or a hex number such as #FF0000.

set_stroke_brush_style(style)

Set the brush style for lines for the item.

This is equivalent to setting the index of Apperance>Stroke>Brush Style within a view item dialog in kst.

This sets the brush type for lines in the item, and not for the fill, so values other than 1 (SolidPattern) only make sense for wide lines and are rarely used:

0:  NoBrush          1:  SolidPattern
2:  Dense1Pattern    3:  Dense2Pattern
4:  Dense3Pattern    5:  Dense4Pattern
6:  Dense5Pattern    7:  Dense6Pattern
8:  Dense7Pattern    9:  HorPattern
11: VerPattern       12: CrossPattern,
13: BDiagPattern     14: FDiagPattern.
set_stroke_cap_style(style)

Set the cap style for the ends of lines in the item.

This is equivalent to setting the index of Apperance>Stroke>Cap Style within a view item dialog in kst.

0 is FlatCap, 1 is SquareCap, and 2 is RoundCap.

set_stroke_join_style(style)

Set the style by which lines are joined in the item.

This is equivalent to setting the index of Apperance>Stroke>Join Style within a view item dialog in kst.

0 is MiterJoin, 1 is BevelJoin, 2 is RoundJoin, and 3 is SvgMiterJoin.

set_stroke_style(style)

Set the stroke style of lines for the item.

This is equivalent to setting the index of Apperance>Stroke>Style within a view item dialog in kst:

0: SolidLine       1: DashLine
2: DotLine         3: DashDotLine
4: DashDotDotLine  5: CustomDashLine
set_stroke_width(width)

Set the width of lines for the item.

set_top_label(label='')[source]

Set the plot top label

set_top_label_auto()[source]

Set the top label to auto generated.

set_x_ac(r)[source]

Set X zoom range to fixed range, centered around the mean.

Similar to AC coupling on an oscilloscope.

set_x_auto()[source]

Set X zoom range to autoscale

set_x_auto_border()[source]

Set X zoom range to autoscale with a small border

set_x_axis_display(display='yyyy/MM/dd h:mm:ss ap')[source]

if the x axis has been interpreted as time, set the display.

Display Types:

year:              display the decimal year
qttextdtehhmmss:   <Qt Text Date> HH:MM:SS.SS
qtlocaldatehhmmss: <Qt Local Date> HH:MM:SS.SS
jd:                Julian Date
mjd:               Modified Julian Date
All others:        custom format

The custom format is defined as:

d         the day as number without a leading zero (1 to 31)
dd        the day as number with a leading zero (01 to 31)
ddd       the abbreviated localized day name (e.g. 'Mon' to 'Sun').
          Uses the system locale to localize the name, i.e. QLocale::system().
dddd      the long localized day name (e.g. 'Monday' to 'Qt::Sunday').
          Uses the system locale to localize the name, i.e. QLocale::system().
M         the month as number without a leading zero (1-12)
MM        the month as number with a leading zero (01-12)
MMM       the abbreviated localized month name (e.g. 'Jan' to 'Dec').
          Uses the system locale to localize the name, i.e. QLocale::system().
MMMM      the long localized month name (e.g. 'January' to 'December').
          Uses the system locale to localize the name, i.e. QLocale::system().
yy        the year as two digit number (00-99)
yyyy      the year as four digit number
h         the hour without a leading zero (0 to 23 or 1 to 12 if AM/PM display)
hh        the hour with a leading zero (00 to 23 or 01 to 12 if AM/PM display)
H         the hour without a leading zero (0 to 23, even with AM/PM display)
HH        the hour with a leading zero (00 to 23, even with AM/PM display)
m         the minute without a leading zero (0 to 59)
mm        the minute with a leading zero (00 to 59)
s         the second without a leading zero (0 to 59)
ss        the second with a leading zero (00 to 59)
z         the milliseconds without leading zeroes (0 to 999)
zzz       the milliseconds with leading zeroes (000 to 999)
AP or A   use AM/PM display. A/AP will be replaced by either "AM" or "PM".
ap or a   use am/pm display. a/ap will be replaced by either "am" or "pm".
t         the timezone (for example "CEST")
set_x_axis_interpretation(interp='ctime')[source]

Interpret the x axis as time

Parameters:interp – interpret the time as follows

interp can be:

ctime: Standard unix C time
year:  Decimal year
jd:    Julian Date
mjd:   Modified Julian Date
excel: Time as used by MS Excel
set_x_axis_reversed(reversed=True)[source]

set the X axis to decreasing from left to right.

set_x_no_spike()[source]

Set X zoom range to spike insensitive autoscale

set_x_range(x0, x1)[source]

Set X zoom range from x0 to x1

set_y_ac(r)[source]

Set Y zoom range to fixed range, centered around the mean.

Similar to AC coupling on an oscilloscope.

set_y_auto()[source]

Set Y zoom range to autoscale

set_y_auto_border()[source]

Set Y zoom range to autoscale with a small border

set_y_axis_reversed(axis_reversed=True)[source]

set the Y axis to decreasing from bottom to top.

set_y_no_spike()[source]

Set Y zoom range to spike insensitive autoscale

set_y_range(y0, y1)[source]

Set Y zoom range from y0 to y1

subplot(*args)

Set the item position according to the given grid definition.

Typical call signature:

subplot(nrows, ncols, plot_number)

Where nrows and ncols are used to notionally split the figure into nrows * ncols sub-axes, and plot_number is used to identify the particular subplot that this function is to create within the notional grid. plot_number starts at 1, increments across rows first and has a maximum of nrows * ncols.

In the case when nrows, ncols and plot_number are all less than 10, a convenience exists, such that the a 3 digit number can be given instead, where the hundreds represent nrows, the tens represent ncols and the units represent plot_number. For instance:

subplot(211)

place the plot in the top grid location (i.e. the first) in a 2 row by 1 column notional grid (no grid actually exists, but conceptually this is how the returned subplot has been positioned).

Interactive items

Interactive items are controls which are part of a kst view and use QtNetwork.QLocalSocket to notify the script when the user has interacted with them. They can only be created through scripts.

class pykst.Button(client, text, socket, posX=0.1, posY=0.1, sizeX=0.1, sizeY=0.1, rot=0)[source]

This represents a button inside a View. When the button is pressed, it sends a message via a socket.

socket is a QtNetwork.QLocalSocket that is not connected to anything. The message “clicked” will be sent when the button is pressed. See the bonjourMonde example.

description_tip()

Returns a string describing the object

name()

Returns the name of the object from inside kst.

remove()

This removes the object from Kst.

set_fill_color(color)

Set the fill/background color.

Colors are given by a name such as red or a hex number such as #FF0000.

set_fill_style(style)

Set the background fill style.

This is equivalent to setting the index of Apperance>Fill>Style within a view item dialog in kst.:

0:  NoBrush          1:  SolidPattern
2:  Dense1Pattern    3:  Dense2Pattern
4:  Dense3Pattern    5:  Dense4Pattern
6:  Dense5Pattern    7:  Dense6Pattern
8:  Dense7Pattern    9:  HorPattern
11: VerPattern       12: CrossPattern,
13: BDiagPattern     14: FDiagPattern.
set_fixed_aspect_ratio(fixed=True)

if True, fix the aspect ratio of the item to its current value.

This is equivalent to checking Dimensions>Fix aspect ratio within a view item dialog in kst.

set_lock_pos_to_data(lock=True)

if lock is True, and the item is in a plot, then the position of the item will be locked to the data coordinates in the plot. The item will move with zooming and scrolling.

If lock is False, or the item is not in a plot, then the item will be fixed to the geometry of the window, and zooming/scrolling will not change its position.

set_name(name)

Set the name of the object inside kst.

set_parent_auto()

Set the parent of the viewitem to an existing view item which fully contains it. Once reparented, moving/resizing the parent will also move/resize the child.

By default view items created by pyKst are parented by the toplevel view unless this method is called, or if the item is moved/resized in the GUI.

set_parent_toplevel()

Set the parent of the viewitem to the toplevel view.

By default view items created by pyKst are parented by the toplevel view unless set_parent_auto() is called, or if the item is moved/resized in the GUI.

set_pos(pos)

Set the center position of the item.

Parameters:pos – a 2 element tuple (x, y) specifying the position. The Top Left of the parent is (0, 0). The Bottom Right of the parent is (1, 1)
set_rotation(rot)

Set the rotation of the item.

This is equivalent to setting Dimensions>Rotation within a view item dialog.

set_size(size)

Set the size of the item.

Parameters:size – a 2 element tuple (w, h) specifying the size.

Elements go from 0 to 1. If the aspect ratio is fixed, then h is ignored.

This is equivalent to setting Dimensions>Position within a view item dialog in kst.

set_stroke_brush_color(color)

Set the color for lines for the item.

Colors are given by a name such as red or a hex number such as #FF0000.

set_stroke_brush_style(style)

Set the brush style for lines for the item.

This is equivalent to setting the index of Apperance>Stroke>Brush Style within a view item dialog in kst.

This sets the brush type for lines in the item, and not for the fill, so values other than 1 (SolidPattern) only make sense for wide lines and are rarely used:

0:  NoBrush          1:  SolidPattern
2:  Dense1Pattern    3:  Dense2Pattern
4:  Dense3Pattern    5:  Dense4Pattern
6:  Dense5Pattern    7:  Dense6Pattern
8:  Dense7Pattern    9:  HorPattern
11: VerPattern       12: CrossPattern,
13: BDiagPattern     14: FDiagPattern.
set_stroke_cap_style(style)

Set the cap style for the ends of lines in the item.

This is equivalent to setting the index of Apperance>Stroke>Cap Style within a view item dialog in kst.

0 is FlatCap, 1 is SquareCap, and 2 is RoundCap.

set_stroke_join_style(style)

Set the style by which lines are joined in the item.

This is equivalent to setting the index of Apperance>Stroke>Join Style within a view item dialog in kst.

0 is MiterJoin, 1 is BevelJoin, 2 is RoundJoin, and 3 is SvgMiterJoin.

set_stroke_style(style)

Set the stroke style of lines for the item.

This is equivalent to setting the index of Apperance>Stroke>Style within a view item dialog in kst:

0: SolidLine       1: DashLine
2: DotLine         3: DashDotLine
4: DashDotDotLine  5: CustomDashLine
set_stroke_width(width)

Set the width of lines for the item.

set_text(text)[source]

Sets the text of the button.

subplot(*args)

Set the item position according to the given grid definition.

Typical call signature:

subplot(nrows, ncols, plot_number)

Where nrows and ncols are used to notionally split the figure into nrows * ncols sub-axes, and plot_number is used to identify the particular subplot that this function is to create within the notional grid. plot_number starts at 1, increments across rows first and has a maximum of nrows * ncols.

In the case when nrows, ncols and plot_number are all less than 10, a convenience exists, such that the a 3 digit number can be given instead, where the hundreds represent nrows, the tens represent ncols and the units represent plot_number. For instance:

subplot(211)

place the plot in the top grid location (i.e. the first) in a 2 row by 1 column notional grid (no grid actually exists, but conceptually this is how the returned subplot has been positioned).

class pykst.LineEdit(client, text, socket, posX=0.1, posY=0.1, sizeX=0.1, sizeY=0.1, rot=0)[source]

This represents a line edit inside a View. When the lineedit’s value is changed, it sends a message via a socket.

socket is a QtNetwork.QLocalSocket that is not connected to anything. The message “valueSet:VAL” where VAL is some text will be sent when the text is changed. See the ksNspire example.

description_tip()

Returns a string describing the object

name()

Returns the name of the object from inside kst.

remove()

This removes the object from Kst.

set_fill_color(color)

Set the fill/background color.

Colors are given by a name such as red or a hex number such as #FF0000.

set_fill_style(style)

Set the background fill style.

This is equivalent to setting the index of Apperance>Fill>Style within a view item dialog in kst.:

0:  NoBrush          1:  SolidPattern
2:  Dense1Pattern    3:  Dense2Pattern
4:  Dense3Pattern    5:  Dense4Pattern
6:  Dense5Pattern    7:  Dense6Pattern
8:  Dense7Pattern    9:  HorPattern
11: VerPattern       12: CrossPattern,
13: BDiagPattern     14: FDiagPattern.
set_fixed_aspect_ratio(fixed=True)

if True, fix the aspect ratio of the item to its current value.

This is equivalent to checking Dimensions>Fix aspect ratio within a view item dialog in kst.

set_lock_pos_to_data(lock=True)

if lock is True, and the item is in a plot, then the position of the item will be locked to the data coordinates in the plot. The item will move with zooming and scrolling.

If lock is False, or the item is not in a plot, then the item will be fixed to the geometry of the window, and zooming/scrolling will not change its position.

set_name(name)

Set the name of the object inside kst.

set_parent_auto()

Set the parent of the viewitem to an existing view item which fully contains it. Once reparented, moving/resizing the parent will also move/resize the child.

By default view items created by pyKst are parented by the toplevel view unless this method is called, or if the item is moved/resized in the GUI.

set_parent_toplevel()

Set the parent of the viewitem to the toplevel view.

By default view items created by pyKst are parented by the toplevel view unless set_parent_auto() is called, or if the item is moved/resized in the GUI.

set_pos(pos)

Set the center position of the item.

Parameters:pos – a 2 element tuple (x, y) specifying the position. The Top Left of the parent is (0, 0). The Bottom Right of the parent is (1, 1)
set_rotation(rot)

Set the rotation of the item.

This is equivalent to setting Dimensions>Rotation within a view item dialog.

set_size(size)

Set the size of the item.

Parameters:size – a 2 element tuple (w, h) specifying the size.

Elements go from 0 to 1. If the aspect ratio is fixed, then h is ignored.

This is equivalent to setting Dimensions>Position within a view item dialog in kst.

set_stroke_brush_color(color)

Set the color for lines for the item.

Colors are given by a name such as red or a hex number such as #FF0000.

set_stroke_brush_style(style)

Set the brush style for lines for the item.

This is equivalent to setting the index of Apperance>Stroke>Brush Style within a view item dialog in kst.

This sets the brush type for lines in the item, and not for the fill, so values other than 1 (SolidPattern) only make sense for wide lines and are rarely used:

0:  NoBrush          1:  SolidPattern
2:  Dense1Pattern    3:  Dense2Pattern
4:  Dense3Pattern    5:  Dense4Pattern
6:  Dense5Pattern    7:  Dense6Pattern
8:  Dense7Pattern    9:  HorPattern
11: VerPattern       12: CrossPattern,
13: BDiagPattern     14: FDiagPattern.
set_stroke_cap_style(style)

Set the cap style for the ends of lines in the item.

This is equivalent to setting the index of Apperance>Stroke>Cap Style within a view item dialog in kst.

0 is FlatCap, 1 is SquareCap, and 2 is RoundCap.

set_stroke_join_style(style)

Set the style by which lines are joined in the item.

This is equivalent to setting the index of Apperance>Stroke>Join Style within a view item dialog in kst.

0 is MiterJoin, 1 is BevelJoin, 2 is RoundJoin, and 3 is SvgMiterJoin.

set_stroke_style(style)

Set the stroke style of lines for the item.

This is equivalent to setting the index of Apperance>Stroke>Style within a view item dialog in kst:

0: SolidLine       1: DashLine
2: DotLine         3: DashDotLine
4: DashDotDotLine  5: CustomDashLine
set_stroke_width(width)

Set the width of lines for the item.

set_text(text)[source]

Sets the text of the line edit.

subplot(*args)

Set the item position according to the given grid definition.

Typical call signature:

subplot(nrows, ncols, plot_number)

Where nrows and ncols are used to notionally split the figure into nrows * ncols sub-axes, and plot_number is used to identify the particular subplot that this function is to create within the notional grid. plot_number starts at 1, increments across rows first and has a maximum of nrows * ncols.

In the case when nrows, ncols and plot_number are all less than 10, a convenience exists, such that the a 3 digit number can be given instead, where the hundreds represent nrows, the tens represent ncols and the units represent plot_number. For instance:

subplot(211)

place the plot in the top grid location (i.e. the first) in a 2 row by 1 column notional grid (no grid actually exists, but conceptually this is how the returned subplot has been positioned).

Pykstplot

pykstplot re-implements a tiny subset of matplotlib.pyplot. It is included by importing pykstplot, and is conceptually incompatible with pykst.

pykstplot.figure()[source]

Creates a new tab in kst.

pykstplot.loglog(*args, **kwargs)[source]

Add a curve to the current axis (or make a new one) with log-log scaling. All parameters are the same as plot().

pykstplot.plot(*args, **kwargs)[source]

Plot lines and/or markers to a kst window. args is a variable length argument, allowing for multiple x, y pairs with an optional format string. For example, each of the following is legal:

plot(x, y)        # plot x and y using default line style and color
plot(x, y, 'bo')  # plot x and y using blue circle markers
plot(y)           # plot y using x as index array 0..N-1
plot(y, 'r+')     # ditto, but with red plusses

An arbitrary number of x, y, fmt groups can be specified, as in:

a.plot(x1, y1, 'g^', x2, y2, 'g-')

By default, each line is assigned a different color in kst.

The following format string characters are accepted to control the line style or marker:

character description
'-' solid line style
'--' dashed line style
'-.' dash-dot line style
':' dotted line style
'.' point marker
',' pixel marker
'o' circle marker
'v' triangle_down marker
'^' triangle_up marker
's' square marker
'*' star marker
'+' plus marker
'x' x marker
'D' diamond marker

The following color abbreviations are supported:

character color
‘b’ blue
‘g’ green
‘r’ red
‘c’ cyan
‘m’ magenta
‘y’ yellow
‘k’ black
‘w’ white

Line styles and colors are combined in a single format string, as in 'bo' for blue circles.

The kwargs can be used to set the color, the line width, the line type, and the legend label. You can specify colors using full names ('green'), or hex strings ('#008000').

Some examples:

plot([1,2,3], [1,2,3], 'go-', label='line 1', linewidth=2)
plot([1,2,3], [1,4,9], 'rs',  label='line 2')
axis([0, 4, 0, 10])
legend()

If you make multiple lines with one plot command, the kwargs apply to all those lines, e.g.:

plot(x1, y1, x2, y2, linewidth=2)

Both lines will have a width of 2.

You do not need to use format strings, which are just abbreviations. All of the line properties can be controlled by keyword arguments. For example, you can set the color, marker, linestyle, and markercolor with:

plot(x, y, color='green', linestyle='dashed', marker='o',
color='blue', markersize=12).

Supported kwargs are:

color
label
linestyle
linewidth
markersize
pykstplot.savefig(fname, **kwargs)[source]

Export the kst session as a series of graphics files. If there is only 1 tab, then the file will be called fname. If there are multiple tabs, the files will be called, for example, fname_1.png, fname_2.png, etc.

The plot will be have the same aspect ratio as the kst session, and, for pixel based formats, will be 1280 pixels wide.

The format is determined by the format kwarg, or by the fname extension if format is not defined.

All formats supported by kst are supported, including, among many others, png, jpg, eps, svg, and pdf.

pykstplot.semilogx(*args, **kwargs)[source]

Add a curve to the current axis (or make a new one) with log scaling on the X axis. All parameters are the same as plot().

pykstplot.semilogy(*args, **kwargs)[source]

Add a curve to the current axis (or make a new one) with log scaling on the Y axis. All parameters are the same as plot().

pykstplot.show()[source]

This method does nothing, but exists for compatibility with matplotlib scripts.

pykstplot.subplot(*args, **kwargs)[source]

Return a subplot axes positioned by the given grid definition.

Typical call signature:

subplot(nrows, ncols, plot_number)

Where nrows and ncols are used to notionally split the figure into nrows * ncols sub-axes, and plot_number is used to identify the particular subplot that this function is to create within the notional grid. plot_number starts at 1, increments across rows first and has a maximum of nrows * ncols.

In the case when nrows, ncols and plot_number are all less than 10, a convenience exists, such that the a 3 digit number can be given instead, where the hundreds represent nrows, the tens represent ncols and the units represent plot_number. For instance:

subplot(211)

produces a subaxes in a figure which represents the top plot (i.e. the first) in a 2 row by 1 column notional grid (no grid actually exists, but conceptually this is how the returned subplot has been positioned).

Note

unlike matplotlib.pyplot.subplot(), creating a new subplot with a position which is entirely inside a pre-existing axes will not delete the previous plot.

Keyword arguments:

axisbg:
The background color of the subplot, which can be any valid color specifier.
pykstplot.title(s)[source]

Set the top axis label of the current axis.

pykstplot.xlabel(s)[source]

Set the x axis label of the current axis.

pykstplot.ylabel(s)[source]

Set the y axis label of the current axis.