flap.plot¶
Created on Sat May 18 18:37:06 2019
@author: Zoletnik @coauthor: Lampert
- class flap.plot.PddType(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)¶
Bases:
EnumEnum class for identifying the plot data type.
Possible values:
‘Coordinate’ = 0
‘Constant’ = 1
‘Data’ = 2
- Constant = 1¶
- Coordinate = 0¶
- Data = 2¶
- class flap.plot.PlotAnimation(ax_list, axes, d, xdata, ydata, tdata, xdata_range, ydata_range, cmap_obj, contour_levels, coord_t, coord_x, coord_y, cmap, options, xrange, yrange, zrange, image_like, plot_options, language, plot_id, gs)¶
Bases:
object- animate()¶
- animate_plot(it)¶
- class flap.plot.PlotDataDescription(data_type=None, data_object=None, value=None)¶
Bases:
objectPlot axis description for use in
PlotID()andplot().- Parameters:
- data_typeflap.PddType, optional, default=None
PddType.Coordinate: A coordinate in data_object.
PddType.Constant: A float constant, stored in value.
PddType.Data: The data in self.data_object.
- data_objectflap.DataObject, optional, default=None
The data object from which the data for this coordinate originates. This may be None if the data is constant.
- valueflap.Coordinate, optional, default=None
Value, see above.
- axis_label()¶
Generate label for axis based on the plot data type.
- Returns:
- str
The label.
- get_data(plot_error, data_index=None)¶
Get data for plot.
- Parameters:
- plot_errorbool
If True, the error is also calculated.
- data_indextuple or list, optional, default=None
Index into the data array if the data type is PddType.Data.
- Returns:
- plot_datanp.ndarray
The data to plot.
- plot_errornp.ndarray
If plot_error is True, the calculated error.
- class flap.plot.PlotID¶
Bases:
objectClass for storing identifying and other information about the plot.
- Attributes:
- figureint
The figure number where the plot resides.
- base_subplotmatplotlib.pyplot.AxesSubplot
The subplot containing the whole plot.
- plot_typestr
The plot type string.
- plot_subtypeint
Subtype is dependent on the plot type. It marks various versions, e.g. real-complex.
- number_of_plotsint
Number of plot calls which generated this.
- axeslist
The axes list. Each element is a
Unitand describes one axis of the plot.- plot_datalist
The description of the axis data. This is a list of self.number_of_plots lists. Each inner list is a list of PlotDataDescriptions.
- plt_axis_listlist
The list of Axes which can be used for plotting into the individual plots. If there is only a single plot, base_subplot is the same as
plt_axis_list[0].- optionslist
These are a list of the options to plot.
- check_axes(d, axes, clear=True, default_axes=None, force=False)¶
Check whether the required plot axes are correct, present and compatible with the self PlotID.
- Parameters:
- dflap.DataObject
The data object to check against.
- axeslist | None
List of the required axes or None as input to plot().
- clearbool, optional, default=True
If True, the plot will be cleared, therefore the axes in the PlotID are irrelevant.
- default_axeslist of str, optional, default=None
The default axes desired for this type of plot.
- forcebool, optional, default=False
Force accepting incompatibe axes.
- Returns:
- pdd_listlist of flap.PlotDataDescription
List of objects which can be used to generate the plot.
- ax_listlist of flap.Unit
Axis list which can be put into axes in self.
- clear()¶
Clear the parameters of the plot, but do not clear the base_subplot and figure.
- flap.plot.axes_to_pdd_list(d, axes)¶
Convert a plot() axes parameter to a list of PlotAxisDescription and axes list for PlotID.
- Parameters:
- dflap.DataObject
The data object.
- axeslist of str
Axes parameter of plot().
- Returns:
- pdd_listlist of flap.PlotAxisDescription
The Pdd list for the axes.
- ax_listlist of flap.Unit.
The axes list.
- flap.plot.get_plot_id()¶
Return the current PlotID or None if no act plot.
- Returns:
- flap.PlotID
- flap.plot.sample_for_plot(x, y, x_error, y_error, n_points)¶
Resample the function before plotting for better performance.
Resample the y(x) function to n_points points for plotting. This is useful for plotting large arrays in a way that short outlier pulses are still indicated.
The original function is divided into n_points equal size blocks in x and in each block, the minimum and maximum is determined. The output will contain 2*`n_points` number or points. Each consecutive point pair contains the minimum and maximum in a block, the time is the centre time of the block.
- Parameters:
- xnp.ndarray
Input ‘x’ array.
- ynp.ndarray
Input ‘y’ array.
- x_errornp.ndarray
Input errors corresponding to the ‘x’ array.
- y_errornp.ndarray
Input errors corresponding to the ‘y’ array.
- n_pointsint
Desired number of blocks. This would be a number larger than the number of pixels in the plot in the horizontal direction.
- Returns:
- x_outnp.ndarrray
Resampled ‘x’ values.
If the box length is less than 5, the original data will be returned.
- y_outnp.ndarrray
Resampled ‘y’ values.
If the box length is less than 5, the original data will be returned.
- flap.plot.set_plot_id(plot_id)¶
Set the current plot.
- Parameters:
- plot_idflap.PlotID
The plot ID to use.