Black Lives Matter. Please consider donating to Black Girls Code today.

2 plot with custom button chooser (python)

I have two separate running code:
code 1:
#plotly bar

from plotly import version
from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot
import pandas as pd
#import numpy as np
import plotly.graph_objs as go

data = pd.read_csv(“hargaberas.csv”, sep=’;’)
data_df = pd.DataFrame(data, columns=[‘kota’,‘Th_2011’,‘Th_2012’,‘Th_2013’,‘Th_2014’,‘Th_2015’,‘Th_2016’])

data_plot = [
go.Bar(x=data[“Kota Harga Eceran”], y=data[“2011”],name=‘2011’),
go.Bar(x=data[“Kota Harga Eceran”], y=data[“2012”],name=‘2012’),
go.Bar(x=data[“Kota Harga Eceran”], y=data[“2013”],name=‘2013’)
]

plot({ ‘data’: data_plot,
‘layout’: {
‘title’: ‘Harga beras’,
‘xaxis’: {
‘title’: ‘Kota’},
‘yaxis’: {
‘title’: 'Rp / kg '}
}}, filename=‘plotly02.html’)

code 2:
#plotly line

from plotly import version
from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot
import pandas as pd
#import numpy as np
import plotly.graph_objs as go

data = pd.read_csv(“hargaberas.csv”, sep=’;’)
data_df = pd.DataFrame(data, columns=[‘kota’,‘Th_2011’,‘Th_2012’,‘Th_2013’,‘Th_2014’,‘Th_2015’,‘Th_2016’])

data_plot = [
go.Scatter(x=data[“Kota Harga Eceran”], y=data[“2011”],name=‘2011’),
go.Scatter(x=data[“Kota Harga Eceran”], y=data[“2012”],name=‘2012’),
go.Scatter(x=data[“Kota Harga Eceran”], y=data[“2013”],name=‘2013’)
]

plot({ ‘data’: data_plot,
‘layout’: {
‘title’: ‘Harga beras’,
‘xaxis’: {
‘title’: ‘Kota’},
‘yaxis’: {
‘title’: 'Rp / kg '}
}}, filename=‘plotly03.html’)

I want to merge those 2 codes above in one single file and make button to choose between line plot and bar plot. Anyone can give me suggestion?