No problem, please run this dash example below and press “Print Data”.
Output with plotly 5.24.1 installed:
X values: [1, 2, 3, 4, 5]
Y values: [2, 1.5, 3.5, 2, 5]
Output with plotly 6.0.0 installed:
X values: {‘dtype’: ‘f8’, ‘bdata’: ‘AAAAAAAA8D8AAAAAAAAAQAAAAAAAAAhAAAAAAAAAEEAAAAAAAAAUQA==’, ‘_inputArray’: {‘0’: 1, ‘1’: 2, ‘2’: 3, ‘3’: 4, ‘4’: 5, ‘bdata’: ‘AAAAAAAA8D8AAAAAAAAAQAAAAAAAAAhAAAAAAAAAEEAAAAAAAAAUQA==’, ‘dtype’: ‘f8’, ‘shape’: ‘5’}}
Y values: {‘dtype’: ‘f8’, ‘bdata’: ‘AAAAAAAAAEAAAAAAAAD4PwAAAAAAAAxAAAAAAAAAAEAAAAAAAAAUQA==’, ‘_inputArray’: {‘0’: 2, ‘1’: 1.5, ‘2’: 3.5, ‘3’: 2, ‘4’: 5, ‘bdata’: ‘AAAAAAAAAEAAAAAAAAD4PwAAAAAAAAxAAAAAAAAAAEAAAAAAAAAUQA==’, ‘dtype’: ‘f8’, ‘shape’: ‘5’}}
Dash example:
import dash
from dash import dcc, html, Input, Output, State
import plotly.graph_objs as go
import numpy as np
# Initialize the Dash app
app = dash.Dash(__name__)
# Create some sample data using numpy
x_data = np.array([1.0, 2.0, 3.0, 4.0, 5.0])
y_data = np.array([2.0, 1.5, 3.5, 2.0, 5.0])
# Define the layout of the app
app.layout = html.Div([
dcc.Graph(id='scatter-plot'),
html.Button('Generate Plot', id='generate-button', n_clicks=0),
html.Button('Print Data', id='print-button', n_clicks=0)
])
# Callback to generate the ScatterGL plot
@app.callback(
Output('scatter-plot', 'figure'),
Input('generate-button', 'n_clicks')
)
def update_figure(n_clicks):
# Create a ScatterGL trace
trace = go.Scattergl(
x=x_data,
y=y_data,
mode='markers',
marker=dict(size=10, color='blue')
)
# Create the figure
fig = go.Figure(data=[trace])
fig.update_layout(title='ScatterGL Plot', xaxis_title='X Axis', yaxis_title='Y Axis')
return fig
# Callback to print the x and y data from the figure
@app.callback(
Output('print-button', 'children'),
Input('print-button', 'n_clicks'),
State('scatter-plot', 'figure')
)
def print_data(n_clicks, figure):
if n_clicks > 0 and figure is not None:
# Extract the x and y data from the figure
x_values = figure['data'][0]['x']
y_values = figure['data'][0]['y']
# Print the x and y values
print("X values:", x_values)
print("Y values:", y_values)
return "Print Data"
# Run the app
if __name__ == '__main__':
app.run_server(debug=True)