dfvutils#
Utility functions for dfvue.
The utility functions do not depend on the dfvue class. Functions depending on the class are in dfvmethods.
This module was written by Matthias Cuntz while at Institut National de Recherche pour l’Agriculture, l’Alimentation et l’Environnement (INRAE), Nancy, France.
- copyright:
Copyright 2023- Matthias Cuntz - mc (at) macu (dot) de
- license:
MIT License, see LICENSE for details.
The following functions are provided:
|
Duplicate the main dfvue window. |
|
Formatter function for scatter plot with left and right axis having the same x-axis. |
|
Intersection of two lists. |
|
Convert text string to correct data type |
|
Extract variable name from 'variable (dim1=ndim1,)' string. |
- History
Written Jul 2023 by Matthias Cuntz (mc (at) macu (dot) de)
Use dfvMain directly for cloning window, Jun 2014, Matthias Cuntz
Use CustomTkinter, Jun 2024, Matthias Cuntz
Use mix of grid and pack layout manager, Jun 2024, Matthias Cuntz
Use CustomTkinter only if installed, Jun 2024, Matthias Cuntz
Allow list in window title in clone_dfvmain, Oct 2024, Matthias Cuntz
Remove [ms] from check for datetime in format_coord on axes2, Oct 2024, Matthias Cuntz
Back to pack layout manager for resizing, Nov 2024, Matthias Cuntz
Increased digits in format_coord_scatter, Jan 2025, Matthias Cuntz
Add parse_entry from dfvreadcsv, Jan 2025, Matthias Cuntz
Use dfvScreen for window sizes, Nov 2025, Matthias Cuntz
- clone_dfvmain(widget)[source]#
Duplicate the main dfvue window.
- Parameters:
widget (dfvue.dfvMain) – widget of dfvMain class.
- Return type:
Another dfvue window will be created.
Examples
>>> self.newwin = ctk.CTkButton( ... self.rowwin, text="New Window", ... command=partial(clone_dfvmain, self.master))
- format_coord_scatter(x, y, ax, ax2, xdtype, ydtype, y2dtype)[source]#
Formatter function for scatter plot with left and right axis having the same x-axis.
- Parameters:
x (float) – Data coordinates of ax2.
y (float) – Data coordinates of ax2.
ax (matplotlib.axes._subplots.AxesSubplot) – Matplotlib axes object for left-hand and right-hand y-axis, resp.
ax2 (matplotlib.axes._subplots.AxesSubplot) – Matplotlib axes object for left-hand and right-hand y-axis, resp.
xdtype (numpy.dtype) – Numpy dtype of data of x-values (xdtype), left-hand side y-values (ydtype), and right-hand side y-values (y2dtype)
ydtype (numpy.dtype) – Numpy dtype of data of x-values (xdtype), left-hand side y-values (ydtype), and right-hand side y-values (y2dtype)
y2dtype (numpy.dtype) – Numpy dtype of data of x-values (xdtype), left-hand side y-values (ydtype), and right-hand side y-values (y2dtype)
- Return type:
String with left-hand side and right hand-side coordinates.
Examples
>>> ax = plt.subplot(111) >>> ax2 = ax.twinx() >>> ax.plot(xx, yy) >>> ax2.plot(xx, yy2) >>> ax2.format_coord = lambda x, y: format_coord_scatter( ... x, y, ax, ax2, xx.dtype, yy.dtype, yy2.dtype)
- list_intersection(lst1, lst2)[source]#
Intersection of two lists.
From: https://stackoverflow.com/questions/3697432/how-to-find-list-intersection Using list comprehension for small lists and set() method with builtin intersection for longer lists.
- Parameters:
- Returns:
List with common elements in both input lists.
- Return type:
Examples
>>> lst1 = [ 4, 9, 1, 17, 11, 26, 28, 28, 26, 66, 91] >>> lst2 = [9, 9, 74, 21, 45, 11, 63] >>> print(Intersection(lst1, lst2)) [9, 11]