In [1]:
import colouringmap.mapping_polygon as clrm

In [ ]:


In [2]:
import geopandas as gpd
import matplotlib.pyplot as plt

%matplotlib inline

In [3]:
gdf = gpd.read_file('testdata/county.shp')
gdf.head()


Out[3]:
area countyid countyname geometry sname
0 3.021043e+07 09007 連江縣 (POLYGON Z ((146283.1604209603 2871066.8554912... LC
1 1.533424e+08 09020 金門縣 (POLYGON Z ((-20263.56102071883 2700396.142658... KM
2 2.187868e+09 10002 宜蘭縣 POLYGON Z ((346918.5626321062 2764840.74850919... YLA
3 1.411293e+09 10004 新竹縣 POLYGON Z ((253991.8906249989 2759599.75 0, 25... HCX
4 1.826677e+09 10005 苗栗縣 POLYGON Z ((241095.5468749994 2736146.24999999... ML

In [4]:
fig,ax = plt.subplots(figsize=(7,7))
ax = clrm.prepare_map(ax, map_context=gdf, background_colour='skyblue')
ax = clrm.map_category(gdf, 'countyname', ax, lw=0., add_legend=False)#cat_order=[u'宜蘭縣',u'新竹縣',u'苗栗縣'])
ax = clrm.add_border(gdf, ax, lw=1.5, ec='#000000', alpha=0.2)
ax = clrm.add_label(gdf, ax, 'countyname', font_colour='blue')
ax.set_title('county')


22
[8, 20, 1, 13, 11, 18, 9, 3, 19, 5, 7, 15, 10, 6, 21, 12, 4, 16, 14, 0, 17, 2] None
!!!
number of colour is less then number of category
colours will be repeating
!!!
countyname
Out[4]:
<matplotlib.text.Text at 0x7f94114bc910>

In [5]:
fig,ax = plt.subplots(figsize=(7,7))
ax = clrm.prepare_map(ax, map_context=gdf, background_colour='royalblue')
ax = clrm.map_sequence(gdf, 'area', ax, lw=0.)
ax = clrm.add_border(gdf, ax, lw=1.5, ec='#000000', alpha=0.3)
ax.set_title('areaa')


Out[5]:
<matplotlib.text.Text at 0x7f94119bebd0>

In [6]:
fig,ax = plt.subplots(figsize=(7,7))
#ax.set_facecolor('cornflowerblue')
ax = clrm.prepare_map(ax, map_context=gdf, background_colour='skyblue')
ax = clrm.map_shape(gdf, ax)
ax = clrm.add_border(gdf, ax, lw=1., ec='white')
ax = clrm.add_label(gdf, ax, 'countyname', font_colour='navy', font_size=8)


countyname

In [7]:
import random
fig,ax = plt.subplots(figsize=(7,7))
#ax.set_facecolor('cornflowerblue')
ax = clrm.prepare_map(ax, map_context=gdf, background_colour='skyblue')
clrs = []
for i in range(len(gdf)):
    clrs.append((random.random(),random.random(),random.random()))
gdf['clrs'] = clrs
ax = clrm.map_colour(gdf, 'clrs', ax)



In [8]:
fig,ax = plt.subplots(figsize=(7,7))
#ax.set_facecolor('cornflowerblue')
ax = clrm.prepare_map(ax, map_context=gdf, background_colour='skyblue', show_xy=True)
ax = clrm.map_shape(gdf, ax)
ax = clrm.add_border(gdf, ax, lw=.1, ec='white')
ax = clrm.add_label(gdf, ax, 'countyname', font_colour='navy', font_size=8)
ax = clrm.add_scalebar(ax)
ax.tick_params(top='on', right='on')


countyname

In [ ]:


In [ ]:


In [ ]: