def plotAll(self,figname):
    fig = plt.figure(figsize=(15, 15))
    ax1 = plt.gca()
    
    tot_people =self._blocks["density"]
    scheme = mapclassify.Quantiles(tot_people, k=5) 
 
    geoplot.choropleth(
    self._blocks, hue=tot_people, scheme=scheme,
    cmap='Oranges', figsize=(12, 8), ax=ax1
    )
    plt.savefig('density-'+figname)

    fig = plt.figure(figsize=(15, 15))
    ax1 = plt.gca()

    ctx.plot_map(self._loc, ax=ax1)
    _c = ["red", "blue"]
    for i, _r in enumerate(self._roads):
      _r.plot(ax=ax1, facecolor='none', edgecolor=_c[i])
    self._blocks.plot(ax=ax1,facecolor='none', edgecolor="black")  
    

    plt.tight_layout()

    # Plot agents
    self.grid._agdf.plot(ax=ax1)
    plt.savefig('agents-'+figname)
Ejemplo n.º 2
0
def test_plot_map():
    search = 'boulder'
    loc = ctx.Place(search, zoom_adjust=-3)
    ax = ctx.plot_map(loc)
    assert ax.get_title() == loc.place

    ax = ctx.plot_map(loc.im, loc.bbox)
    assert_array_almost_equal(loc.bbox, ax.images[0].get_extent())
Ejemplo n.º 3
0
def test_plot_map():
    # Place as a search
    loc = ctx.Place(SEARCH, zoom_adjust=ADJUST)
    w, e, s, n = loc.bbox_map
    ax = ctx.plot_map(loc)

    assert ax.get_title() == loc.place
    ax = ctx.plot_map(loc.im, loc.bbox)
    assert_array_almost_equal(loc.bbox, ax.images[0].get_extent())

    # Place as an image
    img, ext = ctx.bounds2img(w, s, e, n, zoom=10)
    ax = ctx.plot_map(img, ext)
    assert_array_almost_equal(ext, ax.images[0].get_extent())
Ejemplo n.º 4
0
"""
import numpy as np
import matplotlib.pyplot as plt
import contextily as ctx

loc = ctx.Place("boulder", zoom_adjust=0)  # zoom_adjust modifies the auto-zoom

# Print some metadata
for attr in ["w", "s", "e", "n", "place", "zoom", "n_tiles"]:
    print("{}: {}".format(attr, getattr(loc, attr)))

# Show the map
im1 = loc.im

fig, axs = plt.subplots(1, 3, figsize=(15, 5))
ctx.plot_map(loc, ax=axs[0])

###############################################################################
# The zoom level will be chosen for you by default, though you can specify
# this manually as well:

loc2 = ctx.Place("boulder", zoom=11)
ctx.plot_map(loc2, ax=axs[1])

###############################################################################
# Downloading tiles from bounds
# =============================
#
# You can also grab tile information directly from a bounding box + zoom level.
# This is demoed below: