def plotPoints(map_name, lat_long, cl): fig, ax = plt.subplots() x = [lat_long['lng']] y = [lat_long['lat']] ax.plot(x, y, cl) maps = "templates/" + map_name + ".html" f = open(maps, "w") f.write(mplleaflet.fig_to_html(fig=fig)) f.close()
def plotWeather(map_name, hail_la_ln, wind_la_ln, tornado_la_ln): fig, ax = plt.subplots() x = [hail_la_ln['lng']] y = [hail_la_ln['lat']] ax.plot(x, y, 'b*') x = [wind_la_ln['lng']] y = [wind_la_ln['lat']] ax.plot(x, y, 'r>') x = [tornado_la_ln['lng']] y = [tornado_la_ln['lat']] ax.plot(x, y, 'g^') maps = "templates/" + map_name + ".html" f = open(maps, "w") f.write(mplleaflet.fig_to_html(fig=fig)) f.close()
def evaluate(self, data: GpxFile): # fig, ax = plt.subplots() fig = plt.figure() ax = fig.add_subplot(111) df = data.df[['Point_Longitude', 'Point_Latitude']].dropna() ax.plot(df['Point_Longitude'], df['Point_Latitude'], color="#00A6ED", linewidth=3, alpha=0.9) val = mplleaflet.fig_to_html(fig=fig) # , tiles='esri_aerial') """ attribution = _attribution + ' | ' + tiles[1] attribution = "" # :( """ # print(val) return val, InlineHTML(val)
boston_polygon = shapely.ops.cascaded_union(census_tracts.geometry.values) # Plot the data. # We're building a webmap, so we'll first create an unprojected map. ax = gplt.kdeplot(listings) gplt.polyplot(gpd.GeoSeries([boston_polygon]), edgecolor='white', linewidth=4, ax=ax) # Now we'll output this map to mplleaflet to generate our webmap. In this example we'll actually go one step further, # and use a non-default tile layer as well. The default mplleaflet webmap uses the default Leaflet tile service, # which is Open Street Map (OSM). OSM works great in a lot of cases, but tends to be very busy at a local level (an # actual strategic choice on the part of the OSM developers, as the higher visibility rewards contributions to the # project). # # Luckily Leaflet (and, by extension, mplleaflet) can be made to work with any valid time service. To do this we can use # the mplleaflet.fig_to_html method, which creates a string (which we'll write to a file) containing our desired # data. Here is the method signature that we need: # >>> mplleaflet.fig_to_html(<matplotlib.Figure>, tiles=(<tile url>, <attribution string>) # For this demo we'll use the super-basic Hydda.Base tile layer. # # For a list of possible valid inputs: # https://leaflet-extras.github.io/leaflet-providers/preview/ # For the full fig_to_html method signature run mplleaflet.fig_to_html? in IPython or see further: # https://github.com/jwass/mplleaflet/blob/master/mplleaflet/_display.py#L26 fig = plt.gcf() with open("boston_kde.html", 'w') as f: f.write( mplleaflet.fig_to_html(fig, tiles=('http://{s}.tile.openstreetmap.se/hydda/base/{z}/{x}/{y}.png', 'Tiles courtesy of <a href="http://openstreetmap.se/" target="_blank">OpenStreetMap Sweden</a> — Map data © <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>')) )
ax = gplt.kdeplot(listings) gplt.polyplot(gpd.GeoSeries([boston_polygon]), edgecolor='white', linewidth=4, ax=ax) # Now we'll output this map to mplleaflet to generate our webmap. In this example we'll actually go one step further, # and use a non-default tile layer as well. The default mplleaflet webmap uses the default Leaflet tile service, # which is Open Street Map (OSM). OSM works great in a lot of cases, but tends to be very busy at a local level (an # actual strategic choice on the part of the OSM developers, as the higher visibility rewards contributions to the # project). # # Luckily Leaflet (and, by extension, mplleaflet) can be made to work with any valid time service. To do this we can use # the mplleaflet.fig_to_html method, which creates a string (which we'll write to a file) containing our desired # data. Here is the method signature that we need: # >>> mplleaflet.fig_to_html(<matplotlib.Figure>, tiles=(<tile url>, <attribution string>) # For this demo we'll use the super-basic Hydda.Base tile layer. # # For a list of possible valid inputs: # https://leaflet-extras.github.io/leaflet-providers/preview/ # For the full fig_to_html method signature run mplleaflet.fig_to_html? in IPython or see further: # https://github.com/jwass/mplleaflet/blob/master/mplleaflet/_display.py#L26 fig = plt.gcf() with open("boston_kde.html", 'w') as f: f.write( mplleaflet.fig_to_html( fig, tiles= ('http://{s}.tile.openstreetmap.se/hydda/base/{z}/{x}/{y}.png', 'Tiles courtesy of <a href="http://openstreetmap.se/" target="_blank">OpenStreetMap Sweden</a> — Map data © <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>' )))
def test_scatter(): plt.scatter([0, 10, 0, 10], [0, 0, 10, 10], c=[1, 2, 3, 4]) mplleaflet.fig_to_html()
def test_basic(): plt.plot([0, 0], [1, 1]) mplleaflet.fig_to_html()
def test_basic_tiles(): plt.plot([0, 1], [0, 1]) mplleaflet.fig_to_html(tiles='osm')
def test_basic(): plt.plot([0, 1], [0, 1]) mplleaflet.fig_to_html()