Пример #1
0
 def __init__(self, df, plot_kwargs=None,mode='interactive',theme='space', **kwargs):
     
     if plot_kwargs is None:
         self.plot_kwargs = {'title':'Bar'}
     else:
         self.plot_kwargs = plot_kwargs
     
     self._df = df
     col_opts = [''] + list(df.columns.values)
     col_opts_2 = col_opts.copy()
     col_opts_2[0] = "None"
     self._col_opts = dict(zip(col_opts_2,col_opts))
     cmap = ColormapPicker(name='cmap', mode='interactive')
     layout = Layout(name='layout_d', mode='interactive')
     kind_opts = ["scatter","bar","box",
                  "spread","ratio","heatmap",
                  "surface","histogram", "bubble",
                  "bubble3d","scatter3d","scattergeo","choroplet"]
     color_scales = list(cf.colors.get_scales().keys())+[None]
     dash = ['c$N=cufflinks',
             [
              ['r$n=general_params',['@sm$d=columns&o='+str(col_opts[1:]),['c$n=aux_col_1',['@dd$d=Kind&o='+str(kind_opts),'@[False]$d=subplots',
                                                                                            '@[False]$d=Shared xaxes','@[False]$d=Shared yaxes']],
                                     ['c$N=titles_col',["@text$d=Title","@text$d=xTitle","@text$d=yTitle","@text$d=zTitle"]],
                                     '@select$d=Theme&o='+str(cf.getThemes())+'&val='+theme,
                                     ['c$n=colorp_row',['@dd$d=categories&o='+str(self._col_opts),'@sm$d=secondary_y&o='+str(self._col_opts),'@dd$d=Color scale',cmap]]
                                    ]
              ],
              ['r$n=scatter_params',[['c$n=axis_col_xyz',['@dd$d=x&o='+str(self._col_opts),'@dd$d=y&o='+str(self._col_opts),'@dd$d=z&o='+str(self._col_opts)]],
                                     ['c$n=marker_prop_col',['@dd$d=text&o='+str(self._col_opts),'@(1,500,1,12)$d=Size',
                                   '@dd$d=Marker mode&o=["lines","markers","text","lines+markers","markers+text","lines+text","lines+markers+text"]']],
                                     '@False$d=fill','@dd$d=symbol&o=["dot","cross","square","triangle-down","triangle-right","triangle-left","triangle-up","x"]',
                                     '@dd$d=dash&o=["solid","dash","dashdot","dot"]'
                                  ]],
              ['r$N=barmode_row',['@ddown$d=barmode&o=["stack", "group", "overlay"]',
                                  ['c$N=mini_bar_col',['@togs$d=Orientation&n=ori&o=["v","h"]&val=v',
                                                       "@(0.,1.,0.05,1.)$d=Bargap",
                                                       "@(0.,1.,0.05,1.)$d=Bargroupgap"]],
                                  ['c$N=hist_col',["@(0,500,1,0)$d=Bins",
                                  '@dd$d=Histnorm&o=["frequency","percent","probaility","density","probability density"]',
                                  '@dd$d=Histfunc&o=["count","sum","avg","min","max"]']],
                                  
                                 ]],
              layout,
              ['r$n=btn_rows',['[False]$d=Layout&n=btn_layout','@False$d=Apply layout',
                                      '@btn$d=Update&n=update_btn']
              ]
             ]
            ]
     
     Dashboard.__init__(self, dash, mode=mode, **kwargs)
     self.theme.target.layout.width = "100%"
     self.theme.widget.layout.width = "100%"
     
     self.url = ''#not used, but prepared for working online.
     self._init_widget_values()
     self.observe(self.update)
     self.btn_layout.observe(self._layout_toggle)
Пример #2
0
 def themes():
     return cf.getThemes()
Пример #3
0
 def setTheme(theme='pearl'):
     if theme not in cf.getThemes():
         cf.set_config_file(theme='pearl')
     else:
         cf.set_config_file(theme)
Пример #4
0
# In[6]:

df.iplot(kind='line')

# In[38]:

print(df.shape)
df.head(10)

# ### Plot Styling

# ### 테마(Theme) 설정

# In[39]:

themes = cf.getThemes()
themes

# In[40]:

data = pd.Series(range(10))
for theme in themes:
    data.iplot(kind='bar', theme=theme, title=theme)

# ### 테마 설정

# In[41]:

cf.set_config_file(theme='pearl')

# ## Plotly express 사용한 시각화
Пример #5
0
import plotly.express as px
import plotly.offline as iplot
import plotly.graph_objects as go
import matplotlib.pyplot as plt
import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output  # Load Data
import seaborn as sns
import cufflinks as cf
import base64

