본문 바로가기

Data Analysis/Visualization

plotly 연습

# 참고 데이터
import plotly.express as px
data_canada = px.data.gapminder().query("country == 'Canada'")


# 참고할 색상 표
colorscales:
            ['aggrnyl', 'agsunset', 'algae', 'amp', 'armyrose', 'balance',
             'blackbody', 'bluered', 'blues', 'blugrn', 'bluyl', 'brbg',
             'brwnyl', 'bugn', 'bupu', 'burg', 'burgyl', 'cividis', 'curl',
             'darkmint', 'deep', 'delta', 'dense', 'earth', 'edge', 'electric',
             'emrld', 'fall', 'geyser', 'gnbu', 'gray', 'greens', 'greys',
             'haline', 'hot', 'hsv', 'ice', 'icefire', 'inferno', 'jet',
             'magenta', 'magma', 'matter', 'mint', 'mrybm', 'mygbm', 'oranges',
             'orrd', 'oryel', 'oxy', 'peach', 'phase', 'picnic', 'pinkyl',
             'piyg', 'plasma', 'plotly3', 'portland', 'prgn', 'pubu', 'pubugn',
             'puor', 'purd', 'purp', 'purples', 'purpor', 'rainbow', 'rdbu',
             'rdgy', 'rdpu', 'rdylbu', 'rdylgn', 'redor', 'reds', 'solar',
             'spectral', 'speed', 'sunset', 'sunsetdark', 'teal', 'tealgrn',
             'tealrose', 'tempo', 'temps', 'thermal', 'tropic', 'turbid',
             'turbo', 'twilight', 'viridis', 'ylgn', 'ylgnbu', 'ylorbr',
             'ylorrd']
             
# import dash_html_components as html
from dash import Dash, dash_table

external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']

app = dash.Dash(__name__, external_stylesheets=external_stylesheets)

app.layout = html.Div([
    html.H1('Dash Tabs component demo', style={'text-align':'center'} ),
    dcc.Tabs([
        dcc.Tab(label='TAB1', children=[
            dcc.Graph(
                figure=px.bar(data_canada, x = "year", y = "pop", title = "graph1", color = "pop", color_continuous_scale = "darkmint")),
            dcc.Graph(
                figure=px.bar(data_canada, x = "year", y = "pop", title = "graph1", color = "pop", color_continuous_scale = "darkmint"))
        
            
        ]),
        dcc.Tab(label='TAB2', children=[
            dcc.Graph(
                figure = px.bar(data_canada, x = "year", y = "pop", title = "graph2",color = "pop", color_continuous_scale = "deep"))
        ]),
        dcc.Tab(label='TAB3', children=[
            dcc.Graph(
                figure=px.bar(data_canada, x = "year", y = "pop", title = "graph3",color = "pop", color_continuous_scale = "blugrn"))
        ]),
        dcc.Tab(label='TAB4', children=[
            dcc.Graph(
                figure = px.bar(data_canada, x = "year", y = "pop", title = "graph4",color = "pop", color_continuous_scale = "ice"))            
        ]),
        dcc.Tab(label='TAB5', children=[
            dcc.Graph(
                figure = px.bar(data_canada, x = "year", y = "pop", title = "graph5",color = "pop", color_continuous_scale = "peach"))            
        ]),
        dcc.Tab(label='TAB6', children=[
            dcc.Graph(
                figure = px.bar(data_canada, x = "year", y = "pop", title = "graph6",color = "pop", color_continuous_scale = "tealrose"))
        ]) 

    ], colors={
        "border": "black",
        "primary": "black",
        "background": "aliceblue"
    })
], # 최상단 제목 컬러: style={'backgroundColor':'lightsteelblue'}
)
if __name__ == '__main__':
    app.run_server(debug=False)

'Data Analysis > Visualization' 카테고리의 다른 글

Plotly-Dash Environmental Testing  (0) 2021.09.03