This module contains a widget to create new plots with psyplot
The main class is the PlotCreator
which is used to handle the
different plotting methods of the psyplot.project.ProjectPlotter
class
Classes:
Delegate using the |
|
|
Class to make sure that only those arrays names are inserted that are not currently in the main project or the tree |
|
Table that shows the arrays that will be used for plotting |
|
Widget to setup an axes in a arbitrary location |
|
Wrapper for a QToolBox that holds the different possibilities to select an axes |
|
Widget to select an already created axes |
|
Widget to show a rectangle |
|
Combobox showing coordinate information of a dataset |
|
A table showing the coordinates of in a dataset via instances of |
|
Table that allows to exchange rows via drag and drop |
|
Widget to extract data from a dataset and eventually create a plot |
|
Select a subplot to which will be created (if not already existing) when making the plot |
Delegate alowing only the variables in the parents dataset. |
|
|
Table to display the variables of a dataset |
- class psyplot_gui.plot_creator.ArrayNameItemDelegate[source]
Bases:
QStyledItemDelegate
Delegate using the
ArrayNameValidator
for validationMethods:
createEditor
(self, parent, option, index)
- class psyplot_gui.plot_creator.ArrayNameValidator(text, table, *args, **kwargs)[source]
Bases:
QValidator
Class to make sure that only those arrays names are inserted that are not currently in the main project or the tree
Methods:
fixup
(self, a0)validate
(self, a0, a1)
- class psyplot_gui.plot_creator.ArrayTable(get_func, columns=[], *args, **kwargs)[source]
Bases:
DragDropTable
Table that shows the arrays that will be used for plotting
It contains the following columns:
The variable column which holds the variable names of the arrays. multiple variables may be separated by ‘;;’
The array name. The
psyplot.data.InteractiveBase.arr_name
attribute. Depending on the plot methods_prefer_list
, multiple array names are allowed or not. If this attribute is True, arrays with the same array name will be concatenated into onepsyplot.data.InteractiveList
The axes column. Use the right-click context menu to select a subplot
The check column. Checks for variable names, array names, axes and dimensions via the
psyplot.project._PlotterInterface.check_data()
methodColumns containing the dimension informations
Attributes:
Base tool tip for a dimension column
Tool tip for the variable column
The index of the array name column
The final dictionary containing the array names necessary for the arr_names parameter in the
psyplot.data.ArrayList.from_dataset()
methodA list of axes settings corresponding to the arrays in the
arr_names_dict
The index of the axes column
pattern to interprete arbitrary axes
The index of the check column
The names that are currently in use
Return the _prefer_list attribute of the plot_method
The separator for variable names
Pattern to interprete subplots
The index of the variable column
The list of variable names per array
Methods:
add_single_subplot
(rows, cols, row, col)Add one subplot to the selected arrays on multiple figures
add_subplots
(rows, cols[, maxn])Add multiple subplots to the selected arrays
axes_creator_action
(rows)Action to open a
AxesCreatorCollection
for the selected rowsaxes_info
(s)Interpretes an axes information
check_array
(row[, ignore_duplicates])check whether the array variables are valid, the array name is valid, the axes info is valid and the dimensions
check_arrays
(**kwargs)Convenience function to check all arrays using the
check_array()
methodcheck_item
(item)Check the array corresponding to the given item
dropEvent
(event)Reimplemented to call the
check_arrays()
after the callget_all_rows
(row)Return all the rows that have the same array name as the given row
insert_array
(name[, check])Appends the settings for an array the the list in a new row
next_available_name
(*args, **kwargs)Gives the next possible name to use
remove_arrays
([selected])Remove array rows from the list
set_columns
(columns)Set the columns of the table
set_pm
(s)Set the plot method
setup_from_ds
([ds, plot_method])Fill the table based upon the given dataset.
showAxesCreator
(pos)Context menu for right-click on a row
update_other_items
(item)Updates the axes information of the other items corresponding that have the same array name as the array corresponding to the given item
update_selected
([check, dims])Updates the dimensions of the selectiond arrays with the given dims
- DIMS_TT = "The values for dimension %s. You can use integers either explicit, e.g.<ul><li>1, 2, 3, ...,</li></ul>or slices like <em>start:end:step</em>, e.g.<ul><li>'1:6:2'</li></ul>where the latter is equivalent to '1, 3, 5'"
Base tool tip for a dimension column
- VARIABLE_TT = "The variables of the array from the dataset. Multiplevariables for one array may be separated by ';;'"
Tool tip for the variable column
- add_single_subplot(rows, cols, row, col)[source]
Add one subplot to the selected arrays on multiple figures
- property arr_col
The index of the array name column
- property arr_names_dict
The final dictionary containing the array names necessary for the arr_names parameter in the
psyplot.data.ArrayList.from_dataset()
method
- property axes
A list of axes settings corresponding to the arrays in the
arr_names_dict
- property axes_col
The index of the axes column
- axes_creator_action(rows)[source]
Action to open a
AxesCreatorCollection
for the selected rows
- axes_patt = re.compile('\\((?P<fig>\\d+),\\s*(?P<x0>0*\\.\\d+),\\s*(?P<y0>0*\\.\\d+),\\s*(?P<x1>0*\\.\\d+),\\s*(?P<y1>0*\\.\\d+)\\s*\\)')
pattern to interprete arbitrary axes
- check_array(row, ignore_duplicates=[])[source]
check whether the array variables are valid, the array name is valid, the axes info is valid and the dimensions
- check_arrays(**kwargs)[source]
Convenience function to check all arrays using the
check_array()
method
- property check_col
The index of the check column
- property current_names
The names that are currently in use
- dropEvent(event)[source]
Reimplemented to call the
check_arrays()
after the call
- insert_array(name, check=True, **kwargs)[source]
Appends the settings for an array the the list in a new row
- property prefer_list
Return the _prefer_list attribute of the plot_method
- remove_arrays(selected=True)[source]
Remove array rows from the list
- Parameters:
selected (bool) – If True, only the selected rows are removed
- sep = ';;'
The separator for variable names
- setup_from_ds(ds=None, plot_method=None)[source]
Fill the table based upon the given dataset.
- Parameters:
ds (xarray.Dataset or None) – If None, the dataset from the
get_ds
function is usedplot_method (psyplot.project._PlotterInterface or None) – The plot method of the
psyplot.project.ProjectPlotter
class or None if no plot shall be made
- subplot_patt = re.compile('\\((?P<fig>\\d+),\\s*(?P<rows>\\d+),\\s*(?P<cols>\\d+),\\s*(?P<num1>\\d+),\\s*(?P<num2>\\d+)\\s*\\)')
Pattern to interprete subplots
- update_other_items(item)[source]
Updates the axes information of the other items corresponding that have the same array name as the array corresponding to the given item
- update_selected(check=True, dims={})[source]
Updates the dimensions of the selectiond arrays with the given dims
- property var_col
The index of the variable column
- property vnames
The list of variable names per array
- class psyplot_gui.plot_creator.AxesCreator(fig=None, x0=0.125, y0=0.1, x1=0.9, y1=0.9, *args, **kwargs)[source]
Bases:
QWidget
Widget to setup an axes in a arbitrary location
Methods:
create_axes
(fig, x0, y0, x1, y1, **kwargs)Create an axes for the given fig
get_iter
()Get the iterator over the axes
resize_rectangle
(size)resize the rectangle after changes of the widget size
- static create_axes(fig, x0, y0, x1, y1, **kwargs)[source]
Create an axes for the given fig
- Parameters:
fig (int or None) – The figure number. If None, a new figure number will be used
x0 (float) – the x-coordinate of the lower left corner (between 0 and 1)
y0 (float) – the y-coordinate of the lower left corner (between 0 and 1)
x1 (float) – the x-coordinate of the upper right corner (between 0 and 1)
y1 (float) – the y-coordinate of the upper right corner (between 0 and 1)
**kwargs – Any other keyword argument for the
matplotlib.figure.Figure.add_axes()
method
- class psyplot_gui.plot_creator.AxesCreatorCollection(key=None, func_kwargs={}, *args, **kwargs)[source]
Bases:
QDialog
Wrapper for a QToolBox that holds the different possibilities to select an axes
When the user finished, the
okpressed
symbol is emitted with an infinite iterator of strings. Possible widgets for the toolbox are determined by thewidgets
attributeMethods:
close
()reimplemented to make sure that all widgets are closed when this one is closed
Method that is called whenn the ok button is pressed.
Attributes:
okpressed
(*args, **kwargs)signal that is emitted when the 'Ok' pushbutton is pressed and the user finished the selection
key, title and class fot the widget that is used to create an axes
- create_subplot()[source]
Method that is called whenn the ok button is pressed.
It emits the
okpressed
signal with the iterator of the current widget in the toolbox
- okpressed(*args, **kwargs)
signal that is emitted when the ‘Ok’ pushbutton is pressed and the user finished the selection
- widgets = [('subplot', 'Subplot in a grid', <class 'psyplot_gui.plot_creator.SubplotCreator'>), ('axes', 'Arbitray position', <class 'psyplot_gui.plot_creator.AxesCreator'>), ('choose', 'Existing subplot', <class 'psyplot_gui.plot_creator.AxesSelector'>)]
key, title and class fot the widget that is used to create an axes
- class psyplot_gui.plot_creator.AxesSelector(*args, **kwargs)[source]
Bases:
QWidget
Widget to select an already created axes
Click the button, select your axes and click the button again
Methods:
Replace make all axes pickable
Change the pickers of the axes instances
close
()Reimplemented to restore the pickers if the widget is closed
get_iter
()Get the iterator over the axes
get_picked_ax
(event)Function to be called when an axes is picked
inspect_axes
(ax)Inspect the given axes and get the right string for making a plot with it
Restore the original pickers of the existing axes instances
setVisible
(b)Reimplemented to restore the pickers if the widget is made invisible
unclick
()Restore the original pickers
- class psyplot_gui.plot_creator.AxesViewer(*args, **kwargs)[source]
Bases:
QGraphicsView
Widget to show a rectangle
Methods:
resizeEvent
(self, event)Attributes:
sizeChanged
(*args, **kwargs)- sizeChanged(*args, **kwargs)
- class psyplot_gui.plot_creator.CoordComboBox(ds_func, dim, parent=None)[source]
Bases:
QComboBox
Combobox showing coordinate information of a dataset
This combobox loads its data from the current dataset and allows the popups to be left open. It also has a
leftclick
signal that is emitted when the popup is about to be closed because the user clicked on a valueAttributes:
leftclick
(*args, **kwargs)Methods:
eventFilter
(obj, event)Reimplemented to filter right-click events on the view()
handleItemPressed
(index)Function to be called when an item is pressed to make sure that we know whether anything changed before closing the popup
Reimplemented to only close the popup when the
close_popup
attribute is True or it is clicked outside the windowhide_anyway
([index])Function to hide the popup despite of the
_changed
attributeLoad the coordinate data from the dataset and fill the combobox with it (if it is empty)
mouseDoubleClickEvent
(*args, **kwargs)Reimplemented to fill the box with content from the dataset
mousePressEvent
(*args, **kwargs)Reimplemented to fill the box with content from the dataset
right_click
(point)Function that is called when an item is right_clicked
- property close_popups
- handleItemPressed(index)[source]
Function to be called when an item is pressed to make sure that we know whether anything changed before closing the popup
- hidePopup()[source]
Reimplemented to only close the popup when the
close_popup
attribute is True or it is clicked outside the window
- leftclick(*args, **kwargs)
- load_coord()[source]
Load the coordinate data from the dataset and fill the combobox with it (if it is empty)
- mouseDoubleClickEvent(*args, **kwargs)[source]
Reimplemented to fill the box with content from the dataset
- mousePressEvent(*args, **kwargs)[source]
Reimplemented to fill the box with content from the dataset
- property use_coords
- class psyplot_gui.plot_creator.CoordsTable(get_func, *args, **kwargs)[source]
Bases:
QTableWidget
A table showing the coordinates of in a dataset via instances of
CoordComboBox
Attributes:
A list of
CoordComboBox
in this tableMethods:
fill_from_ds
([ds])Clear the table and create new comboboxes
sizeHint
()Reimplemented to adjust the heigth based upon the header and the first row
- property combo_boxes
A list of
CoordComboBox
in this table
- class psyplot_gui.plot_creator.DragDropTable(*args, **kwargs)[source]
Bases:
QTableWidget
Table that allows to exchange rows via drag and drop
This class was mainly taken from http://stackoverflow.com/questions/26227885/drag-and-drop-rows-within-qtablewidget
Methods:
dropEvent
(self, event)dropOn
(event)droppingOnItself
(event, index)moveRows
(row[, remove])Move all selected rows to the given row
position
(pos, rect, index)
- class psyplot_gui.plot_creator.PlotCreator(*args, **kwargs)[source]
Bases:
QDialog
Widget to extract data from a dataset and eventually create a plot
Attributes:
Tooltip for not making a plot
Methods:
add_new_ds
(oname, ds[, fname])close
(*args, **kwargs)Reimplemented to make sure that the data sets are deleted
Method to be called when the Create plot button is pressed
fill_ds_combo
(project)fill the dataset combobox with datasets of the current main project
fill_fmt_tree
(pm)Takes the names of the plotting methods in the current project
get_ds
([i])Get the dataset
insert_array
([variables])Inserts an array for the given variables (or the ones selected in the
variable_table
if variables is None)insert_array_from_combo
(cb[, variables])Insert new arrays into the dataset when the combobox is left-clicked
Reimplemented to close the window when escape is hitted
Load a preset file
open_data
(*args, **kwargs)Convenience method to create a sub project without a plotter
open_dataset
([fnames])Opens a file dialog and the dataset that has been inserted
Clear all comboboxes
set_decoder
(decoder)Set the decoder for the new plots.
set_ds
(i)Set the current dataset
set_pm
(plot_method)set_preset
(preset)Method to be emitted to setup one subplot at a specific location for each of the selected arrays on separate (new) figures
Method to be emitted to setup the subplots for the selected arrays on new figures
Shows info on the current plotting method in the help explorer
switch2ds
(ds)Switch to the given dataset
Change the automatic closing of popups
- NO_PM_TT = 'Choose a plot method (or choose none to only extract the data)'
Tooltip for not making a plot
- create_plots()[source]
Method to be called when the Create plot button is pressed
This method reads the data from the
array_table
attribute and makes the plot (or extracts the data) based upon theplot_method
attribute
- get_ds(i=None)[source]
Get the dataset
- Parameters:
i (int or None) – If None, the dataset of the current index in the ds_combo is returned. Otherwise it specifies the locdation of the dictionary in the
ds_descs
attribute- Returns:
The requested dataset
- Return type:
- insert_array(variables=None)[source]
Inserts an array for the given variables (or the ones selected in the
variable_table
if variables is None)
- insert_array_from_combo(cb, variables=None)[source]
Insert new arrays into the dataset when the combobox is left-clicked
- open_data(*args, **kwargs)[source]
Convenience method to create a sub project without a plotter
This method is used when the
pm_combo
is empty
- open_dataset(fnames=None, *args, **kwargs)[source]
Opens a file dialog and the dataset that has been inserted
- setup_subplot()[source]
Method to be emitted to setup one subplot at a specific location for each of the selected arrays on separate (new) figures
- setup_subplots()[source]
Method to be emitted to setup the subplots for the selected arrays on new figures
- switch2ds(ds)[source]
Switch to the given dataset
- Parameters:
ds (xarray.Dataset) – The dataset to use. It is assumed that this dataset is already in the dataset combobox
- class psyplot_gui.plot_creator.SubplotCreator(fig=None, rows=1, cols=1, num1=1, num2=None, *args, **kwargs)[source]
Bases:
QWidget
Select a subplot to which will be created (if not already existing) when making the plot
Methods:
create_subplot
([fig, rows, cols, num1, num2])Create a subplot for the given figure
get_iter
()Get the iterator over the axes
Set the validator range for the num2 line edit
set_selected
(num1, num2)Update the selection in the table based upon num1 and num2
Update the selection of the table after changes of
num1_edit
Update the selection of the table after changes of
num2_edit
Set up the table based upon the number of rows and columns in the rows and cols line edit
Update the
num1_edit
andnum2_edit
after the selection of the table changed- static create_subplot(fig=None, rows=1, cols=1, num1=1, num2=None, **kwargs)[source]
Create a subplot for the given figure
- Parameters:
fig (
matplotlib.figure.Figure
or int) – If integer, thematplotlib.pyplot.figure()
function is usedrows (int) – Number of rows for the gridspec
cols (int) – Number of columns for the gridspec
num1 (int) – The subplot number of the upper left corner in the grid (starting from 1!)
num2 (None or int) – The subplot number of the lower left corner in the grid (starting from 1!). If None, num1 will be used
**kwargs – Any other keyword argument for the
matplotlib.figure.Figure.add_subplot()
method
- Returns:
The new created subplot
- Return type:
mpl.axes.Subplot
- class psyplot_gui.plot_creator.VariableItemDelegate[source]
Bases:
QStyledItemDelegate
Delegate alowing only the variables in the parents dataset.
The parent must hold a get_ds method that returns a dataset when called
Methods:
createEditor
(self, parent, option, index)
- class psyplot_gui.plot_creator.VariablesTable(get_func, columns=['long_name', 'dims', 'shape'], *args, **kwargs)[source]
Bases:
QTableWidget
Table to display the variables of a dataset
Methods:
fill_from_ds
([ds])Clear the table and insert items from the given dataset
set_columns
([columns])Attributes:
The currently selected variables
The variables in the dataset
- property selected_variables
The currently selected variables
- variables = []
The variables in the dataset