Polygons in map turn out black when printed (2014b)
Ältere Kommentare anzeigen
Hi all,
I frequently need to make maps of gridded data and have been using individual polygons for pixels to get around the pcolorm/etc. issues. However, when the border of the map cuts through one of these polygons, those polygons come out black when printed, but only if the polygon itself is white. Has anybody faced this issue before / found a reason or solution?
Things I've tried: changing renderer, changing origin such that it doesn't cut off a polygon anymore, changing output format.
Here's a minimal example of this issue (see attached file for the figure output, note how the polygon at the page break is black, despite all polygons set to being white in the code):
%Set coordinates and borders for polygons (usually not uniform, but for
%purpose of ex.)
lat = -89:2:89;
lon = -179:2:179;
lat_bnds = [[-90:2:88]' [-88:2:90]'];
lon_bnds = [[-180:2:178]' [-178:2:180]'];
%Pre-allocate the polygon structure
struct_poly(length(lon)*length(lat)).Lat = 0;
%Set borders in polygon syntax (with NaNs between individual polygons),
%with one polygon per pixel
for poly_idx = 1:length(lon)*length(lat);
[lon_idx,lat_idx] = ind2sub([length(lon) length(lat)],poly_idx);
struct_poly(poly_idx).Lat = [lat_bnds(lat_idx,1); lat_bnds(lat_idx,2);...
lat_bnds(lat_idx,2); lat_bnds(lat_idx,1); lat_bnds(lat_idx,1);NaN];
struct_poly(poly_idx).Lon = [lon_bnds(lon_idx,1); lon_bnds(lon_idx,1);...
lon_bnds(lon_idx,2); lon_bnds(lon_idx,2); lon_bnds(lon_idx,1);NaN];
struct_poly(poly_idx).Geometry = 'Polygon';
end
%Set colors of these polygons (all white for demonstration of issue, otherwise set by data)
plot_colors = repmat([1 1 1],162000,1);
color_atts = makesymbolspec('Polygon',{'INDEX',[1 numel(struct_poly)],...
'FaceColor',plot_colors,'LineStyle','none'});
%Place polygons on map using geoshow
axesm('bsam','Origin',155)
geoshow(struct_poly,'SymbolSpec',color_atts)
%Show some coasts, just for funsies
coast = load('coast');
geoshow(coast.lat,coast.long,'Color','black')
framem off; gridm off; axis off; mlabel off; plabel off;
%Print (set to png, but this happens pretty much in any format)
print(gcf,'-dpng','polygon_test')
Thanks in advance for your time and help!
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Graphics Object Properties finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!