Image Added
Image Removed
# Metview Macro
# **************************** LICENSE START ***********************************
#
# Copyright 2015 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 ************************************
# ------------------------------------------------------------------
# Tags: contour,legend
# Title: Disjoint Legend
# Description: Demonstrates how to show a disjoint legend with labels
# for each level value.
# See also:
# https://software.ecmwf.int/magis/Legend+examples+legend2
# ------------------------------------------------------------------
# read the input grib file (temperature)
my_data = read("./t850.grb")
# set up the geographical view
my_view = geoview(map_area_definition : "CORNERS",
map_projection : "POLAR_STEREOGRAPHIC",
area : [21.51,-37.27,51.28,65.00])
# set up a shade contour with legend for the field
my_contour = mcont(contour_level_selection_type : "LEVEL_LIST",
contour_level_list : [-48.0,-10.0,0.0,10.0,20.0,48.0],
contour_hilo : "OFF",
contour_label : "OFF",
contour : "OFF",
legend : "ON",
contour_shade : "ON",
contour_shade_colour_method : "LIST",
contour_shade_method : "AREA_FILL",
contour_shade_max_level : 48.00,
contour_shade_min_level : -48.00,
contour_shade_colour_list : ["blue_purple"," greenish_blue"," blue_green"," yellow_green"," yellow"," orange"])
# set up an disjoint legend for the field
my_legend = mlegend(legend_display_type : "DISJOINT",
legend_text_composition : "USER_TEXT_ONLY",
legend_title : "ON",
legend_user_lines : ["extremely cold"," very cold"," cold"," temperate"," hot"],
legend_text_font_size : 0.4,
legend_text_colour : "BLACK",
legend_entry_text_width : 80.00,
legend_title_text : "Temperature at 850 hPa")
# set up the coastlines
my_coast= mcoast(map_coastline_resolution : "HIGH")
# set up the title
my_title = mtext(text_font_size : 0.6,
text_lines : ["Disjoint legend with user defined labels"," "],
text_justification : "LEFT",
text_colour : "CHARCOAL")
# define the output media
to_psfile = ps_output
(
output_name : "plot" # extension is added automatically
)
# check the runmode and decide which media to putput the plot to
mode = runmode()
if (mode = "execute") then setoutput(to_psfile)
else if (mode = "batch") then setoutput(to_psfile)
else if (mode = "visualise") then print('screen')
else fail("Only execute, batch and visualise allowed")
end if
# plot the cartesian graph
plot(my_view,my_data,my_contour,my_coast,my_title,my_legend)