Metview's documentation is now on readthedocs!

Download source and data


Contour Shading Only Over Land_TEST
#Metview Macro

#  **************************** LICENSE START ***********************************
# 
#  Copyright 2020 ECMWF. This software is distributed under the terms
#  of the Apache License version 2.0. In applying this license, ECMWF does not
#  waive the privileges and immunities granted to it by virtue of its status as
#  an Intergovernmental Organization or submit itself to any jurisdiction.
# 
#  ***************************** LICENSE END ************************************
# 

# read grib data
f = read("2m_temperature.grib")

# define coastlines with sea shading but no land shading. 
# We set map_layer_mode="foreground" to make the 
# sea shading appear on top of the contour plot!
coast = mcoast(
    map_coastline_sea_shade        : "on",
    map_coastline_sea_shade_colour : "charcoal",
    map_grid_colour                : "RGB(0.4,0.4,0.4)",
    map_grid_frame                 : "on",
    map_label                      : "off",
    map_layer_mode                 : "foreground"
    )

# define map view
view = geoview(
    map_projection     : "mollweide",
    subpage_y_position : 15,
    subpage_frame      : "off",
    coastlines         : coast
    )

# define contour_shading
cont = mcont(
    contour_automatic_setting : "style_name",
    contour_style_name        : "sh_all_fM64t52i4",
    legend                    : "on"
    )
        
# define the output plot file
setoutput(pdf_output(output_name : 'shading_only_over_land'))
   
# generate plot
plot(view, f, cont)
Contour Shading Only Over Land_TEST
"""
Contour Shading Only Over Land
"""

#  **************************** LICENSE START ***********************************
#
#  Copyright 2020 ECMWF. This software is distributed under the terms
#  of the Apache License version 2.0. In applying this license, ECMWF does not
#  waive the privileges and immunities granted to it by virtue of its status as
#  an Intergovernmental Organization or submit itself to any jurisdiction.
#
#  ***************************** LICENSE END ************************************
#

import metview as mv

# read grib data
f = mv.read("2m_temperature.grib")

# define coastlines with sea shading but no land shading.
# We set map_layer_mode="foreground" to make the
# sea shading appear on top of the contour plot!
coast = mv.mcoast(
    map_coastline_sea_shade="on",
    map_coastline_sea_shade_colour="charcoal",
    map_grid_colour="RGB(0.4,0.4,0.4)",
    map_grid_frame="on",
    map_label="off",
    map_layer_mode="foreground",
)

# define map view
view = mv.geoview(
    map_projection="mollweide",
    subpage_y_position=15,
    subpage_frame="off",
    coastlines=coast,
)

# define contour_shading
cont = mv.mcont(
    contour_automatic_setting="style_name",
    contour_style_name="sh_all_fM64t52i4",
    legend="on",
)

# define the output plot file
mv.setoutput(mv.pdf_output(output_name="shading_only_over_land"))

# generate plot
mv.plot(view, f, cont)