... | ... | @@ -2,4 +2,95 @@ |
|
|
```plaintext
|
|
|
fig = plt.figure(figsize=(30,30))
|
|
|
subplots = set_subplots(3,4,0.1,0.2,0.03,0.02)
|
|
|
``` |
|
|
\ No newline at end of file |
|
|
```
|
|
|
## Plot line
|
|
|
```plaintext
|
|
|
axe = fig.add_axes(subplot)
|
|
|
axe.plot (data,color ="#000000",linewidth=2)
|
|
|
axe.set_xlabel("years",size=fs_axistitle)
|
|
|
axe.set_ylabel(file_name,size=fs_axistitle)
|
|
|
axe.set_xticks(np.arange(0,nb_year,20))
|
|
|
axe.set_xticklabels(np.arange(years[0],years[-1],20))
|
|
|
```
|
|
|
## Morocco Map
|
|
|
### All Morocco
|
|
|
```plaintext
|
|
|
axe = fig.add_axes(subplot,projection=ccrs.PlateCarree())
|
|
|
im = axe.imshow(data,extent=[-17.5,-1,21,36],cmap=yelgre,vmin=v_min,vmax=v_max)
|
|
|
axe.text(-17,35,file_name+" _ "+str(year),fontsize = fs_textongraph,weight="bold",rotation="horizontal")
|
|
|
axe.coastlines('50m', linewidth=0.7,edgecolor='black')
|
|
|
axe.add_feature(cfeature.BORDERS,linewidth=0.4,edgecolor='black')
|
|
|
axe.add_feature(cfeature.RIVERS,linewidth=0.6,edgecolor="white")
|
|
|
axe.set_xticks(np.arange(-15,-1,4))
|
|
|
axe.set_yticks(np.arange(23,36,4))
|
|
|
axe.tick_params(labelsize=fs_label,length=4, direction ="inout")
|
|
|
```
|
|
|
### North Morocco
|
|
|
```plaintext
|
|
|
axe = fig.add_axes(subplot,projection=ccrs.PlateCarree())
|
|
|
im = axe.imshow(data,extent=[-17.5,-1,21,36],cmap=yelgre,vmin=v_min,vmax=v_max)
|
|
|
axe.text(-11,37,file_name+" _ "+str(year),fontsize = fs_textongraph,weight="bold",rotation="horizontal")
|
|
|
axe.axis([-12,-1,29,38])
|
|
|
axe.coastlines('50m', linewidth=0.7,edgecolor='black')
|
|
|
axe.add_feature(cfeature.BORDERS,linewidth=0.4,edgecolor='black')
|
|
|
axe.add_feature(cfeature.RIVERS,linewidth=0.6,edgecolor="white")
|
|
|
axe.set_xticks(np.arange(-12,-1,2))
|
|
|
axe.set_yticks(np.arange(29,38,2))
|
|
|
axe.tick_params(labelsize=fs_label,length=4, direction ="inout")
|
|
|
```
|
|
|
## Brazil Map
|
|
|
```plaintext
|
|
|
fig = plt.figure(figsize=(30,30))
|
|
|
axe = fig.add_axes([0,0,0.2,0.2],projection=ccrs.PlateCarree())
|
|
|
im = axe.imshow(biomes,extent=[-74,-35,-32.5,5.5])
|
|
|
states_provinces = cfeature.NaturalEarthFeature(
|
|
|
category='cultural',
|
|
|
name='admin_1_states_provinces_lines',
|
|
|
scale='50m',
|
|
|
facecolor='none')
|
|
|
axe.add_feature(states_provinces, edgecolor='black')
|
|
|
axe.coastlines('50m', linewidth=0.4,edgecolor='black')
|
|
|
axe.add_feature(cfeature.BORDERS,linewidth=0.4,edgecolor='black')
|
|
|
axe.add_feature(cfeature.RIVERS,linewidth=0.6,edgecolor="white")
|
|
|
axe.set_xticks(np.append(np.append(-77,np.arange(-75,-30,5)),-32))
|
|
|
axe.set_yticks(np.append(np.append(-34,np.arange(-30,10,5)),7))
|
|
|
axe.set_xticklabels(np.append("",np.arange(-75,-30,5)))
|
|
|
axe.set_yticklabels(np.append("",np.arange(-30,10,5)))
|
|
|
axe.tick_params(labelsize=fs_label,length=4, direction ="inout")
|
|
|
```
|
|
|
## Colormap scaling
|
|
|
```plaintext
|
|
|
scale_map = []
|
|
|
suggest_scalemap = []
|
|
|
#scaling
|
|
|
if scale_map == []:
|
|
|
v_min = np.amin(data)
|
|
|
v_max = np.amax(data)
|
|
|
suggest_scalemap.append([file_name,v_min,v_max])
|
|
|
else :
|
|
|
v_min = scale_map[i][1]
|
|
|
v_max = scale_map[i][2]
|
|
|
#add at the end
|
|
|
print("Suggested scaling : ",suggest_scalemap)
|
|
|
```
|
|
|
## Legend
|
|
|
```plaintext
|
|
|
legends = [
|
|
|
mtplines.Line2D([0], [0], color="#2c7fb8", linewidth=2, linestyle="solid", label='Pasture Mapbiomas'),
|
|
|
mtplines.Line2D([0], [0], color="#2ca25f", linewidth=2, linestyle="solid", label='Grassland Mapbiomas'),
|
|
|
mtplines.Line2D([0], [0], color="#000000", linewidth=2, linestyle="solid", label='Pasture+Grassland Map'),
|
|
|
mtplines.Line2D([0], [0], color="#000000", linewidth=2, linestyle="dashed",label='Pasture LPJmL')
|
|
|
]
|
|
|
axe = fig.add_axes(subplots\[0\],frame_on=False, yticks=\[\],xticks=\[\]) axe.legend(handles = legends,fontsize=fs_legend,loc = 'upper left',ncol=2)
|
|
|
```
|
|
|
## Colorbar
|
|
|
|
|
|
- vertical on the right :
|
|
|
|
|
|
```plaintext
|
|
|
last_subplot = the subplot next to color bar
|
|
|
cbar_ax = fig.add_axes([last_subplot[0]+last_subplot[2]+0.02,last_subplot[1]+0.009,0.025,last_subplot[3]-0.02])
|
|
|
cbar=fig.colorbar(im, cax = cbar_ax,orientation="vertical")
|
|
|
cbar.ax.tick_params(labelsize=fs_legend,labelleft=False,labelright=True)
|
|
|
cbar.set_label(label=file_name,size=fs_legend,weight='bold')
|
|
|
``` |