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: curve,axis,cartesian
# Title: Bar Plotting
# Description: Demonstrates how to plot time serie vectors using linebars
# and bars in a Cartesian view.
# See also:
# https://software.ecmwf.int/magics/Graph+examples+graph4
# ------------------------------------------------------------------
# set up the axis for the cartesian view
my_vaxis = maxis(axis_tick_label_height : 0.40,
axis_orientation : "VERTICAL",
axis_grid_thickness : 1,
axis_type : "REGULAR",
axis_tick_label_colour : "NAVY",
axis_grid : "ON",
axis_grid_line_style : "DOT",
axis_grid_colour : "GREY")
my_haxis = maxis(axis_orientation : "HORIZONTAL",
axis_grid_thickness : 1,
axis_type : "DATE",
axis_days_label_height : 0.40,
axis_grid : "ON",
axis_months_label_height : 0.40,
axis_years_label_height : 0.50,
axis_grid_line_style : "DOT",
axis_grid_colour : "GREY")
my_view = cartesianview(x_axis_type : "DATE",
x_date_min : "2012-03-03 00:00:00",
x_date_max : "2012-03-08 00:00:00",
y_axis_type : "regular",
y_min : 25,
y_max : 75,
horizontal_axis : my_haxis,
vertical_axis : my_vaxis,
subpage_y_length: 70)
# define first set of input vectors to plot
my_dates1 = ["2012-03-04 00:00:00","2012-03-04 12:00:00","2012-03-05 00:00:00"]
my_input1 = input_visualiser(input_plot_type : "xy_area",
input_x_type : "date",
input_date_x_values : my_dates1,
input_date_x2_values : my_dates1,
input_y_values : [30,35,50],
input_y2_values : [60,40,70])
# set up a linebar plot for the first set
my_graph1 = mgraph(graph_type : "BAR",
graph_bar_colour : "RED",
graph_bar_style : "LINEBAR",
graph_bar_line_colour : "RED",
graph_bar_justification : "RIGHT",
graph_bar_width : 6*3600,
graph_bar_line_thickness : 4,
graph_bar_annotation_font_size : 0.40,
graph_bar_annotation : ["<font colour='red'>Using linebar style</font>"],
legend : "ON")
# define second set of input vectors to plot
my_dates2 = ["2012-03-06 00:00:00","2012-03-06 12:00:00","2012-03-07 00:00:00"]
my_input2 = input_visualiser(input_plot_type : "xy_area",
input_x_type : "date",
input_date_x_values : my_dates2,
input_date_x2_values : my_dates2,
input_y_values : [60,40,30],
input_y2_values : [00,00,00])
# set up a bar plot for the second set
my_graph2 = mgraph(graph_type : "BAR",
graph_shade_colour : "GREEN",
graph_bar_annotation_font_colour : "CHARCOAL",
graph_bar_justification : "CENTRE",
graph_bar_width : 3*3600,
graph_bar_annotation_font_size : 0.40,
graph_bar_annotation : ["<font colour='evergreen'>Using bar style</font>"],
legend_user_text : " ",
legend : "ON")
# set up the title
my_title = mtext(text_font_size : 0.6,
text_lines : ["More options on bar plotting ..."],
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_input1,my_graph1,my_input2,my_graph2,my_title)