matplot: coastline

Example showing the coastline (function patch)

Code:


// the global variable 'countries' is loaded from the file countries.js
var i,j, coord;


// make a figure of size 700 x 500 pixels
fig = new matplot.Figure("plot",700,500, {renderer: matplot.RasterCanvas});

// add axis to the figure
ax = fig.axes();

// loop over all countries and polygones
for (i=0; i < countries.length; i++) {
  for (j=0; j < countries[i].coordinates.length; j++) {
    // countries[i].coordinates[j] is a list of [longitude,latitude]
    coord = numeric.transpose(countries[i].coordinates[j]);
    ax.patch(coord[0],coord[1],{color: 'blue'});
  }
}

// draw everything
fig.draw();