
โ Plotly๋?
๋ฐ์ดํฐ๋ฅผ “์ธํฐ๋ํฐ๋ธ(์ํธ์์ฉ)”ํ๊ฒ ์๊ฐํํด์ฃผ๋ ๋ผ์ด๋ธ๋ฌ๋ฆฌ
์ค์น
pip install dash
https://dash.plotly.com/layout
Part 1. Layout | Dash for Python Documentation | Plotly
This is the 1st chapter of the Dash Fundamentals. The next chapter covers Dash callbacks. # Run this app with `python app.py` and # visit http://127.0.0.1:8050/ in your web browser. from dash import Dash, html, dcc import plotly.express as px import pandas
dash.plotly.com
๊ฐ๋
2๊ฐ์ง ๊ฐ๋ ์ด ์๋ค.
๋ ์ด์์(Dash HTML Components), ์ฝ๋ฐฑ(Dash Core Components)
๋ ์ด์์์ html์ ํ๋ฉด์ ๋์ฐ๋ ๊ฒ, ์ฝ๋ฐฑ์ ๋ชจ๋ ๊ฒ๋ค์ interactiveํ๊ฒ ๋ง๋ค์ด์ค
Dash, Plotly
Dash: Python์ react application์ผ๋ก ๋ง๋ค์ด์ interactiveํ๊ฒ ๋ง๋ค์ด์ค๋ค.
Plotly: ์คํ์์ค Graphing Libraries. ๋ฐ์ดํฐ ์๊ฐํ๋ฅผ ํ ์ ์๊ฒ ํด์ค.
โ Plotly
https://plotly.com/python-api-reference/generated/plotly.express.scatter_geo.html
plotly.express.scatter_geo — 6.6.0 documentation
hover_data (str, or list of str or int, or Series or array-like, or dict) – Either a name or list of names of columns in data_frame, or pandas Series, or array_like objects or a dict with column names as keys, with values True (for default formatting) Fa
plotly.com
https://plotly.com/python/templates/
Theming
Over 25 examples of Theming and templates including changing color, size, log axes, and more in Python.
plotly.com
from dash import Dash, html
import plotly.express as px
from data import countries_df
from builders import make_table
stylesheets = [
"https://cdn.jsdelivr.net/npm/reset-css@5.0.2/reset.min.css",
"https://fonts.googleapis.com/css2?family=Open+Sans&display=swap",
]
app = Dash(external_stylesheets=stylesheets)
app.layout = html.Div(
style={
"minHeight": "100vh",
"backgroundColor": "#111111",
"color": "white",
"fontFamily": "Open Sans, sans-serif",
},
children=[
html.Header(
style={"textAlign": "center", "paddingTop": "50px", "marginBottom": 100},
children=html.H1("Corona Dashboard", style={"fontSize": 40}),
),
html.Div(children=[html.Div(children=[make_table(countries_df)])]),
],
)
map_figure = px.scatter_geo(
countries_df,
size="Confirmed",
hover_name="Country_Region",
locations="Country_Region",
locationmode="country names",
size_max=40,
color="Confirmed",
template="plotly_dark",
hover_data={
"Confirmed": ":,",
"Recovered": ":,",
"Deaths": ":,",
"Country_Region": False,
},
)
map_figure.show()
if __name__ == "__main__":
app.run(debug=True)
callback
from dash import Dash, html, dcc
import plotly.express as px
from data import countries_df, totals_df
from builders import make_table
from dash.dependencies import Input, Output
stylesheets = [
"https://cdn.jsdelivr.net/npm/reset-css@5.0.2/reset.min.css",
"https://fonts.googleapis.com/css2?family=Open+Sans&display=swap",
]
app = Dash(external_stylesheets=stylesheets)
bubble_map = px.scatter_geo(
countries_df,
size="Confirmed",
hover_name="Country_Region",
locations="Country_Region",
locationmode="country names",
size_max=40,
title="Confirmed By Country",
color="Confirmed",
template="plotly_dark",
color_continuous_scale=px.colors.sequential.Oryel,
# projection="natural earth",
hover_data={
"Confirmed": ":,",
"Recovered": ":,",
"Deaths": ":,",
"Country_Region": False,
},
)
bars_graph = px.bar(
totals_df,
x="condition",
y="count",
template="plotly_dark",
title="Total Global Cases",
hover_data={"count": ":,"},
labels={"condition": "Condition", "count": "Count", "color": "Condition"},
)
bars_graph.update_traces(marker_color=["#e74c3c", "#8e44ad", "#27ae60"])
app.layout = html.Div(
style={
"minHeight": "100vh",
"backgroundColor": "#111111",
"color": "white",
"fontFamily": "Open Sans, sans-serif",
},
children=[
html.Header(
style={"textAlign": "center", "paddingTop": "50px", "marginBottom": 100},
children=html.H1("Corona Dashboard", style={"fontSize": 40}),
),
html.Div(
style={
"display": "grid",
"gap": 50,
"gridTemplateColumns": "repeat(4, 1fr)",
},
children=[
html.Div(
style={"grid-column": "span 3"},
children=[dcc.Graph(figure=bubble_map)],
),
html.Div(children=[make_table(countries_df)]),
],
),
html.Div(
style={
"display": "grid",
"gap": 50,
"gridTemplateColumns": "repeat(4, 1fr)",
},
children=[
html.Div(children=[dcc.Graph(figure=bars_graph)]),
html.Div(
children=[
dcc.Input(
style={"color": "black"},
placeholder="What is your name?",
id="hello-input",
),
html.H2(children="Hello Anonymous", id="hello-output"),
],
),
],
),
],
)
@app.callback(Output("hello-output", "children"), [Input("hello-input", "value")])
def update_hello(value):
if value is None:
return "Hello Anonymous"
else:
return f"Hello {value}"
if __name__ == "__main__":
app.run(debug=True)'๐ ๋ผ์ด๋ธ๋ฌ๋ฆฌ' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
| ๋ผ์ด๋ธ๋ฌ๋ฆฌ - Shadcn/ui (0) | 2026.04.27 |
|---|---|
| ๋ผ์ด๋ธ๋ฌ๋ฆฌ - Jupyter (0) | 2026.04.17 |
| ๋ผ์ด๋ธ๋ฌ๋ฆฌ - pandas(python) (0) | 2026.04.17 |
| ๋ผ์ด๋ธ๋ฌ๋ฆฌ - Flask (0) | 2026.03.16 |
| ๋ผ์ด๋ธ๋ฌ๋ฆฌ - Playwright (0) | 2026.03.13 |