- 追加された行はこの色です。
- 削除された行はこの色です。
#author("2020-06-20T11:00:07+00:00","default:f-lab","f-lab")
#author("2020-06-30T13:57:24+00:00","default:f-lab","f-lab")
[[seminar-personal/tei2020]]
[[seminar-personal/tei2020]]&br;
[[N班ゼミ>http://f-lab.mydns.jp/index.php?seminar-N-2020]]
|~目次|
|#contents|
&br;
*保健所の座標データを読んで、MatPlotLibで保健所の分布を表示する[#h6efba04]
-座標はGIS座標をそのまま使う
-点の横に保健所の名前を表示する
--
import pandas as pd
import matplotlib.pyplot as plt
#日本語表示
import seaborn as sns
sns.set(font='IPAGothic')
df=pd.read_csv("3-2_hokennjotou.csv")
x=df['X座標']
y=df['Y座標']
place=df['名称']
plt.scatter(x,y)
plt.title('保健所座標図分布')
plt.xlabel("x")
plt.ylabel("y")
for i in range(len(x)):
plt.annotate(place[i], xy=(x[i],y[i]))
plt.show()
--
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
sns.set(font='IPAGothic')#文字化け対策
f="3-2_hokennjotou.csv"
df = pd.read_csv(f,delimiter =",")#csvを読み込み
row_len = len(df.index)
for i in range(row_len):
x=df.iat[i,3]#x座標を取得
y=df.iat[i,4]#y座標
name=df.iat[i,0]#施設名を取得
plt.title('保健所座標図分布')
plt.plot(x,y,'o',color='b')#点表示
plt.annotate(name, xy=(x, y))#施設名を追加
plt.show()
--結果
&ref(tei2020-20200626/result.jpg,50%);
*参照資料 [#a7f564eb]
1、
[[scatterについて>https://ai-inter1.com/python-scatterplot/]]