Module gwy :: Class GraphModel
[hide private]
[frames] | no frames]

Class GraphModel

source code

Instance Methods [hide private]
 
__init__()
Creates a new graph model.
source code
 
new_alike()
Creates new graph model object that has the same settings as gmodel.
source code
 
get_n_curves()
Reports the number of curves in a graph model.
source code
 
add_curve(curve)
Adds a new curve to a graph model.
source code
 
remove_curve_by_description(description)
Removes all the curves having same description string as description.
source code
 
remove_curve(cindex)
Removes the curve having given index.
source code
 
get_curve_by_description(description)
Finds a graph curve model in a graph model by its description.
source code
 
get_curve(cindex)
Gets a graph curve model in a graph model by its index.
source code
 
get_curve_index(curve)
Finds the index of a graph model curve.
source code
 
replace_curve(cindex, curve)
Replaces a curve in a graph model.
source code
 
remove_all_curves()
Removes all the curves from graph model
source code
 
append_curves(source, colorstep)
Appends all curves from another graph model to a graph model.
source code
 
set_units_from_data_line(data_line)
Sets x and y graph model units to match a data line.
source code
 
set_units_from_data_field(data_field, power_xy_in_x, power_z_in_x, power_xy_in_y, power_z_in_y)
Sets x and y graph model units to units derived from a data field.
source code
 
units_are_compatible(othergmodel)
Checks if the units of two graph models are compatible.
source code
 
x_data_can_be_logarithmed()
Checks whehter x axis can be lograrithmed.
source code
 
y_data_can_be_logarithmed()
Checks whehter y axis can be lograrithmed.
source code
 
set_axis_label(pos, label)
Sets one axis label of a graph model.
source code
 
get_axis_label(pos)
Gets the label of a one graph model axis.
source code
 
get_x_range()
Gets the abscissa range of a graph.
source code
 
get_y_range()
Gets the ordinate range of a graph.
source code
 
get_ranges(x_logscale, y_logscale)
Gets the log-scale suitable range minima of a graph curve.
source code
 
export_ascii(export_units, export_labels, export_metadata, export_style)
Exports a graph model data to a string.
source code
 
duplicate()
Convenience macro doing gwy_serializable_duplicate() with all the necessary typecasting.
source code
Method Details [hide private]

__init__()
(Constructor)

source code 

Creates a new graph model.

Returns:
New graph model as a GObject. (GraphModel)

new_alike()

source code 

Creates new graph model object that has the same settings as gmodel.

This includes axis/label visibility, actual plotting range, etc. Curves are not duplicated or referenced.

Returns:
New graph model. (GraphModel)

get_n_curves()

source code 

Reports the number of curves in a graph model.

Returns:
Number of curves in graph model. (int)

add_curve(curve)

source code 

Adds a new curve to a graph model.

Parameters:
  • curve - A GraphCurveModel representing the curve to add. (GraphCurveModel)
Returns:
The index of the added curve in gmodel. (int)

remove_curve_by_description(description)

source code 

Removes all the curves having same description string as description.

Parameters:
  • description - Curve description (label). (string)
Returns:
The number of removed curves. (int)

remove_curve(cindex)

source code 

Removes the curve having given index.

Parameters:
  • cindex - Curve index in graph model. (int)

get_curve_by_description(description)

source code 

Finds a graph curve model in a graph model by its description.

Parameters:
  • description - Curve description (label). (string)
Returns:
The first curve that has description (label) given by description (no reference is added). (GraphCurveModel)

get_curve(cindex)

source code 

Gets a graph curve model in a graph model by its index.

Parameters:
  • cindex - Curve index in graph model. (int)
Returns:
The curve with index cindex (no reference is added). (GraphCurveModel)

get_curve_index(curve)

source code 

Finds the index of a graph model curve.

Parameters:
Returns:
The index of curve in gmodel, -1 if it is not present there. (int)

replace_curve(cindex, curve)

source code 

Replaces a curve in a graph model.

Parameters:
  • cindex - Curve index in graph model. (int)
  • curve - A curve model to put into gmodel at position cindex. (GraphCurveModel)

Since: 2.51

append_curves(source, colorstep)

source code 

Appends all curves from another graph model to a graph model.

