4

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.

Sardar Usama
  • 19,536
  • 9
  • 36
  • 58
user2861089
  • 1,205
  • 4
  • 22
  • 44

2 Answers2

4

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):

enter image description here

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:

required output

Sardar Usama
  • 19,536
  • 9
  • 36
  • 58
1

I haven't really figured out why but when I set the DefaultFaceColor to almost white, it works...

'DefaultFaceColor',[1.000 0.9792 0.9792]
user2861089
  • 1,205
  • 4
  • 22
  • 44