...
Create a new Input Visualiser icon. Set Input Plot Type to XYPoints and type a list of values (forward slash-delimited) for both Input X Values and Input Y Values (they should have the same number of elements). So the first number from Input X Values together with the first number from Input Y Values form one point in the graph, and so on.
Visualise the icon to get a basic plot of the data. You can drop a customised Symbol Plotting icon into the Display Window to change the numbers into markers. If you wish to have a plot where the individual points are coloured according to some value, set Input Values to a list of numbers. Then an appropriate Symbol Plotting icon will colour the markers.
...
Info |
---|
In Organising Macros we will see how to put similar code into functions in order to reduce duplication of code. |
Plotting onto a Map
XXXXXXXX
All of the icons (and their Macro equivalent functions) which plot graph data to an X/Y (Cartesian) axis can also plot graph data onto a map using lat/lon coordinates. As an example, we will plot a box which bounds a simple geographical region.
We will do this in two different ways; first, using the Input Visualiser.
Marking an area using Input Visualiser
Create a new Input Visualiser icon and set Input Plot Type to Geo Points. We want to define 4 lines, therefore we need a list of 5 points to connect together in order to create a closed box.
You can choose your own coordinates, or use these: top latitude = 65, bottom latitude = 51, left longitude = -5, right longitude = 26. Set Input Longitude Values and Input Latitude Values to each be a list of 5 numbers which will describe the four corners (and repeat the first). When you drop a Graph Plotting icon into the plot, the points should be connected into a rectangle (if this is not the case, check the ordering of your points!). This can be a simple way or marking an area on a map. You can have as many points as you wish, and therefore have more complex polygons. You could also read polygons from a file and plot them on the map using some Macro code - an example of this will be see in Case study: Plotting the Track of Hurricane Sandy.
Depending on what you want, this method has a limitation - the lines do not follow the projection of the view; they are just straight lines on the screen (see the images above). This is fine in cylindrical projection, but not in many others. Try plotting the lines in a polar stereographic Geographical View.
Marking an area using mvl_geoline
Macro has a function called mvl_geoline
()
which simply splits a geographic line into smaller parts which will follow any view projection.
Panel |
---|
The first four parameters define the end-points of the line. Parameter |
Create a new Macro icon and set up the coordinates of the box, for example:
Code Block | ||
---|---|---|
| ||
toplat = 65
botlat = 51
leftlon = -5
rightlon = 26 |
Define the first line of the box like this:
Code Block | ||
---|---|---|
| ||
increment = 0.1
line1 = mvl_geoline(toplat, leftlon, toplat, rightlon, increment) |
Now finish off the box with the remaining 3 lines. They can then all be put into the plot()
command like this, with an optional Graph Plotting visdef defined somewhere in the macro:
Code Block | ||
---|---|---|
| ||
plot(line1, line2, line3, line4, red_line) |
Run the macro and drop a polar stereographic view into the Display Window to see the difference from the previous version.
An alternative is to combine the lines into a list before passing it to the plot()
command:
Code Block | ||
---|---|---|
| ||
to_plot = [line1, line2, line3, line4]
plot(to_plot, red_line) |
Extra Work
Customise the time series plot:
- put some extra space around the data points - add a day to each end of the x axis using a custom Cartesian View
- add a useful legend indicating that the blue line is the 24h forecast data and the red line is the analysis data
Geo boxes side-by-side
Write a macro which creates a 2-page layout similar to the image under "Plotting onto a Map". Use the two different box-drawing techniques, one in each page. Ensure they use the same variables to define the bounds of the box.