import pandas as pd
import plotly.express as px
from plotly.offline import plot, iplot, init_notebook_mode
init_notebook_mode(connected=True)

coups = pd.read_csv('coups_all.csv')
# coups = pd.read_csv('coups_2000.csv')
import plotly.graph_objects as go

fig = go.Figure(data=go.Choropleth(
    locations = coups['code'],
    z = coups['COUNTA of coup_id'],
    text = coups['country'],
    colorscale = 'plasma',
    marker_line_color='gray',
    marker_line_width=0.5,
    colorbar_title = 'No. of Coups',
))

fig.update_layout(
    autosize=True,
#     width=1000,
    height=1000,
    template="plotly_dark",
    margin=
        {
        "r":0,"t":0,"l":0,"b":0,
        "pad": 0,
#         "autoexpand": False
        },
    title_text="Number of Coups",
    title_font_size=14,
    title_xanchor="center",
    title_x=0.5,
    geo=dict(
        showframe=False,
        projection_type='equirectangular'
    ),
)

fig.update_layout(
    paper_bgcolor='black',
    plot_bgcolor='black',
    geo_bgcolor='black',
    legend_title = dict(font = dict(color = "white")),
    dragmode=False,
)

fig.update_traces(
    colorbar_orientation="h",
    colorbar_thickness=10,
    colorbar_yanchor="bottom",
    colorbar_title=" ",
    colorbar_len=0.6,
    selector=dict(type='choropleth')
)
fig.show()
import pandas as pd
import plotly.express as px

gdp = pd.read_csv('gdp.csv')

gdp['GDPchange'] = gdp.apply(lambda x: x['GDPchange'][:-1] , axis=1)
gdp['GDPchange'] = gdp['GDPchange'].str[:-1].astype(float)
gdp
Year GDPchange
0 1994 3.2
1 1995 4.4
2 1996 11.6
3 1997 6.5
4 1998 -28.1
5 1999 1.0
6 2000 5.4
7 2001 2.1
8 2002 -0.9
9 2003 0.5
10 2004 2.7
11 2005 4.2
12 2006 2.3
13 2007 3.2
14 2008 3.2
15 2009 3.3
16 2010 4.6
17 2011 8.0
18 2012 -1.7
19 2013 3.2
20 2014 0.9
21 2015 6.1
22 2016 6.2
23 2017 5.9
gdp['GDPchange'].dtype
dtype('float64')
import plotly.graph_objects as go

fig = px.bar(gdp, x='Year', y='GDPchange',
         template="plotly_dark")

config = {
    'displayModeBar': False,
    'showAxisDragHandles': True,
    'showAxisRangeEntryBoxes' : False,
    'editable': False,
    'doubleClick': False
         }
fig.update_xaxes(fixedrange=True)
fig.update_yaxes(fixedrange=True)
fig.update_traces(marker_line_color='rgb(8,48,107)',
                  marker_line_width=1, opacity=0.6)

fig.show(config=config)