def test_colorbar_using_paper_coordinates_horizontal(): """ Create colorbar positioned at 0cm,0cm with length 2cm oriented horizontally """ fig = Figure() fig.colorbar(cmap="rainbow", position="x0c/0c+w2c+h") return fig
def test_colorbar_box(): """ Create colorbar with box around it. """ fig = Figure() fig.colorbar(cmap="rainbow", box=True, position="x0c/0c+w1c/0.5c") return fig
def test_colorbar_scaled_z_values(): """ Create colorbar with z-values scaled to 0.1x of the original CPT. """ fig = Figure() fig.colorbar(cmap="rainbow", scale=0.1, position="x0c/0c+w2c/0.5c") return fig
def test_colorbar_using_paper_coordinates(): """ Create colorbar positioned at 0cm,0cm with length 1cm and width 0.5cm. """ fig = Figure() fig.colorbar(cmap="rainbow", position="x0c/0c+w1c/0.5c") return fig
def test_colorbar_box_with_offset_background(): """ Create colorbar with box and an offset background shaded region. """ fig = Figure() fig.colorbar(cmap="rainbow", box="+s5p/-5p", position="x0c/0c+w1c/0.5c") return fig
def test_colorbar_box_with_fill(): """ Create colorbar with box that has a different colored fill. """ fig = Figure() fig.colorbar(cmap="rainbow", box="+gorange", position="x0c/0c+w1c/0.5c") return fig
def test_colorbar_truncated_to_zlow_zhigh(): """ Create colorbar truncated to z-low and z-high. """ fig = Figure() fig.colorbar(cmap="rainbow", truncate=[0.15, 0.85], position="x0c/0c+w2c/0.5c") return fig
def test_colorbar_box_with_rounded_corners(): """ Create colorbar with box that has rounded corners. """ fig = Figure() fig.colorbar(cmap="rainbow", box="+porange+r", position="x0c/0c+w1c/0.5c") return fig
def test_makecpt_reverse_color_only(position): """ Use static color palette table with its colors reversed. """ fig = Figure() makecpt(cmap="earth", reverse=True, series=[0, 1000]) fig.colorbar(cmap=True, frame=True, position=position) return fig
def test_colorbar_positioned_using_map_coordinates(): """ Create colorbar positioned at longitude,latitude 3,6 with length 2cm. """ fig = Figure() fig.basemap(region=[2, 4, 6, 8], projection="t0/2c", frame=True) fig.colorbar(cmap="rainbow", position="g3/6+w2c") return fig
def test_makecpt_plot_colorbar(position): """ Use static color palette table to plot a colorbar. """ fig = Figure() makecpt(cmap="relief") fig.colorbar(cmap=True, frame=True, position=position) return fig
def test_makecpt_cyclic(region): """ Use static color palette table that is cyclic. """ fig = Figure() makecpt(cmap="cork", cyclic=True) fig.colorbar(cmap=True, region=region, frame=True, position="JBC") return fig
def test_colorbar_positioned_using_normalized_coords(): """ Create colorbar at normalized coordinates 0.75,0.25 with length 2cm. """ fig = Figure() fig.basemap(region=[2, 4, 6, 8], projection="t0/2c", frame=True) fig.colorbar(cmap="rainbow", position="n0.75/0.25+w2c") return fig
def test_makecpt_categorical(region): """ Use static color palette table that is categorical. """ fig = Figure() makecpt(cmap="categorical", categorical=True) fig.colorbar(cmap=True, region=region, frame=True, position="JBC") return fig
def test_colorbar_shading_boolean(): """ Create colorbar and set shading with a Boolean value. """ fig = Figure() fig.basemap(region=[0, 10, 0, 10], projection="X15c", frame="a") fig.colorbar(cmap="geo", shading=True, frame=True) return fig
def test_colorbar_shading_list(): """ Create colorbar and set shading by passing the high/low values as a list. """ fig = Figure() fig.basemap(region=[0, 10, 0, 10], projection="X15c", frame="a") fig.colorbar(cmap="geo", shading=[-0.7, 0.2], frame=True) return fig
def test_makecpt_truncated_zlow_zhigh(position): """ Use static color palette table that is truncated to z-low and z-high. """ fig = Figure() makecpt(cmap="rainbow", truncate=[0.15, 0.85], series=[0, 1000]) fig.colorbar(cmap=True, frame=True, position=position) return fig
def test_makecpt_reverse_color_and_zsign(position): """ Use static color palette table with both its colors and z-value sign reversed. """ fig = Figure() makecpt(cmap="earth", reverse="cz", series=[0, 1000]) fig.colorbar(cmap=True, frame=True, position=position) return fig
def test_makecpt_plot_colorbar_scaled_with_series(position): """ Use static color palette table scaled to a min/max series and plot it on a colorbar. """ fig = Figure() makecpt(cmap="oleron", series=[0, 1000]) fig.colorbar(cmap=True, frame=True, position=position) return fig
def test_makecpt_continuous(position): """ Use static color palette table that is continuous from blue to white and scaled from 0 to 1000 m. """ fig = Figure() makecpt(cmap="blue,white", continuous=True, series=[0, 1000]) fig.colorbar(cmap=True, frame=True, position=position) return fig
def test_colorbar_box_with_secondary_border(): """ Create colorbar with box that has a secondary, inner border in addition to the main primary, outer border. """ fig = Figure() fig.colorbar(cmap="rainbow", box="+porange+imagenta", position="x0c/0c+w1c/0.5c") return fig
def test_grd2cpt(grid): """ Test creating a CPT with grd2cpt to create a CPT based off a grid input and plot it with a color bar. """ fig = Figure() fig.basemap(frame="a", projection="W0/15c", region="d") grd2cpt(grid=grid) fig.colorbar(frame="a") return fig
def test_colorbar_box_with_clearance(): """ Create colorbar with box that has an x-clearance of 0.8cm and y-clearance of 0.4cm. """ fig = Figure() fig.colorbar(cmap="rainbow", box="+c0.8c/0.4c+porange", position="x0c/0c+w1c/0.5c") return fig
def test_colorbar_shading_list(): """ Create colorbar and set shading by passing the high/low values as a list """ fig_ref, fig_test = Figure(), Figure() # Use single-character arguments for the reference image fig_ref.basemap(R="0/10/0/10", J="X15c", B="a") fig_ref.colorbar(C="geo", I="-0.7/0.2") fig_test.basemap(region=[0, 10, 0, 10], projection="X15c", frame="a") fig_test.colorbar(cmap="geo", shading=[-0.7, 0.2]) return fig_ref, fig_test
def test_colorbar_shading_boolean(): """ Create colorbar and set shading with a Boolean value. """ fig_ref, fig_test = Figure(), Figure() # Use single-character arguments for the reference image fig_ref.basemap(R="0/10/0/10", J="X15c", B="a") fig_ref.colorbar(C="geo", I="") fig_test.basemap(region=[0, 10, 0, 10], projection="X15c", frame="a") fig_test.colorbar(cmap="geo", shading=True) return fig_ref, fig_test
def test_colorbar_shading_float(): """ Create colorbar and set shading with a single float variable """ fig_ref, fig_test = Figure(), Figure() # Use single-character arguments for the reference image fig_ref.basemap(R="0/10/0/10", J="X15c", B="a") fig_ref.colorbar(C="geo", I=0.5) fig_test.basemap(region=[0, 10, 0, 10], projection="X15c", frame="a") fig_test.colorbar(cmap="geo", shading=0.5) return fig_ref, fig_test
def test_colorbar_positioned_using_justification_code(): """ Create colorbar at Top Center inside the map frame with length 2cm. """ fig_ref, fig_test = Figure(), Figure() # Use single-character arguments for the reference image fig_ref.basemap(R="2/4/6/8", J="t0/2c", B="") fig_ref.colorbar(C="rainbow", D="jTC+w2c") fig_test.basemap(region=[2, 4, 6, 8], projection="t0/2c", frame=True) fig_test.colorbar(cmap="rainbow", position="jTC+w2c") return fig_ref, fig_test
def test_grdimage_grid_and_shading_with_xarray(grid, xrgrid): """ Test that shading works well when xarray.DataArray is input to both the ``grid`` and ``shading`` arguments. """ fig_ref, fig_test = Figure(), Figure() fig_ref.grdimage( grid="@earth_relief_01d_g", region="GL", cmap="geo", shading=xrgrid, verbose="i" ) fig_ref.colorbar() fig_test.grdimage(grid=grid, region="GL", cmap="geo", shading=xrgrid, verbose="i") fig_test.colorbar() return fig_ref, fig_test
def test_grd2cpt(grid): """ Test creating a CPT with grd2cpt to create a CPT based off a grid input and plot it with a color bar. """ fig_ref, fig_test = Figure(), Figure() # Use single-character arguments for the reference image fig_ref.basemap(B="a", J="W0/15c", R="d") grd2cpt(grid="@earth_relief_01d") fig_ref.colorbar(B="a2000") fig_test.basemap(frame="a", projection="W0/15c", region="d") grd2cpt(grid=grid) fig_test.colorbar(frame="a2000") return fig_ref, fig_test
shorelines=[f"1/1.5p,{coast}", f"2/1p,{coast}"], frame=frame, land=land, water=water, lakes=lakes, area_thresh=10000) # Plot moment tensors which should be in a file in the psmeca format from GCMT # lon lat depth mrr mtt mpp mrt mrp mtp iexp name if moment_tensors and mt_fid: # Make the colormap to shade MTs by depth depths = np.loadtxt(mt_fid, usecols=2, dtype=float) makecpt(cmap=mt_cmap, series=[min(depths), max(depths), 1]) mts = fig.meca(mt_fid, scale=mt_scale, convention="mt", component="dc", C=True, verbose=True, L="1p/black") if mt_colorbar: fig.colorbar(position="n.95/.825+w-2c/.45c", frame='af+l"depth [km]"') # Scalebar, need to use config to set the pen thickness of the scale with config(MAP_TICK_PEN_PRIMARY=1.5): fig.basemap(region=region, projection=projection, #frame=["WSne", "gfa"], map_scale=map_scale) # Landmark text fig.text(textfiles=landmarks_fid) # Plot the whole of Alaska as an inset to give context if inset: with fig.inset(position="n0/.75+w5c/4c", margin=0): # Plot the whole of Alaska as the inset fig.coast(region=[-170, -135, 53, 72], projection="L-150/62/63/64/3.5c", land="gray", water="white", shorelines="0p,black",