PLOTLY AND CUFF LINKS
CLASS-WORK
Complete_PlotLy_CuffLinks
In [ ]:
!pip install chart_studio
Collecting chart_studio
  Downloading chart_studio-1.1.0-py3-none-any.whl (64 kB)
     |████████████████████████████████| 64 kB 2.5 MB/s 
Requirement already satisfied: requests in /usr/local/lib/python3.7/dist-packages (from chart_studio) (2.23.0)
Requirement already satisfied: six in /usr/local/lib/python3.7/dist-packages (from chart_studio) (1.15.0)
Requirement already satisfied: plotly in /usr/local/lib/python3.7/dist-packages (from chart_studio) (4.4.1)
Requirement already satisfied: retrying>=1.3.3 in /usr/local/lib/python3.7/dist-packages (from chart_studio) (1.3.3)
Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /usr/local/lib/python3.7/dist-packages (from requests->chart_studio) (1.24.3)
Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.7/dist-packages (from requests->chart_studio) (2021.10.8)
Requirement already satisfied: chardet<4,>=3.0.2 in /usr/local/lib/python3.7/dist-packages (from requests->chart_studio) (3.0.4)
Requirement already satisfied: idna<3,>=2.5 in /usr/local/lib/python3.7/dist-packages (from requests->chart_studio) (2.10)
Installing collected packages: chart-studio
Successfully installed chart-studio-1.1.0
In [ ]:
import pandas as pd
import numpy as np
import cufflinks as cf
from plotly.offline import download_plotlyjs, iplot, plot, init_notebook_mode
In [ ]:
init_notebook_mode(connected=True)
cf.go_offline()
In [ ]:
df = pd.DataFrame(np.random.rand(100, 4), columns='a b c d'.split())
df2 = pd.DataFrame({"Category": ["one", "two", "three"], "Count":[10, 20, 12]})
In [ ]:
def configure_plotly_browser_state():
  import IPython
  display(IPython.core.display.HTML('''
        <script src="/static/components/requirejs/require.js"></script>
        <script>
          requirejs.config({
            paths: {
              base: '/static/base',
              plotly: 'https://cdn.plot.ly/plotly-latest.min.js?noext',
            },
          });
        </script>
        '''))
In [ ]:
df.plot()
Out[ ]:
<matplotlib.axes._subplots.AxesSubplot at 0x7f35cc5fd5d0>
In [ ]:
configure_plotly_browser_state()
df.iplot()
In [ ]:
configure_plotly_browser_state()
df.iplot(kind="scatter", x='c', y='b', mode = 'markers', size = 5, color = 'red')
In [ ]:
configure_plotly_browser_state()
df.iplot(kind='bar')
In [ ]:
configure_plotly_browser_state()
df.mean().iplot(kind = 'bar', bins=20)
In [ ]:
configure_plotly_browser_state()
df.iplot(kind='box')
In [ ]:
#for surface plots in 3d
df3 = pd.DataFrame({'x':[1,2,3,4,5,6], 'y':[10,20,30,40,50,60], 'z':[120, 210, 130, 310, 410, 140]})
In [ ]:
configure_plotly_browser_state()
df3.iplot(kind='surface', colorscale="ylgnbu")
In [ ]:
configure_plotly_browser_state()
df['a'].iplot(kind = 'hist', bins=25)
In [ ]:
configure_plotly_browser_state()
df.iplot(kind='hist', bins = 25)
In [ ]:
configure_plotly_browser_state()
df[['a', 'b']].iplot(kind='spread')
/usr/local/lib/python3.7/dist-packages/cufflinks/plotlytools.py:849: FutureWarning:

The pandas.np module is deprecated and will be removed from pandas in a future version. Import numpy directly instead

/usr/local/lib/python3.7/dist-packages/cufflinks/plotlytools.py:850: FutureWarning:

The pandas.np module is deprecated and will be removed from pandas in a future version. Import numpy directly instead

In [ ]: