In [1]:
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib.image as image
%matplotlib inline
plt.xkcd()


Out[1]:
<matplotlib.rc_context at 0x19a7f7eff28>

In [2]:
start='20130428'
end='20190112'

In [46]:
def plotter(currency,i,c='orange',st='2012-12-20',last='2017'):
    dfs=pd.read_html('https://coinmarketcap.com/currencies/'+currency+'/historical-data/?start='+start+'&end='+end)
    df=dfs[0]
    df=df[['Date','Close**']]
    df.columns=['Date','.']
    df['Date']=pd.to_datetime(df['Date'])
    fig,ax=plt.subplots(figsize=(13,6))
    df[(last>df['Date'])&(df['Date']>'2013')].set_index('Date').plot(ax=ax,c='grey')
    ax2=ax.twiny()
    ax2=ax2.twinx()
    dz=df[df['Date']>'2017'].set_index('Date')
    dz.columns=[u'Before and after the last bubble\n2013-2016 (bottom + left axis)']
    dz.plot(ax=ax2,c='grey')
    dz.columns=[currency.capitalize()+u' price in $ since 2017 (top + right axis)']
    dz.plot(ax=ax2,c=c)
    ax.set_xlim(st,pd.to_datetime(st)+pd.to_timedelta(3, unit='Y'))
    ax2.set_xlim('2017','2020')
    ax.set_xlabel('')
    ax2.legend()
    im = image.imread('https://s2.coinmarketcap.com/static/img/coins/32x32/'+str(i)+'.png')
    ax3 = fig.add_axes([0.14, 0.7, 0.07, 0.07])
    ax3.axis('off')
    ax3.imshow(im)
    ttl1='peak: '+str(int(max(df[df['Date']>'2017']['.'])/max(df[df['Date']<'2017']['.'])))+'x'
    ttl2='latest: '+str(round(df.loc[df.index[0]].values[1]/max(df[df['Date']<'2017']['.']),2))+'x'
    ax3.set_title(ttl1+'\n'+ttl2,color=c,)
    plt.savefig(currency)

In [48]:
plotter('bitcoin',1,'orange')


C:\ProgramData\Anaconda3\lib\site-packages\ipykernel_launcher.py:6: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  

In [49]:
plotter('litecoin',2,'lightgrey')


C:\ProgramData\Anaconda3\lib\site-packages\ipykernel_launcher.py:6: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  

In [50]:
plotter('ripple',52,'black','2012-11-30')


C:\ProgramData\Anaconda3\lib\site-packages\ipykernel_launcher.py:6: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  

In [51]:
plotter('dash',131,'dodgerblue','2013-06-07')


C:\ProgramData\Anaconda3\lib\site-packages\ipykernel_launcher.py:6: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  

In [52]:
plotter('namecoin',3,'lightsteelblue','2012-11-18')


C:\ProgramData\Anaconda3\lib\site-packages\ipykernel_launcher.py:6: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  

In [53]:
plotter('dogecoin',74,'darkkhaki','2013-01-22')


C:\ProgramData\Anaconda3\lib\site-packages\ipykernel_launcher.py:6: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  

In [54]:
plotter('bytecoin-bcn',372,'deeppink','2013-02-15')


C:\ProgramData\Anaconda3\lib\site-packages\ipykernel_launcher.py:6: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  

In [55]:
plotter('nxt',66,'deepskyblue','2013-06-15')


C:\ProgramData\Anaconda3\lib\site-packages\ipykernel_launcher.py:6: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  

In [56]:
plotter('nem',873,'mediumturquoise','2015-06-25','2017-02')


C:\ProgramData\Anaconda3\lib\site-packages\ipykernel_launcher.py:6: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  

In [57]:
plotter('peercoin',5,'limegreen')


C:\ProgramData\Anaconda3\lib\site-packages\ipykernel_launcher.py:6: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  

In [58]:
plotter('feathercoin',8,'black','2012-11-20')


C:\ProgramData\Anaconda3\lib\site-packages\ipykernel_launcher.py:6: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  

In [ ]:


In [ ]:


In [ ]: