CJYen 3 年 前
コミット
2f7200c0bb
4 ファイル変更59 行追加0 行削除
  1. 9 0
      README.md
  2. 40 0
      api/main.py
  3. 10 0
      chart.html
  4. BIN
      result/img.jpg

+ 9 - 0
README.md

@@ -0,0 +1,9 @@
+### Required
+---
+- plotly
+- plotly_express
+- pandas
+
+### Result
+---
+![result](./result/img.jpg)

+ 40 - 0
api/main.py

@@ -0,0 +1,40 @@
+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')

ファイルの差分が大きいため隠しています
+ 10 - 0
chart.html


BIN
result/img.jpg


この差分においてかなりの量のファイルが変更されているため、一部のファイルを表示していません