Azzera filtri
Azzera filtri

Polygons in map turn out black when printed (2014b)

1 visualizzazione (ultimi 30 giorni)
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';
%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)],...
%Place polygons on map using geoshow
%Show some coasts, just for funsies
coast = load('coast');
framem off; gridm off; axis off; mlabel off; plabel off;
%Print (set to png, but this happens pretty much in any format)
Thanks in advance for your time and help!

Risposta accettata

ks905383 il 10 Mag 2017
I actually finally found an answer to this issue, which has been bugging me for ages! - It seem like a bug that can be fixed through setting the 'InvertHardcopy' property on the relevant figure to 'off' and instead set the figure background manually to white. So, a fix to the above code would be
figure1 = gcf;
figure1.InvertHardcopy = 'off';
figure1.Color = [1 1 1];
InvertHardcopy is supposed to set the figure background to white (as opposed to the default grey used in figure windows), but there seems to a be a bug that shows up sometimes when white structures are plotted. (Thanks to the forum posts and !)

Più risposte (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by