LECA.prep.interactive_data_visualize
- LECA.prep.interactive_data_visualize(df: DataFrame, fig: Figure, features: List[str], show_axes: List[str], highlight_data: DataFrame | None = None) None
Visualize dataset with a 2d or 3d plot. Special formulation to support integration with notebook interactive widgets. Plots the distribution of measurement points within the min-max range of each selected feature.
- Parameters:
data (
DataFrame) – Dataframe of experimental measurements.fig (
plt.Figure) – Figure object passed to contain plots.features (List[str]) – List of all features.
show_axes (List[str]) – List of features to use as axes for the data distribution plot.
highlight_data (Optional[
DataFrame]) –Optional DataFrame of measurements to highlight within the plot (shown as red triangles).
Default value
None.
Examples
from ipywidgets import interact, widgets import matplotlib.pyplot as plt from IPython.display import display %matplotlib notebook # Define which DataFrames to use for included/excluded data df = sliced_df cut_df = cutoff_df # Initialize plt.Figure object fig = plt.figure(figsize=(4,4)) ax = fig.add_subplot() # Define and show interactive widgets X_slider=widgets.Dropdown(options=features, description='X') Y_slider=widgets.Dropdown(options=features, description='Y') Z_slider=widgets.Dropdown(options=[None]+features, description='Z (optional)') display(X_slider) display(Y_slider) display(Z_slider) # Function call to update plot def data_vis(change=None): ax.clear() X_feature = X_slider.value Y_feature = Y_slider.value Z_feature = Z_slider.value if Z_feature: prep.interactive_data_visualize(df, fig, features, show_axes=[X_feature, Y_feature, Z_feature], highlight_data=cut_df) else: prep.interactive_data_visualize(df, fig, features, show_axes=[X_feature, Y_feature], highlight_data=cut_df) # Make button to plot data btn=widgets.Button(description="Run") display(btn) btn.on_click(data_vis)
- Return type:
None