Trim contour lines over map plot in Matlab -


i plotted set of contour lines , on them, shapefile map shape similar ones found here.

f = triscatteredinterp(x,y,z); [qx, qy] = meshgrid(1:.01:10,1:.01:10);  qz = f(qx, qy); contour(qx, qy, qz, 10); hold on;  plot([shp.x],[shp.y],'k'); axis equal 

however, since countour defined on square region goes outside limits of map (shapefile), doesn't nice.

is there way can cut/trim/hide contour lines fall outside limits of map have contour lines contained within map?

thanks!

you can use axis keyword constrain limits of contour plot. if these limits shape data ought let crop image required:

xmin = min(min(shp.x)); xmax = max(max(shp.x); ymin = min(min(shp.y)); ymax = max(max(shp.y)); axis([xmin, xmax, ymin, ymax]); 

alternatively may find clipping option contour sufficient.

update: above clip contour plot bounding box of shapefile, if want contours show inside shape it's touch more complicated. you'd want create rectangular patch size of desired axes limits hole in middle defined shape data.

if have mapping toolbox, @ least possible given nature of question, can use poly2fv. make 2 polygons, 1 size of plot range

x1 = [xmin xmin xmax xmax xmin]; y1 = [ymin ymax ymax ymin ymin]; 

and other defined shape data, convert faces , vertices

[f, v] = poly2fv({x1, x2}, {y1, y2}); 

and plot patch

patch('faces', f', 'vertices', v, 'facecolor', 'w');  

where can change facecolor match plot background.

if don't have mapping toolbox might have make patches hand. there other tricks involving alpha masks work on image data rather plots.


Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

order - Notification for user in user account opencart -