text_html_output_2.png
import numpy as np

import pandas as pd

import plotly.graph_objects as go

import warnings

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import warnings
warnings.filterwarnings(action='ignore')
import plotly as py
import plotly.graph_objects as go
from plotly import tools
def drop(df):
    df = df.drop(df.index[0])
    return df
df_2017 = pd.read_csv('../input/kaggle-survey-2017/multipleChoiceResponses.csv', encoding='latin1')
df_2018 = pd.read_csv('../input/kaggle-survey-2018/multipleChoiceResponses.csv', encoding='latin1')
df_2019 = pd.read_csv('../input/kaggle-survey-2019/multiple_choice_responses.csv')
df_2020 = pd.read_csv('../input/kaggle-survey-2020/kaggle_survey_2020_responses.csv')
df_2018 = drop(df_2018)
df_2019 = drop(df_2019)
df_2020 = drop(df_2020)
num_qn = df_2020.columns
stat_2017 = df_2017['GenderSelect'][0:].value_counts()
f_2017 = round(stat_2017['Female'] / np.sum(stat_2017) * 100, 2)
stat_2018 = df_2018['Q1'][0:].value_counts()
f_2018 = round(stat_2018['Female'] / np.sum(stat_2018) * 100, 2)
stat_2019 = df_2019['Q2'][0:].value_counts()
f_2019 = round(stat_2019['Female'] / np.sum(stat_2019) * 100, 2)
stat_2020 = df_2020['Q2'][0:].value_counts()
f_2020 = round(stat_2020['Woman'] / np.sum(stat_2020) * 100, 2)

color = ['rgb(49,130,189)']
color_m = ['rgb(49,130,189)', '#de6560']
mode_size = [12]
line_size = [5]
x_data = np.vstack((np.arange(2017, 2021),) * 1)
y_data = np.array([[f_2017, f_2018, f_2019, f_2020]])
fig = go.Figure()
for i in range(0, 1):
    fig.add_trace(go.Scatter(x=x_data[i], y=y_data[i], mode='lines', line=dict(color=color[i], width=line_size[i]), connectgaps=True))
    fig.add_trace(go.Scatter(x=[x_data[i][0], x_data[i][-1]], y=[y_data[i][0], y_data[i][-1]], mode='markers', marker=dict(color=color_m[i], size=mode_size[i])))
fig.update_layout(title="<span style='color:#000; font-size:25px; font-family:PT Sans'>Relative number of female participants</span>", xaxis=dict(showline=True, showgrid=False, showticklabels=True, linecolor='rgb(204, 204, 204)', linewidth=2, ticks='outside', tickfont=dict(family='PT sans', size=15, color='rgb(82, 82, 82)')), yaxis=dict(showgrid=False, zeroline=False, showline=False, showticklabels=False), autosize=False, margin=dict(autoexpand=True, l=200, r=20, t=100), width=600, height=400, showlegend=False, plot_bgcolor='white')
annotations = []
for y_trace, color in zip(y_data, color):
    annotations.append(dict(xref='paper', x=0.04, y=y_trace[0], xanchor='left', yanchor='bottom', text='{}%'.format(y_trace[0]), font=dict(family='PT sans', size=18, color='rgb(82, 82, 82)'), showarrow=False))
    annotations.append(dict(xref='paper', x=0.9, y=y_trace[3], xanchor='right', yanchor='middle', text='{}%'.format(y_trace[3]), font=dict(family='PT sans', size=18, color='rgb(82, 82, 82)'), showarrow=False))
annotations.append(dict(xref='paper', yref='paper', x=0.5, y=-0.2, xanchor='center', yanchor='top', text='Source: 2017 - 2020 Kaggle Machine Learning & ' + 'Data Science Survey', font=dict(family='PT sans', size=12, color='rgb(150,150,150)'), showarrow=False))
fig.update_layout(annotations=annotations)
fig.show()