iplot.init_notebook_mode(connected=True)
cf.go_offline()

cf.getThemes()
cf.set_config_file(theme='white')


def create_dataframe():
    """Create Pandas DataFrame from local CSV."""
    df = pd.read_csv('data/WorldCups.csv')
    return df


def all_cleaned_data():
    # -----------------------------------------------------------------------
    # -----------------------------------------------------------------------
    # -------------------Importing data--------------------------------------
    # -----------------------------------------------------------------------
Пример #6
0
    def __init__(self,
                 df,
                 plot_kwargs=None,
                 mode='interactive',
                 theme='space',
                 **kwargs):

        if plot_kwargs is None:
            self.plot_kwargs = {'title': 'Bar'}
        else:
            self.plot_kwargs = plot_kwargs

        self._df = df
        col_opts = [''] + list(df.columns.values)
        col_opts_2 = col_opts.copy()
        col_opts_2[0] = "None"
        self._col_opts = dict(zip(col_opts_2, col_opts))
        cmap = ColormapPicker(name='cmap', mode='interactive')
        layout = Layout(name='layout_d', mode='interactive')
        kind_opts = [
            "scatter", "bar", "box", "spread", "ratio", "heatmap", "surface",
            "histogram", "bubble", "bubble3d", "scatter3d", "scattergeo",
            "choroplet"
        ]
        color_scales = list(cf.colors.get_scales().keys()) + [None]
        dash = [
            'c$N=cufflinks',
            [[
                'r$n=general_params',
                [
                    '@sm$d=columns&o=' + str(col_opts[1:]),
                    [
                        'c$n=aux_col_1',
                        [
                            '@dd$d=Kind&o=' + str(kind_opts),
                            '@[False]$d=subplots', '@[False]$d=Shared xaxes',
                            '@[False]$d=Shared yaxes'
                        ]
                    ],
                    [
                        'c$N=titles_col',
                        [
                            "@text$d=Title", "@text$d=xTitle",
                            "@text$d=yTitle", "@text$d=zTitle"
                        ]
                    ], '@select$d=Theme&o=' + str(cf.getThemes()) + '&val=' +
                    theme,
                    [
                        'c$n=colorp_row',
                        [
                            '@dd$d=categories&o=' + str(self._col_opts),
                            '@sm$d=secondary_y&o=' + str(self._col_opts),
                            '@dd$d=Color scale', cmap
                        ]
                    ]
                ]
            ],
             [
                 'r$n=scatter_params',
                 [[
                     'c$n=axis_col_xyz',
                     [
                         '@dd$d=x&o=' + str(self._col_opts),
                         '@dd$d=y&o=' + str(self._col_opts),
                         '@dd$d=z&o=' + str(self._col_opts)
                     ]
                 ],
                  [
                      'c$n=marker_prop_col',
                      [
                          '@dd$d=text&o=' + str(self._col_opts),
                          '@(1,500,1,12)$d=Size',
                          '@dd$d=Marker mode&o=["lines","markers","text","lines+markers","markers+text","lines+text","lines+markers+text"]'
                      ]
                  ], '@False$d=fill',
                  '@dd$d=symbol&o=["dot","cross","square","triangle-down","triangle-right","triangle-left","triangle-up","x"]',
                  '@dd$d=dash&o=["solid","dash","dashdot","dot"]']
             ],
             [
                 'r$N=barmode_row',
                 [
                     '@ddown$d=barmode&o=["stack", "group", "overlay"]',
                     [
                         'c$N=mini_bar_col',
                         [
                             '@togs$d=Orientation&n=ori&o=["v","h"]&val=v',
                             "@(0.,1.,0.05,1.)$d=Bargap",
                             "@(0.,1.,0.05,1.)$d=Bargroupgap"
                         ]
                     ],
                     [
                         'c$N=hist_col',
                         [
                             "@(0,500,1,0)$d=Bins",
                             '@dd$d=Histnorm&o=["frequency","percent","probaility","density","probability density"]',
                             '@dd$d=Histfunc&o=["count","sum","avg","min","max"]'
                         ]
                     ],
                 ]
             ], layout,
             [
                 'r$n=btn_rows',
                 [
                     '[False]$d=Layout&n=btn_layout', '@False$d=Apply layout',
                     '@btn$d=Update&n=update_btn'
                 ]
             ]]
        ]

        Dashboard.__init__(self, dash, mode=mode, **kwargs)
        self.theme.target.layout.width = "100%"
        self.theme.widget.layout.width = "100%"

        self.url = ''  #not used, but prepared for working online.
        self._init_widget_values()
        self.observe(self.update)
        self.btn_layout.observe(self._layout_toggle)