Esempio n. 1
0
def scale_bar_and_direction(ax,
                            arrow_location=(0.86, 0.08),
                            scalebar_location=(0.88, 0.05),
                            scalebar_distance=25,
                            zorder=20):
    """Draw a scale bar and direction arrow

    Parameters
    ----------
    ax : axes
    length : int
        length of the scalebar in km.
    ax_crs: projection system of the axis
        to be provided in Jamaica grid coordinates
    location: tuple
        center of the scalebar in axis coordinates (ie. 0.5 is the middle of the plot)
    linewidth: float
        thickness of the scalebar.
    """
    # lat-lon limits
    scale_bar(ax,
              scalebar_location,
              scalebar_distance,
              color='k',
              zorder=zorder)

    ax.text(*arrow_location,
            transform=ax.transAxes,
            s='N',
            fontsize=14,
            zorder=zorder)
    arrow_location = numpy.asarray(arrow_location) + numpy.asarray(
        (0.008, -0.03))
    # arrow_location[1] = arrow_location[1] - 0.02
    ax.arrow(*arrow_location,
             0,
             0.02,
             length_includes_head=True,
             head_width=0.01,
             head_length=0.04,
             overhang=0.2,
             transform=ax.transAxes,
             facecolor='k',
             zorder=zorder)
Esempio n. 2
0
                         vmax=10,
                         cmap='Wistia',
                         alpha=0.8,
                         s=3.0)
    cb = plt.colorbar(points,
                      orientation='horizontal',
                      ticklocation='auto',
                      shrink=0.5,
                      pad=0.1)
    cb.set_label(label='Concentration (' + "${\mu}$" + 'g/m' + r'$^3$' + ')',
                 size=20)
    cb.ax.tick_params(labelsize=20)
    plt.tight_layout()

    plt.legend(title='[' + str(day_.date()) + ']', loc='upper right')
    scale_bar(ax, (0.05, 0.05), 100)
    #    ax.annotate("N", xy=(124, 39), xytext=(0, 0.5), arrowprops = dict(arrowstyle="->"))
    #    plt.show()

    plt.savefig('./test2/Anew_source3_w12_T61_' + str(day_.date()) + '.jpg')

    plt.close()

# 2-3. Using Pandas and Cartopy_ Underlying locations

underloc = pd.read_csv('w16.csv')

#underloc = underloc.drop([0,3,4,8,15],0) # for new w11

underloc = underloc.drop([4, 8, 12, 15], 0)  # for w12
Esempio n. 3
0
    angles='xy',
    scale_units='xy',
    scale=arrowsScale,
    regrid_shape=arrowsRegridShape,
    pivot='middle',
    transform=ccrs.Mercator())

# adds shapefile
land_feature = ShapelyFeature(
    Reader(landShapefile).geometries(),
    crs=ccrs.Mercator(),
    facecolor=facecolor)

ax.add_feature(
    land_feature,
    edgecolor=edgecolor)

# adds longitude and latitude ticks
xticks, yticks, xticklabels, yticklabels = ticks_definer(
    MHDF5Reader.getLonHorizontalGrid(),
    MHDF5Reader.getLatHorizontalGrid(),
    tickInterval)
ax.set_xticks(xticks, crs=ccrs.Mercator())
ax.set_yticks(yticks, crs=ccrs.Mercator())
ax.set_xticklabels(xticklabels)
ax.set_yticklabels(yticklabels)

scale_bar(ax, (0.8, 0.3), length=100)

fig.savefig(figSaveName+imgFormat, dpi=dpi)
Esempio n. 4
0
for idx, row in communes_clipped.iterrows():
    text = ax.text(row['geometry'].representative_point().x, row['geometry'].representative_point().y, row['nom_commun'], color='white',
                          ha='center', va='center', size=20)
    text.set_path_effects([path_effects.Stroke(linewidth=3, foreground='black'),path_effects.Normal()])

print("- Add Cities' Names...")

ax.axis("off")

ax.set_xlim((xmin,xmax))
ax.set_ylim((ymin,ymax))


print("- Add Scalebar and North Arrow...")
# SCALE BAR AND NORTH ARROW
scale_bar(ax, [0.1,0.05], 20,text_kwargs=dict(fontsize="22")) # changer fontsize pour la taille de la police

x, y, arrow_length = 0.1, 0.7, 0.05
ax.annotate('N', xy=(x, y), xytext=(x, y-arrow_length),
            arrowprops=dict(facecolor='black', width=5, headwidth=15),
            ha='center', va='center', fontsize=20,
            xycoords=ax.transAxes)

print("- Add Legend...")

# LEGEND
legend_elements = [Line2D([0], [0], color='r', lw=4, label=label_lignes),
                   Line2D([0], [0], marker='o', color='w', label='Motif de '+theme,
                          markerfacecolor='orange', markersize=15),
                   Patch(facecolor="white", edgecolor='white',
                         label="$\\bf{Catégories}$ $\\bf{d'espaces}$"),
Esempio n. 5
0

# Plot
fig = nice_plot_prob("output/prob.tif",
                     maxpixels=1e8,
                     borders="data/ctry_PROJ.shp",
                     linewidth=0.2,
                     legend=True,
                     figsize=(5, 4),
                     dpi=800)
ax = fig.gca()
# Scale bar
scale_bar(ax, (0.8, 0.1),
          10,
          metres_per_unit=1000,
          unit_name="km",
          color="black",
          linewidth=1,
          text_kwargs={'size': 7})
# Gridlines from Cartopy
gl = ax.gridlines(crs=ccrs.PlateCarree(),
                  linewidth=0.3,
                  alpha=0.5,
                  xlocs=[-61.8, -61.6, -61.4, -61.2, -61.0],
                  ylocs=[15.8, 16.0, 16.2, 16.4],
                  draw_labels=True)
gl.top_labels = False
gl.right_labels = False
gl.xlabel_style = {'size': 6}
gl.ylabel_style = {'size': 6}