Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3
Info

For more information, see Migrating from Metview 3 to Metview 4.

The following examples illustrate the differences in how curves are plotted in Metview 4 compared with Metview 3. The differences are summarised here:

  • the curve() function is replaced by the input_visualiser() function to define the curves. The Input Visualiser provides a way to plot lists of values in various ways.
  • the curveview is replaced by the cartesianview. The Cartesian View is a general X/Y coordinate system suitable for any non-map-based plot. The Curve View does not exist in Metview 4.
  • the axis limits are defined within the Cartesian View, not in the Axis definitions - these are now only for visual attributes of the axis; the View contains all the information for setting up the coordinate system
  • the custom legend entries are defined in the legend() function - Metview has a new Legend icon for controlling the legend.
  • use of mgraph() instead of pgraph(), etc. These are the Magics++ versions of the visual definition icons.
  • specification of output plot files is a little different

 

Section
bordertrue
Column

Metview 3 code

Include Page
Time Series Curve From Lists Metview 3 Example
Time Series Curve From Lists Metview 3 Example

Column

Metview 4 code

Include Page
Time Series Curve From Lists Example
Time Series Curve From Lists Example

Section
bordertrue
Column
# Metview Macro
 
 
# Define our range of dates
 
date_start = 2012-07-27
num_days  = 16
 
 
# Build our set of dates and values for the curves
 
dates    = nil
values_sin  = nil
values_cos  = nil
 
for i = 0 to num_days by hour(6) do
    dates  = dates & ([date_start + i])
    values_sin = values_sin & [sin(i)]
    values_cos = values_cos & [cos(i)]
end for
 
 
# graph plotting attributes
 
graph_attrib_sin    = pgraph
(
    legend            : "on",
    legend_user_text  : "sin curve",
    graph_line_colour : "blue",
    graph_line_style  : "dash"
)
 
graph_attrib_cos    = pgraph
(
    legend            : "on",
    legend_user_text  : 'cos curve',
    graph_line_colour : "red"
)
 
 
# define the curves and associate them with the plotting attributes
 
curve_def_sin    = curve
(
    x_values    : dates,
    y_values    : values_sin,
    attributes  : graph_attrib_sin
)
 
curve_def_cos    = curve
(
    x_values    : dates,
    y_values    : values_cos,
    attributes  : graph_attrib_cos
)
 
 
 
# define the plot's title and legend attributes
 
text_plot = ptext
(
    text_automatic : "no",
    text_user      : "yes",
    text_line_1    : "Example curve plot"
)
 
 
 
# Define the output media
 
to_screen = output
(
    format        : "screen"
)
 
to_psfile = output
(
    format       : "postscript",
    destination  : "file",
    ncopies      : 1,
    file_name    : "curves.ps"
)
 
 
# 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 setoutput(to_screen)
else     fail("Only execute, batch and visualise allowed")
end if
 
 
# Call function to build layout (defined at end of macro)
 
dw = build_layout (dates)
 
 
# Plot the curves
 
plot (dw, curve_def_sin,text_plot)
plot (dw, curve_def_cos,text_plot)
 
 
#################################################################
#
#                End of Main Macro
#
#################################################################
 
 
# Function to build the layout
 
function build_layout(dates : list)
 
    horizontal_axis = paxis
    (
        axis_type           : 'date',
        axis_date_min_value : dates [1],
        axis_date_max_value : dates [count(dates)],
        axis_date_type      : 'days'
    )
 
    vertical_axis = paxis
    (
        axis_title_text    : 'y-axis title',
        axis_orientation   : 'vertical'
    )
 
    curveview = curveview
    (
        horizontal_axis      : horizontal_axis,
        vertical_axis        : vertical_axis
    )
 
    page1 = plot_page
    (
        view  : curveview
    )
 
    _display_window_ = plot_superpage
    (
        pages : [page1]
    )
 
    return _display_window_
 
end build_layout
 
 
Column
mv4-curve-plot.html