换一种说法?
matplotlib
如果繁荣的话
资料来源
https://www.stat.go.jp/data/nihon/02.html
使用python 1制作时
如果没有树形图库,请
1 | pip3 install squarify |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | # lib import pandas as pd import squarify #Treemap Ploting import matplotlib from matplotlib import style import matplotlib.pyplot as plt import seaborn as sns # Activate Seaborn sns.set() %matplotlib inline # サイズとフォント設定 matplotlib.rcParams['figure.figsize'] = (16.0, 9.0) plt.rcParams['font.family'] = 'Hiragino Sans' plt.rcParams['font.weight'] = 'bold' # ggplot style使用 style.use('ggplot') # dataframe 作成 population = [7369,3788,14360,21356,19476,22431,43248] label = ["中国(5.58%)","四国(2.87%)","九州?沖縄\n(10.88%)","中部(16.18%)","北海道?東北(14.75%)","関西(16.99%)","関東(32.76%)"] percentage = [5.58,2.87,10.88,16.18,14.75,16.99,32.76] df = pd.DataFrame({"Population":population,"Label":label,"Percentage":percentage}) fig, ax = plt.subplots() # Colormap cmap = matplotlib.cm.Blues # Min and Max Values mini = min(df["Population"]) maxi = max(df["Population"]) # colors setting norm = matplotlib.colors.Normalize(vmin=mini, vmax=maxi) colors = [cmap(norm(value)) for value in df["Population"]] # Plotting squarify.plot(sizes=df["Population"], label=df["Label"], alpha=0.8, color=colors, text_kwargs={'fontsize':24,'color':'grey'}) # 軸削除 plt.axis('off') # y軸逆に plt.gca().invert_yaxis() # タイトル、位置設定 plt.title("日本の地域別人口比率", fontsize=32,fontweight="bold") ttl = ax.title ttl.set_position([.5, 1.05]) # 背景色 fig.set_facecolor('#eeffee') |
就像这样。
有点废话...
因此,我将尝试使用蓬勃发展的服务:https://app.flourish.studio/可以很好地可视化。
使用旺盛时
请使用您的Google帐户注册。
选择新项目
选择树形图
您可以使用
创建它。
这次使用的数据如下。
嵌套是按地区→县设置的。
当然,Size by指定了2017年的估计人口。
如您所见,您可以使用日语,并且可以像电子表格工具(例如Excel)一样操作它。
我将使用蓬勃发展重新发布树形图。
(当您正常下载标签时,标签会消失,因此我正在截图)
https://mubaris.com/posts/dataviz-treemaps/?