Advertisement
Matthen

Spain and France

Jul 26th, 2012
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. france = Apply[Table, CountryData["France", "Polygon"]][[1]];
  2. spain = Apply[Table, CountryData["Spain", "Polygon"]][[1]]; img =
  3. Style[Graphics[{
  4. Opacity[1/2],
  5. Red,
  6. Polygon[france],
  7. Green,
  8. Polygon[spain],
  9. Blue,
  10. Rectangle[{Min[First /@ spain],
  11. Max[Last /@ spain]}, {Max[First /@ france], Min[Last /@ france]}]
  12. }, ImageSize -> 1000], Antialiasing -> False];
  13. imgRast = Tally[Flatten[ImageData[Rasterize[img]], 1]][[2 ;;]];
  14. Graphics[Table[{RGBColor @@ imgRast[[i, 1]],
  15. Rectangle[{i, 0}, {i + 1, 1}]}, {i, Length[imgRast]}]];
  16. GraphicsGrid[{
  17. {PieChart[{imgRast[[1, 2]], imgRast[[4, 2]]},
  18. ChartLegends -> {Style["France below no part of Spain", Medium],
  19. Style["France below some part of Spain", Medium]},
  20. ChartStyle -> {RGBColor @@ imgRast[[1, 1]],
  21. RGBColor @@ imgRast[[4, 1]]},
  22. ChartLabels -> (N[100*#, 3] "%" & /@ {imgRast[[1, 2]],
  23. imgRast[[4, 2]]}/(imgRast[[1, 2]] + imgRast[[4, 2]]))],
  24. PieChart[{imgRast[[6, 2]], imgRast[[3, 2]]},
  25. ChartLegends -> {Style["Spain above no part of France", Medium],
  26. Style["Spain above some part of France", Medium]},
  27. ChartStyle -> {RGBColor @@ imgRast[[6, 1]],
  28. RGBColor @@ imgRast[[3, 1]]},
  29. ChartLabels -> (N[100*#, 3] "%" & /@ {imgRast[[6, 2]],
  30. imgRast[[3, 2]]}/(imgRast[[3, 2]] + imgRast[[6, 2]]))]},
  31. {img, SpanFromLeft}
  32. }
  33. ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement