-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Marco Zocca
committed
Jan 7, 2024
1 parent
9f7fd1a
commit 5096fc4
Showing
2 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import plotly.express as px | ||
|
||
def irisScatter1(): | ||
""" | ||
:return: px.Figure in JSON | ||
""" | ||
# Load data, make figure. | ||
df = px.data.iris() | ||
fig = px.scatter(df, x="sepal_width", y="sepal_length") | ||
trace = next(fig.select_traces()) | ||
|
||
# Set default point styles. | ||
n = len(trace.x) | ||
color = [trace.marker.color] * n | ||
size = [8] * n | ||
symbol = [trace.marker.symbol] * n | ||
|
||
# Modify kth point. | ||
k = 136 | ||
color[k] = "red" | ||
size[k] = 15 | ||
symbol[k] = "star" | ||
|
||
# Update trace. | ||
# trace.marker.color = color | ||
# trace.marker.size = size | ||
# trace.marker.symbol = symbol | ||
|
||
# Alternatively, call: | ||
fig.update_traces(marker=dict(color=color, size=size, symbol=symbol)) | ||
|
||
return fig.to_json() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
|
||
from flask import Flask, request, send_file | ||
from markupsafe import Markup, escape | ||
|
||
from plotly_compound_scatter_test import irisScatter1 | ||
|
||
app = Flask(__name__, static_folder='') | ||
|
||
@app.get('/') | ||
def index(): | ||
return send_file('index.html') | ||
|
||
@app.post('/get-data') | ||
def hello(): | ||
# name = request.args.get("name", "World") | ||
# return f'Hello, {escape(name)}!' | ||
figJSON = irisScatter1() | ||
return figJSON | ||
|
||
if __name__ == "__main__": | ||
app.run(host='0.0.0.0', port=3000, debug=True) |