The colors of the curves can be updated, presumably to continue a preset color sequence. This is controlled by argument colorstep. When colorstep is zero no curve color modification is done. When it is positive, a block of curves of size colorstep is always given the same color, the first color being the first preset color corresponding to the number of curves already in gmodel. So pass colorstep=1 for individual curves, colorstep=2 for couples of curves (e.g. data and fit) that should have the same color, etc.

Parameters:
  • source - Graph model containing the curves to append. (GraphModel)
  • colorstep - Block size for curve color updating. (int)

Since: 2.41

set_units_from_data_line(data_line)

source code 

Sets x and y graph model units to match a data line.

Parameters:
  • data_line - A data line to take units from. (DataLine)

set_units_from_data_field(data_field, power_xy_in_x, power_z_in_x, power_xy_in_y, power_z_in_y)

source code 

Sets x and y graph model units to units derived from a data field.

Parameters:
  • data_field - A data field. (DataField)
  • power_xy_in_x - Power of field's lateral units to appear in graph's abscissa units. (int)
  • power_z_in_x - Power of field's value units to appear in graph's abscissa units. (int)
  • power_xy_in_y - Power of field's lateral units to appear in graph's ordinate units. (int)
  • power_z_in_y - Power of field's value units to appear in graph's ordinate units. (int)

Since: 2.51

units_are_compatible(othergmodel)

source code 

Checks if the units of two graph models are compatible.

This function is useful namely as a pre-check for moving curves between graphs.

Parameters:
Returns:
True if the abscissa and ordinate units of the two graphs are compatible. (bool)

Since: 2.41

x_data_can_be_logarithmed()

source code 

Checks whehter x axis can be lograrithmed.

Returns:
True if all x-values are greater than zero (thus logarithmic display of x-data is feasible). (bool)

y_data_can_be_logarithmed()

source code 

Checks whehter y axis can be lograrithmed.

Returns:
True if all y-values are greater than zero (thus logarithmic display of y-data is feasible). (bool)

set_axis_label(pos, label)

source code 

Sets one axis label of a graph model.

Parameters:
  • pos - Axis position. (GtkPositionType)
  • label - The new label. (string)

get_axis_label(pos)

source code 

Gets the label of a one graph model axis.

Parameters:
  • pos - Axis position. (GtkPositionType)
Returns:
The label as a string owned by the model. (string)

get_x_range()

source code 

Gets the abscissa range of a graph.

Explicitly set minimum and maximum range properties take precedence over values calculated from curve abscissa ranges.

Returns:
Tuple consisting of 3 values (value, x_min, x_max). ((bool), (float), (float))

get_y_range()

source code 

Gets the ordinate range of a graph.

Explicitly set minimum and maximum range properties take precedence over values calculated from curve ordinate ranges.

Returns:
Tuple consisting of 3 values (value, y_min, y_max). ((bool), (float), (float))

get_ranges(x_logscale, y_logscale)

source code 

Gets the log-scale suitable range minima of a graph curve.

See Graph.curve_model_get_ranges() for discussion.

Parameters:
  • x_logscale - True if logarithmical scale is intended for the abscissa. (bool)
  • y_logscale - True if logarithmical scale is intended for the ordinate. (bool)
Returns:
Tuple consisting of 5 values (value, x_min, x_max, y_min, y_max). ((bool), (float), (float), (float), (float))

Since: 2.8

export_ascii(export_units, export_labels, export_metadata, export_style)

source code 

Exports a graph model data to a string.

The export format is specified by parameter export_style.

Parameters:
  • export_units - True to export units in the column header. (bool)
  • export_labels - True to export labels in the column header. (bool)
  • export_metadata - True to export all graph metadata within file header. (bool)
  • export_style - File format subtype to export to (e. g. plain, csv, gnuplot, etc.). Expected values: GRAPH_MODEL_EXPORT_ASCII_PLAIN, GRAPH_MODEL_EXPORT_ASCII_GNUPLOT, GRAPH_MODEL_EXPORT_ASCII_CSV, GRAPH_MODEL_EXPORT_ASCII_ORIGIN, GRAPH_MODEL_EXPORT_ASCII_IGORPRO, GRAPH_MODEL_EXPORT_ASCII_POSIX, GRAPH_MODEL_EXPORT_ASCII_MERGED. (GraphModelExportStyle)
Returns:
Tuple consisting of 2 values (value, string). ((string), (SkipArg))

duplicate()

source code 

Convenience macro doing gwy_serializable_duplicate() with all the necessary typecasting.

Returns:
(GraphModel)