Adjust plot() calls
Note
The Macro to Python converter is available from Metview version 5.22.0
In Macro we can call plot()
multiple times for a given graphical output. However, in Python it behaves differently and only the result of the last call is kept. The converter is not able to merge multiple plot()
calls into a single one, instead a warning is placed to the top of the generated Python script and the adjustment has to be made manually.
In Macro we use multiple plot()
calls
for a graphical output when we have a layout, i.e. we use plot_superpage()
with multiple pages. The following examples show how to do the Macro to Python conversion in this case:
Macro code |
# create a 1x2 layout
dw = plot_superpage(pages: mvl_regular_layout(geoview(), 2, 1, 1, 1))
# invoke a plot command for each layout page separately
plot(dw[1], fs_1, visdef_1)
plot(dw[2], fs_2, visdef_2)
|
Adjusted Python code |
# create a 1x2 layout
dw = mv.plot_superpage(pages=mvl_regular_layout(mv.geoview(), 2, 1, 1, 1))
# collect all the plot arguments into a list
plt_data = []
plt_data.extend([dw[0], fs_1, visdef_1])
plt_data.extend([dw[1], fs_2, visdef_2])
# call plot with all the arguments
mv.plot(plt_data)
|
Macro code |
# create a 1x2 layout
dw = plot_superpage(pages: mvl_regular_layout(geoview(), 2, 1, 1, 1))
for i=1 to count(dw) do
plot(dw[i], fs[i])
end for
|
Adjusted Python code |
# create a 1x2 layout
dw = mv.plot_superpage(pages=mvl_regular_layout(mv.geoview(), 2, 1, 1, 1))
# collect all the plot arguments into a list
plt_data = []
for i in range(len(dw)):
plt_data.extend([dw[i], fs[i]])
# call plot with all the arguments
mv.plot(plt_data)
|