12345678910111213141516171819202122232425262728293031323334353637383940 |
- import plotly_express as px
- import pandas as pd
- import plotly
- # Read data from excel
- df = pd.read_csv("../docs/keyword.csv")
- keyword = df['Keyword']
- # competition = df['Competition (indexed value)']
- bid = df['Top of page bid (low range)']
- search = df['Avg_monthly_searches']
- margin = df['Top of page bid (low range)']
- remark = df['Keyword']
- # Create chart and store as figure [fig]
- fig = px.treemap(df,
- path=[keyword, bid],
- values=search,
- color=margin,
- # color_continuous_scale=['green', 'yellow', 'red'],
- color_continuous_scale=px.colors.sequential.Peach,
- title='Keyword Overview',
- hover_name=remark,
- )
- fig.update_traces(root_color="lightgrey")
- # Update/change layout
- fig.update_layout(title_font_size=42,
- title_font_family='Arial',
- margin=dict(t=50, l=25, r=25, b=25)
- )
- fig.show()
- # save chart and export to HTML
- plotly.offline.plot(fig, filename='../chart.html')
|