ross.get_data_from_figure

ross.get_data_from_figure#

ross.get_data_from_figure(fig)#

Get data from a Plotly scatter plot (XY) and convert to a pd.DataFrame.

This function takes a go.Figure() object from Plotly and converts the data to a DataFrame from Pandas. It works only for Scatter Plots (XY) and does no support subplots or polar plots.

This function is suitable to the following analyzes:
  • run_freq_response()

  • run_unbalance_response()

  • run_time_response()

Parameters:
figgo.Figure

A Plotly figure generated by go.Figure() command.

Returns:
dfpd.DataFrame

A DataFrame with the fig.data.

Examples

>>> import ross as rs
>>> rotor = rs.rotor_example()

Get post-processed data from an unbalance response >>> resp = rotor.run_unbalance_response( … 3, 0.001, 0.0, np.linspace(0, 1000, 101) … ) >>> fig = resp.plot_magnitude(probe=[rs.Probe(3, 0.0, tag=”probe1”), rs.Probe(3, np.pi/2, tag=”probe2”)]) >>> df = rs.get_data_from_figure(fig)

Use the probe tag to navigate through pandas data Index 0 for frequency array >>> df[“probe1”].values[0] # doctest: +ELLIPSIS array([ 0., 10., 20., 30.,…

Index 1 for amplitude array >>> df[“probe1”].values[1] # doctest: +ELLIPSIS array([0.00000000e+00,…

Or use “iloc” to obtain the desired array from pandas >>> df.iloc[1, 0] # doctest: +ELLIPSIS array([0.00000000e+00, 1.6057…