def plot_map_native(lon_corners, lat_corners, data, **kwargs): from matplotlib import pyplot, patches, path import numpy # Fix longitude coordinates; we need longitudes to run from # -180 to 180, not from 0 to 360 lon_corners.values = numpy.where(lon_corners > 180, lon_corners - 360, lon_corners) # Loop over GLL nodes and create paths that describe the boundaries # of each node; collect these into a list to plot all at once path_list = [] for icol in range(lon_corners.shape[0]): # Get corners for this node x_corners = lon_corners[icol, :].values y_corners = lat_corners[icol, :].values # Repeat first vertex at end of array to close the path x_corners = numpy.append(x_corners, x_corners[0]) y_corners = numpy.append(y_corners, y_corners[0]) # Create paths connecting the corners and append to list vertices = numpy.column_stack([x_corners, y_corners]) path_list.append(path.Path(vertices, closed=True)) # Plot collection of patches from matplotlib.collections import PathCollection collection = PathCollection(path_list, transform=crs.Geodetic(), **kwargs) collection.set_array(data) ax = pyplot.gca() pl = ax.add_collection(collection) return pl
#서울 구별 인구수 반영 그림 그리기 fig = plt.figure() ax = plt.gca() for x in range(len(seoul)): coord = seoul[x]['geometry'] verts = coord['coordinates'][0] patch = Polygon.Polygon( verts, facecolor=seoulcolor[seoul[x]['properties']['SIG_KOR_NM']], ec='k') cols.append(patch) ax.add_patch(patch) plt.autoscale() plt.axis('off') p = PathCollection(cols, cmap=cm.Blues) p.set_array(np.array(colors)) ax.add_collection(p) ax.autoscale_view() plt.colorbar(p) plt.show() #Draw Heat Map dx, dy = 0.15, 0.05 y, x = np.mgrid[slice(-3, 3 + dy, dy), slice(-3, 3 + dx, dx)] z = (1 - x / 2. + x**5 + y**3) * np.exp(-x**2 - y**2) z = z[:-1, :-1] z_min, z_max = -np.abs(z).max(), np.abs(z).max() plt.pcolor(x, y, z, cmap='RdBu', vmin=z_min, vmax=z_max)