Set Polygon FaceColor to 'none' after coloring it using mapshow
28 ビュー (過去 30 日間)
古いコメントを表示
Hi,Im having trouble with FaceColor using map show.
I'm loading a shapefile and plot it using mapshow with no fill.
after wards, I want to color some of the polygon's red (let's say it polygons No. 1,3 &5).
B = shaperead('Sub_basins.shp');
mapshow(B,'FaceColor','none');
mapshow(B([1 5 6]),'FaceColor', 'r')
later on, I want to erase the color from some of them (let's say No. 1):
mapshow(B(1),'FaceColor', 'none')
But for some reason, the polygon stays red.
Did anyone have a solution for this?
I'm attaching the .shp file if it helps.
Thanks!
Amit
0 件のコメント
採用された回答
Ritish Sehgal
2023 年 1 月 24 日
Hi,
You can try setting the ‘FaceColor’ attribute to white color to remove the red color of the Polygon.
For example, the below command will whiten the 1st Polygon.
mapshow(B(1), 'FaceColor', 'w')
Hope it helps!!
2 件のコメント
Ritish Sehgal
2023 年 1 月 31 日
Hi,
It is an expected behavior in “mapshow” function. This function adds polygon objects to the same figure handle without removing any preceding polygon object. It is similar to using “hold on” for an ‘axes’ object to plot multiple datasets.
When you set the polygon FaceColor to ‘none’ in the third call to “mapshow” function it adds a polygon with FaceColor = ‘none’ on top of the polygon which already exists (i.e. polygon with FaceColor = ‘r’) and hence not affecting the displayed figure.
You can access the polygon objects and update their properties using the output argument of “mapshow” function. So, the commands can be re-written in the following way:
B = shaperead('Sub_basins.shp');
ms = mapshow(B, "FaceColor", "none");
set([ms.Children([1,5,6])], "FaceColor", "r")
set(ms.Children(1), "FaceColor", "none")
Hope it helps!!
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!