My figure is a map of the USA. I would like all states' facecolor
to be white unless specified:
ax = usamap('conus');
states = shaperead('usastatelo', 'UseGeoCoords', true,'Selector',{@(name) ~any(strcmp(name,{'Alaska','Hawaii'})), 'Name'});
faceColors = makesymbolspec('Polygon', {'Name','Washington','FaceColor','red'}, {'Name','Alabama','FaceColor','red'});
geoshow(ax, states, 'DisplayType', 'polygon', 'SymbolSpec', faceColors,'DefaultFaceColor','w','DefaultEdgeColor','black')
framem off; gridm off; mlabel off; plabel off
But when I print it using:
print -r600 -dtiff MyMap.tif
and open the figure, some of the states' facecolor
on the east are black.
Why is this and how can I fix it? Thanks.
This bug does not exist in MATLAB 2016a. But I tried your code in MATLAB 2015a and I got the following .tif file as output (which is also described by you in the question):
There is a workaround to make this right. Before using print
command, write the following line:
set(gcf, 'color', 'w', 'InvertHardCopy', 'off');
which gives the desired .tif output file as shown below: