def plot_coords(ground_truth, coords, degree_range=0.0001): tilemapbase.start_logging() tilemapbase.init(create=True) t = tilemapbase.tiles.build_OSM() degree_range = degree_range center_lat = np.mean(np.array([coord[0] for coord in ground_truth])) center_lon = np.mean(np.array([coord[1] for coord in ground_truth])) extent = tilemapbase.Extent.from_lonlat(center_lon - degree_range, center_lon + degree_range, center_lat - degree_range, center_lat + degree_range) extent = extent.to_aspect(1.0) fig, ax = plt.subplots(figsize=(8, 8), dpi=100) ax.xaxis.set_visible(False) ax.yaxis.set_visible(False) plotter = tilemapbase.Plotter(extent, t, width=600) plotter.plot(ax, t) # for coord in ground_truth: # x, y = tilemapbase.project(coord[1], coord[0]) # ax.scatter(x,y, marker="*", color="red", linewidth=5) for idx, coord in enumerate(coords): x, y = tilemapbase.project(coord[2], coord[1]) ax.scatter(x, y, marker=".", c=(0, 1 - (1 / len(coords)) * idx, (1 / len(coords)) * idx), linewidth=1) plt.show()
def draw(df, id_col, val_col, extent, color_selector, figsize=(8, 8), dpi=100, width=600, alpha=0.8, axis_visible=False, **kwargs): fig, ax = plt.subplots(figsize=figsize, dpi=dpi) ax.xaxis.set_visible(axis_visible) ax.yaxis.set_visible(axis_visible) t = tmb.tiles.build_OSM() plotter = tmb.Plotter(extent, t, width=width) plotter.plot(ax, t) add_color_bar(df, val_col, fig, color_selector, **kwargs) n = len(df) for i in range(n): id = df[id_col].iloc[i] val = df[val_col].iloc[i] color = color_selector(val) vts = _swap(h3.h3_to_geo_boundary(id)) xys = [tmb.project(*x) for x in vts] poly = plt.Polygon(xys, fc=color, alpha=alpha) ax.add_patch(poly) fig.text(0.86, 0.125, '© DATAWISE', va='bottom', ha='right') return fig, ax
def printRoute(self, dpi, width): tilemapbase.start_logging() tilemapbase.init(create=True) t = tilemapbase.tiles.build_OSM() if self.s[0] < self.e[0]: south = self.s[0] north = self.e[0] else: south = self.e[0] north = self.s[0] if self.s[1] < self.e[1]: east = self.s[1] west = self.e[1] else: east = self.e[1] west = self.s[1] degree_range = 0.1 extent = tilemapbase.Extent.from_lonlat(east - degree_range, west + degree_range, south - degree_range, north + degree_range) fig, ax = plt.subplots(figsize=(8, 8), dpi=dpi) plotter = tilemapbase.Plotter(extent, t, width=width) plotter.plot(ax, t) for i in self.routeLatLons: x, y = tilemapbase.project(i[1], i[0]) ax.scatter(x, y, marker=".", color="black", linewidth=2) plt.show()
def drawp(df, poly_col, val_col, extent, color_selector, figsize=(8, 8), dpi=100, width=600, alpha=0.8): fig, ax = plt.subplots(figsize=figsize, dpi=dpi) ax.xaxis.set_visible(False) ax.yaxis.set_visible(False) t = tmb.tiles.build_OSM() plotter = tmb.Plotter(extent, t, width=width) plotter.plot(ax, t) n = len(df) for i in range(n): val = df[val_col].iloc[i] color = color_selector(val) vts = df[poly_col].iloc[i]["coordinates"][0] xys = [tmb.project(*x) for x in vts] poly = plt.Polygon(xys, fc=color, alpha=alpha) ax.add_patch(poly) fig.text(0.86, 0.125, '© DATAWISE', va='bottom', ha='right') return fig, ax
def plotLocation(df, df2=None): # Sensor locations latSensor = [50.12565556, 50.10290556, 50.12691389] lonSensor = [8.69305556, 8.54222222, 8.74861111] # Create a basic map using OpenStreetMap centerPoint = (8.69305556, 50.12565556) degree_range = 0.1 extent = tilemapbase.Extent.from_lonlat( centerPoint[0] - 1.6 * degree_range, centerPoint[0] + degree_range, centerPoint[1] - degree_range, centerPoint[1] + degree_range) extent = extent.to_aspect(1.0) plotter = tilemapbase.Plotter(extent, t, width=600) fig, ax = plt.subplots(figsize=(8, 8), dpi=100) plotter.plot(ax, t) plotxSensor = [] plotySensor = [] for i in range(len(latSensor)): setTEMP = (lonSensor[i], latSensor[i]) x, y = tilemapbase.project(*setTEMP) plotxSensor.append(x) plotySensor.append(y) lonTEMP = df["Lon"] latTEMP = df["Lat"] plotx = [] ploty = [] for i in range(len(lonTEMP)): setTEMP = (lonTEMP.iloc[i], latTEMP.iloc[i]) x, y = tilemapbase.project(*setTEMP) plotx.append(x) ploty.append(y) ax.scatter(plotx, ploty, label="Loops") ax.scatter(plotxSensor, plotySensor, label="Sensor") plotx_add = [] ploty_add = [] if df2 is not None: colList = [ df2.columns[i] for i in range( 1, df2.columns.get_loc("Stickstoffmonoxid (NO)[µg/m³]")) ] for column in colList: location = df[df["ElemUID"] == int(column)] setTEMP = (location["Lon"].values[0], location["Lat"].values[0]) x, y = tilemapbase.project(*setTEMP) plotx_add.append(x) ploty_add.append(y) ax.scatter(plotx_add, ploty_add, c="green", label="Reduced Loops") plt.legend() plt.show()
def plot_path_to_png(timezone='2017-03-28 15:22:00.000000', shapefile='./shapefiles/speedy_Como_dataset.shp', image_save_path='./images/'): # verifico che il path non sia già stato generato file_timezone = timezone.replace('.', '').replace(' ', '__').replace(':', '_') image_path = ospath.join(image_save_path, file_timezone) + '.png' if ospath.isfile(image_path): # in tal caso lo ritorno print('Image already existing at: ' + image_path) return image_path[1:] tmp.init(create=True) t = tmp.tiles.build_OSM() initiated = True tmp.start_logging() print("Opening shapefile...") with fiona.open(shapefile) as np: meta = np.meta paths = [] for feature in np: if feature['properties']['time_zone'] == timezone: paths.append(feature) print("Done.") tzgdf = gpd.GeoDataFrame.from_features(paths) extent = extent_from_frame(tzgdf) extent = extent.to_aspect(1.0) extent = extent.with_scaling(0.8) print("Plotting path...") fig, ax = plt.subplots(figsize=(8, 8), dpi=300) ax.xaxis.set_visible(False) ax.yaxis.set_visible(False) plotter = tmp.Plotter(extent, t, width=600) points = points_from_frame(tzgdf) plotter.plot(ax, t) plt.plot(*points) ts = time.time() print("Done, saving image...") plt.savefig(image_path, dpi=300, bbox_inches='tight') print("Done. Image saved as: " + image_path) return image_path[1:]
def plot_basemap(self, ax, tgt_srid): xmin, ymin, xmax, ymax = self.get_bbox(tgt_srid=4326) extent = tilemapbase.Extent.from_lonlat(xmin, xmax, ymin, ymax) extent = extent.to_project_3857() plotter = tilemapbase.Plotter(extent, self.tile_map_base, width=self.basemap_width) plotter.plot(ax, self.tile_map_base, zorder=-1)
def get_image(self): fig, ax = plt.subplots(figsize=(10, 10), dpi=500) ax.xaxis.set_visible(False) ax.yaxis.set_visible(False) plotter = tilemapbase.Plotter(self.extent, self.tiles, width=1000) plotter.plot(ax, self.tiles) return plotter.as_one_image()
def plot_map(current_position): extent = tilemapbase.Extent.from_lonlat(current_position[0] - degree_range, current_position[0] + degree_range, current_position[1] - degree_range, current_position[1] + degree_range) extent = extent.to_aspect(1.0) fig, ax = plt.subplots(figsize=(8, 8), dpi=100) ax.xaxis.set_visible(False) ax.yaxis.set_visible(False) plotter = tilemapbase.Plotter(extent, t, width=600) plotter.plot(ax, t, picker=True) return fig
def get_base_map(edges, zoom=12, dpi=600, t=None): tilemapbase.start_logging() tilemapbase.init(create=True) if not t: t = tilemapbase.tiles.Carto_Light_No_Labels extent = tilemapbase.Extent.from_lonlat(edges["west"], edges["east"], edges["south"], edges["north"]) fig, ax = plt.subplots(dpi=dpi) ax.xaxis.set_visible(False) ax.yaxis.set_visible(False) plotter = tilemapbase.Plotter(extent, t, zoom=zoom) plotter.plot(ax, t) return ax, extent
def gps_carte_fond(self): #print(self.fenetre_graph.Matrice) if self.fenetre_graph.update_graph.Matrice is not None : #print(self.Longitude,self.Latitude) self.centre = (np.mean(self.Longitude[0]),np.mean(self.Latitude[0])) #self.centre = (-1.7458099,48.0453455) self.marge = 0.002 self.extent = tilemapbase.Extent.from_lonlat(self.centre[0] - self.marge, self.centre[0] + self.marge,self.centre[1] - self.marge, self.centre[1] + self.marge) self.extent = self.extent.to_aspect(1.0) self.plotter = tilemapbase.Plotter(self.extent, tilemapbase.tiles.build_OSM(), width=400) self.plotter.plot(self.axe,tilemapbase.tiles.build_OSM()) #self.plot.show() self.graph.draw() self.affichage_carte = True
def gps_carte_fond(self,centre,i): self.centre = (centre[0],centre[1]) if not self.trace: #self.centre = (-1.7458099,48.0453455) self.marge = 0.003 self.extent = tilemapbase.Extent.from_lonlat(self.centre[0] - self.marge, self.centre[0] + self.marge,self.centre[1] - self.marge, self.centre[1] + self.marge) self.extent = self.extent.to_aspect(1.0) self.plotter = tilemapbase.Plotter(self.extent, tilemapbase.tiles.build_OSM(), width=500, height=500) self.trace = True self.plotter.plot(self.axe,tilemapbase.tiles.build_OSM()) #self.plot.show() self.graph.draw() i += 1 if i == 500: self.trace = False i = 0 return i
def plot_path_to_png(timezone='2017-03-28 15:22:00.000000', shapefile='./shapefiles/speedy_Como_dataset.shp'): if not initated: init() print("Opening shapefile...") with fiona.open(shapefile) as np: meta = np.meta paths = [] for feature in np: if feature['properties']['time_zone'] == timezone: paths.append(feature) print("Done.") tzgdf = gpd.GeoDataFrame.from_features(paths) extent = extent_from_frame(tzgdf) extent = extent.to_aspect(1.0) extent = extent.with_scaling(0.8) print("Plotting path...") fig, ax = plt.subplots(figsize=(8, 8), dpi=300) ax.xaxis.set_visible(False) ax.yaxis.set_visible(False) plotter = tmp.Plotter(extent, t, width=600) points = points_from_frame(tzgdf) plotter.plot(ax, t) plt.plot(*points) ts = time.time() print("Done, saving image...") image_path = 'path' + str(ts).replace('.', '') + '.png' plt.savefig(image_path, dpi=300) print("Done. Image saved as: " + image_path) return image_path
def _draw_png(df, lats, lngs, p_size, p_color, l_size, l_color, figsize=(8, 8), dpi=100, axis_visible=False, padding=0.03, adjust=True): ex1 = tmb.Extent.from_lonlat(min(lngs), max(lngs), min(lats), max(lats)) ex2 = _expand(ex1, padding) extent = ex2.to_aspect(figsize[0] / figsize[1], shrink=False) if adjust else ex2 fig, ax = plt.subplots(figsize=figsize, dpi=dpi) ax.xaxis.set_visible(axis_visible) ax.yaxis.set_visible(axis_visible) t = tmb.tiles.build_OSM() plotter = tmb.Plotter(extent, t, width=figsize[0] * 100, height=figsize[1] * 100) plotter.plot(ax, t) ps = [tmb.project(x, y) for x, y in zip(lngs, lats)] xs = [p[0] for p in ps] ys = [p[1] for p in ps] n = len(df) for i in range(n - 1): l2 = lines.Line2D(xs[i:(i + 2)], ys[i:(i + 2)], linewidth=l_size[i], color=l_color[i]) ax.add_line(l2) for i in range(n): x, y = ps[i] ax.plot(x, y, marker=".", markersize=p_size[i], color=p_color[i]) fig.text(0.8875, 0.125, '© DATAWISE', va='bottom', ha='right') return fig, ax
def gps_carte_fond(self, i): #print(self.fenetre_graph.Matrice) #print(self.Longitude,self.Latitude) #rint(self.matrice is not None) if not self.trace: if self.matrice is not None: #print('tracé') if None is not None: self.centre = (self.position_antenne[1], self.position_antenne[0]) else: self.centre = (np.mean(self.Longitude[0]), np.mean(self.Latitude[0])) print("centre : ", self.centre) print("self.position_antenne :", self.position_antenne) #self.centre = (-1.7458099,48.0453455) self.marge = 0.003 self.extent = tilemapbase.Extent.from_lonlat( self.centre[0] - self.marge, self.centre[0] + self.marge, self.centre[1] - self.marge, self.centre[1] + self.marge) self.extent = self.extent.to_aspect(1.0) self.plotter = tilemapbase.Plotter( self.extent, tilemapbase.tiles.build_OSM(), width=500, height=500) self.trace = True self.plotter.plot(self.axe, tilemapbase.tiles.build_OSM()) #self.plot.show() self.graph.draw() i += 1 if i == 500: self.trace = False i = 0 return i
def osm_plot(path): path = np.array(path) path = path[:, 0:2] margins = [38.1598, 38.163, -122.457, -122.451] # lats, lons degree_range = 0.0015 extent = tilemapbase.Extent.from_lonlat( latitude_min=margins[0] - degree_range, latitude_max=margins[1] + degree_range, longitude_min=margins[2] - degree_range, longitude_max=margins[3] + degree_range) extent = extent.to_aspect(1.0) points = np.array( [tilemapbase.project(*waypoint[::-1]) for waypoint in path]) x, y = points[:, 0], points[:, 1] # x, y = tilemapbase.project(*goal_loc[::-1]) fig, ax = plt.subplots(figsize=(6, 6)) plotter = tilemapbase.Plotter(extent, tile_provider=tilemapbase.tiles.build_OSM(), width=600) plotter.plot(ax) ax.scatter(x[0], y[0], marker=".", color="black", linewidth=10) ax.scatter(x[-1], y[-1], marker="x", color="red", linewidth=2) ax.plot(x, y, linewidth=2) ax.scatter(x, y, marker=".", color="green", linewidth=1) plt.xlabel('Longitude') plt.ylabel('Latitude') plt.xticks([]), plt.yticks([]) plt.tight_layout() ax.grid(b=True, which='major', color='#666666', linestyle='-') ax.minorticks_on() ax.grid(b=True, which='minor', color='#999999', linestyle='-', alpha=0.2) plt.show()
try: if (sighting['snr'] > 20.0) and (float( sighting['plane.geo_altitude']) > midrange_vis_height): obsdict = { 'icao24': sighting['icao24'], 'latitude': sighting['latitude'], 'longitude': sighting['longitude'], 'last_contact': sighting['last_contact'] } newlist.append(obsdict) except TypeError: print('record type issue') #print(newlist) ## print(' from ' + time.strftime('%m/%d/%Y %H:%M:%S', time.gmtime(tamydalist[0]['last_contact'])),end = '') # print(' to ' + time.strftime('%m/%d/%Y %H:%M:%S', time.gmtime(mydatalist[-1]['last_contact']))) # Define the `extent` of basemap extent = tilemapbase.Extent.from_lonlat(minlong, maxlong, minlat, maxlat) extent = extent.to_aspect(1.0) fig, ax = plt.subplots(figsize=(10, 10)) plotter = tilemapbase.Plotter(extent, tilemapbase.tiles.build_OSM(), width=600) plotter.plot(ax) plotter.plot(plt.axes()) for planeobservation in newlist: x, y = tilemapbase.project(planeobservation['longitude'], planeobservation['latitude']) print('x ' + str(x) + ' y ' + str(y)) plt.plot(x, y, "ro-") plt.show
def update_map(self): """ """ if not self.isVisible(): self.last_used_latitude = 0.0 self.last_used_longitude = 0.0 self.last_used_degree_range = 0.0 return try: survey = app_core.DesktopAppSync().get_selected_survey() item_id = app_core.DesktopAppSync().get_selected_item_id() item_metadata = app_core.DesktopAppSync().get_metadata_dict() item_title = item_metadata.get('item_title', '') latitude_dd = item_metadata.get('rec_latitude_dd', '') if not latitude_dd: latitude_dd = item_metadata.get('latitude_dd', '') longitude_dd = item_metadata.get('rec_longitude_dd', '') if not longitude_dd: longitude_dd = item_metadata.get('longitude_dd', '') # self.survey_edit.setText(survey) self.itemid_edit.setText(item_id) self.title_edit.setText(item_title) # if not item_id: self.last_used_latitude = 0.0 self.last_used_longitude = 0.0 self.last_used_degree_range = 0.0 self.axes.cla() self._canvas.draw() return # lat_dd = 0.0 long_dd = 0.0 try: lat_dd = float(latitude_dd) long_dd = float(longitude_dd) except: self.last_used_latitude = 0.0 self.last_used_longitude = 0.0 self.last_used_degree_range = 0.0 self.axes.cla() self._canvas.draw() return # if (lat_dd == 0.0) or (long_dd == 0): # Clear. self.last_used_latitude = 0.0 self.last_used_longitude = 0.0 self.last_used_degree_range = 0.0 self.axes.cla() self._canvas.draw() return current_position = (long_dd, lat_dd) degree_range = 0.05 zoom_range = self.zoom_combo.currentText() try: degree_range = float(zoom_range) except: pass # Don't redraw the same map. if (self.last_used_latitude == lat_dd) and \ (self.last_used_longitude == long_dd) and \ (self.last_used_degree_range == degree_range): return # self.last_used_latitude = lat_dd self.last_used_longitude = long_dd self.last_used_degree_range = degree_range # extent = tilemapbase.Extent.from_lonlat( current_position[0] - degree_range, current_position[0] + degree_range, current_position[1] - degree_range, current_position[1] + degree_range) extent = extent.to_aspect(1.0) self.axes.cla() self.axes.xaxis.set_visible(False) self.axes.yaxis.set_visible(False) plotter = tilemapbase.Plotter(extent, self.osm_tiles, width=600) plotter.plot(self.axes, self.osm_tiles) x, y = tilemapbase.project(*current_position) self.axes.scatter(x, y, marker=".", color="black", linewidth=20) # self._canvas.draw() except Exception as e: debug_info = self.__class__.__name__ + ', row ' + str( sys._getframe().f_lineno) app_utils.Logging().error('Exception: (' + debug_info + '): ' + str(e))
tilemapbase.start_logging() tilemapbase.init(create=True) tiles = tilemapbase.tiles.build_OSM() extent = tilemapbase.Extent.from_lonlat( long_min, long_max, lat_min, lat_max, ) # extent = extent.to_aspect(1.0) fig, ax = plt.subplots(figsize=figure_size) ax.xaxis.set_visible(False) ax.yaxis.set_visible(False) plotter = tilemapbase.Plotter(extent, tiles, width=600) plotter.plot(ax, tiles) # Convert GPS coordinates to "Web Mercator" projection, normalised between 0 # and 1. x_coordinates = [] y_coordinates = [] for x, y in zip(df["longitude"].to_list(), df["latitude"].to_list()): x_norm, y_norm = tilemapbase.project(x, y) x_coordinates.append(x_norm) y_coordinates.append(y_norm) colour_map = sns.color_palette("plasma_r", as_cmap=True) # plasma_r YlOrRd # Minimum and maximum of colour map.
def plot_example(batch, model_output, example_i: int = 0, border: int = 0): fig = plt.figure(figsize=(20, 20)) ncols = 4 nrows = 2 # Satellite data extent = (float(batch['sat_x_coords'][example_i, 0].cpu().numpy()), float(batch['sat_x_coords'][example_i, -1].cpu().numpy()), float(batch['sat_y_coords'][example_i, -1].cpu().numpy()), float(batch['sat_y_coords'][example_i, 0].cpu().numpy()) ) # left, right, bottom, top def _format_ax(ax): #ax.set_xlim(extent[0]-border, extent[1]+border) #ax.set_ylim(extent[2]-border, extent[3]+border) # ax.coastlines(color='black') ax.scatter(batch['x_meters_center'][example_i].cpu(), batch['y_meters_center'][example_i].cpu(), s=500, color='white', marker='x') ax = fig.add_subplot(nrows, ncols, 1) #, projection=ccrs.OSGB(approx=False)) sat_data = batch['sat_data'][example_i, :, :, :, 0].cpu().numpy() sat_min = np.min(sat_data) sat_max = np.max(sat_data) ax.imshow(sat_data[0], extent=extent, interpolation='none', vmin=sat_min, vmax=sat_max) ax.set_title('t = -{}'.format(params['history_len'])) _format_ax(ax) ax = fig.add_subplot(nrows, ncols, 2) ax.imshow(sat_data[params['history_len'] + 1], extent=extent, interpolation='none', vmin=sat_min, vmax=sat_max) ax.set_title('t = 0') _format_ax(ax) ax = fig.add_subplot(nrows, ncols, 3) ax.imshow(sat_data[-1], extent=extent, interpolation='none', vmin=sat_min, vmax=sat_max) ax.set_title('t = {}'.format(params['forecast_len'])) _format_ax(ax) ax = fig.add_subplot(nrows, ncols, 4) lat_lon_bottom_left = osgb_to_lat_lon(extent[0], extent[2]) lat_lon_top_right = osgb_to_lat_lon(extent[1], extent[3]) tiles = tilemapbase.tiles.build_OSM() lat_lon_extent = tilemapbase.Extent.from_lonlat( longitude_min=lat_lon_bottom_left[1], longitude_max=lat_lon_top_right[1], latitude_min=lat_lon_bottom_left[0], latitude_max=lat_lon_top_right[0]) plotter = tilemapbase.Plotter(lat_lon_extent, tile_provider=tiles, zoom=6) plotter.plot(ax, tiles) ############## TIMESERIES ################## # NWP ax = fig.add_subplot(nrows, ncols, 5) nwp_dt_index = pd.to_datetime( batch['nwp_target_time'][example_i].cpu().numpy(), unit='s') pd.DataFrame(batch['nwp'][example_i, :, :, 0, 0].T.cpu().numpy(), index=nwp_dt_index, columns=params['nwp_channels']).plot(ax=ax) ax.set_title('NWP') # datetime features ax = fig.add_subplot(nrows, ncols, 6) ax.set_title('datetime features') datetime_feature_cols = [ 'hour_of_day_sin', 'hour_of_day_cos', 'day_of_year_sin', 'day_of_year_cos' ] datetime_features_df = pd.DataFrame(index=nwp_dt_index, columns=datetime_feature_cols) for key in datetime_feature_cols: datetime_features_df[key] = batch[key][example_i].cpu().numpy() datetime_features_df.plot(ax=ax) ax.legend() ax.set_xlabel(nwp_dt_index[0].date()) # PV yield ax = fig.add_subplot(nrows, ncols, 7) ax.set_title('PV yield for PV ID {:,d}'.format( batch['pv_system_id'][example_i].cpu())) pv_actual = pd.Series(batch['pv_yield'][example_i].cpu().numpy(), index=nwp_dt_index, name='actual') pv_pred = pd.Series(model_output[example_i].detach().cpu().numpy(), index=nwp_dt_index[params['history_len'] + 1:], name='prediction') pd.concat([pv_actual, pv_pred], axis='columns').plot(ax=ax) ax.legend() # fig.tight_layout() return fig
norm=norm, extend='max', orientation='horizontal') cbar.ax.xaxis.set_ticks_position('bottom') cbar.ax.xaxis.set_label_position('bottom') cbar.ax.tick_params(direction='in') cbar.ax.set_xlabel('%s (ppb)' % spe) for spe in ['rNO2dNOx']: #plot OSM fig = plt.figure(figsize=(5, 6)) ax = fig.add_axes([.05, .05, .9, .9]) ax.xaxis.set_visible(False) ax.yaxis.set_visible(False) plotter = tilemapbase.Plotter(extent, tile, width=300) plotter.plot(ax, tile) #plot data mobile = get_xy(mbdata, spe) aqs = get_xy(aqsdata, spe) cmap = plt.cm.jet norm = mpl.colors.Normalize(vmin=0, vmax=1) ax.scatter(mobile[0], mobile[1], c=mobile[2], s=0.1, cmap=cmap, norm=norm) ax.scatter(aqs[0], aqs[1], c=aqs[2], marker='*', s=50, edgecolor='black', cmap=cmap, norm=norm)
for i in range(colors)]) line_segments = LineCollection(lincol_array_test, array=mid_color_vals, cmap=plt.get_cmap(colormap)) if background: # https://stackoverflow.com/a/20909062 fig.subplots_adjust(hspace=0., wspace=0., left=0., bottom=0., right=1., top=1.) base_plotter = tilemapbase.Plotter(extent, base_provider, width=2 * 700) base_plotter.plot(ax) try: slope_plotter = tilemapbase.Plotter(extent, slope_provider, width=2 * 700) slope_plotter.plot(ax) except NameError: pass # https://stackoverflow.com/a/21322270 plt.axis('off') blackline = LineCollection([ list(zip(path_x, path_y)), ],
color_list[:, -1] = [ MAX_ALPHA * (MIN_ALPHA + (math.log(1 + x, len(color_list)) * (1 - MIN_ALPHA))) for x in range(0, len(color_list)) ] # Log distribution of alpha cm = matplotlib.colors.ListedColormap(color_list) cm.set_under(alpha=0) # Initializing figure fig, ax = plt.subplots(figsize=(WIDTH, WIDTH / ASPECT_RATIO)) ax.xaxis.set_visible(False) ax.yaxis.set_visible(False) plt.subplots_adjust(left=0, right=1, top=1, bottom=0) # Plotting map background plotter = tilemapbase.Plotter(map_extent, t, zoom=ZOOM_LEVEL) plotter.plot(ax, t) shading = np.zeros((1, 1), dtype='float') ax.imshow(shading, extent=extent, origin='lower', cmap='gray', alpha=BACKGROUND_SHADING) # Plotting title ax.text(s=TITLE, x=X_TITLE, y=Y_TITLE, size=TITLE_SIZE, transform=ax.transAxes, horizontalalignment='center',