Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- france = Apply[Table, CountryData["France", "Polygon"]][[1]];
- spain = Apply[Table, CountryData["Spain", "Polygon"]][[1]]; img =
- Style[Graphics[{
- Opacity[1/2],
- Red,
- Polygon[france],
- Green,
- Polygon[spain],
- Blue,
- Rectangle[{Min[First /@ spain],
- Max[Last /@ spain]}, {Max[First /@ france], Min[Last /@ france]}]
- }, ImageSize -> 1000], Antialiasing -> False];
- imgRast = Tally[Flatten[ImageData[Rasterize[img]], 1]][[2 ;;]];
- Graphics[Table[{RGBColor @@ imgRast[[i, 1]],
- Rectangle[{i, 0}, {i + 1, 1}]}, {i, Length[imgRast]}]];
- GraphicsGrid[{
- {PieChart[{imgRast[[1, 2]], imgRast[[4, 2]]},
- ChartLegends -> {Style["France below no part of Spain", Medium],
- Style["France below some part of Spain", Medium]},
- ChartStyle -> {RGBColor @@ imgRast[[1, 1]],
- RGBColor @@ imgRast[[4, 1]]},
- ChartLabels -> (N[100*#, 3] "%" & /@ {imgRast[[1, 2]],
- imgRast[[4, 2]]}/(imgRast[[1, 2]] + imgRast[[4, 2]]))],
- PieChart[{imgRast[[6, 2]], imgRast[[3, 2]]},
- ChartLegends -> {Style["Spain above no part of France", Medium],
- Style["Spain above some part of France", Medium]},
- ChartStyle -> {RGBColor @@ imgRast[[6, 1]],
- RGBColor @@ imgRast[[3, 1]]},
- ChartLabels -> (N[100*#, 3] "%" & /@ {imgRast[[6, 2]],
- imgRast[[3, 2]]}/(imgRast[[3, 2]] + imgRast[[6, 2]]))]},
- {img, SpanFromLeft}
- }
- ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement