Flag Colors

Find out which flag colors are most common in different parts of the world.

Run the code to get the flags of Europe. Try other regions, like south america or northern europe:

SHOW/HIDE DETAILS

Get an Entity that represents the countries of Europe. Type += to get a natural language input box and type europe. Run the code with +:

\!\(\* NamespaceBox["LinguisticAssistant", DynamicModuleBox[{Typeset`query$$ = "europe", Typeset`boxes$$ = TemplateBox[{"\"Europe\"", RowBox[{"EntityClass", "[", RowBox[{"\"Country\"", ",", "\"Europe\""}], "]"}], "\"EntityClass[\\\"Country\\\", \\\"Europe\\\"]\"", "\"countries\""}, "EntityClass"], Typeset`allassumptions$$ = {{ "type" -> "Clash", "word" -> "europe", "template" -> "Assuming \"${word}\" is ${desc1}. Use as \ ${desc2} instead", "count" -> "2", "Values" -> {{ "name" -> "CountryClass", "desc" -> "a class of countries", "input" -> "*C.europe-_*CountryClass-"}, { "name" -> "Word", "desc" -> "a word", "input" -> "*C.europe-_*Word-"}}}, { "type" -> "SubCategory", "word" -> "europe", "template" -> "Assuming ${desc1}. Use ${desc2} instead", "count" -> "4", "Values" -> {{ "name" -> "Europe", "desc" -> "Europe", "input" -> "*DPClash.CountryEC.europe-_*Europe-"}, { "name" -> "EuropeSovereign", "desc" -> "sovereign states in Europe", "input" -> "*DPClash.CountryEC.europe-_*EuropeSovereign-"}, { "name" -> "EuropeExtended", "desc" -> "Europe with Russia and Turkey", "input" -> "*DPClash.CountryEC.europe-_*EuropeExtended-"}, { "name" -> "EuropeRussia", "desc" -> "Europe with Russia", "input" -> "*DPClash.CountryEC.europe-_*EuropeRussia-"}}}}, Typeset`assumptions$$ = {}, Typeset`open$$ = {1}, Typeset`querystate$$ = { "Online" -> True, "Allowed" -> True, "mparse.jsp" -> 0.276033`5.892505998971276, "Messages" -> {}}}, DynamicBox[ToBoxes[ AlphaIntegration`LinguisticAssistantBoxes["", 4, Automatic, Dynamic[Typeset`query$$], Dynamic[Typeset`boxes$$], Dynamic[Typeset`allassumptions$$], Dynamic[Typeset`assumptions$$], Dynamic[Typeset`open$$], Dynamic[Typeset`querystate$$]], StandardForm], ImageSizeCache->{58., {7., 16.}}, TrackedSymbols:>{ Typeset`query$$, Typeset`boxes$$, Typeset`allassumptions$$, Typeset`assumptions$$, Typeset`open$$, Typeset`querystate$$}], DynamicModuleValues:>{}, UndoTrackedVariables:>{Typeset`open$$}], BaseStyle->{"Deploy"}, DeleteWithContents->True, Editable->False, SelectWithContents->True]\)

Get the names of the countries of Europe:

\!\(\* NamespaceBox["LinguisticAssistant", DynamicModuleBox[{Typeset`query$$ = "europe", Typeset`boxes$$ = TemplateBox[{"\"Europe\"", RowBox[{"EntityClass", "[", RowBox[{"\"Country\"", ",", "\"Europe\""}], "]"}], "\"EntityClass[\\\"Country\\\", \\\"Europe\\\"]\"", "\"countries\""}, "EntityClass"], Typeset`allassumptions$$ = {{ "type" -> "Clash", "word" -> "europe", "template" -> "Assuming \"${word}\" is ${desc1}. Use as \ ${desc2} instead", "count" -> "2", "Values" -> {{ "name" -> "CountryClass", "desc" -> "a class of countries", "input" -> "*C.europe-_*CountryClass-"}, { "name" -> "Word", "desc" -> "a word", "input" -> "*C.europe-_*Word-"}}}, { "type" -> "SubCategory", "word" -> "europe", "template" -> "Assuming ${desc1}. Use ${desc2} instead", "count" -> "4", "Values" -> {{ "name" -> "Europe", "desc" -> "Europe", "input" -> "*DPClash.CountryEC.europe-_*Europe-"}, { "name" -> "EuropeSovereign", "desc" -> "sovereign states in Europe", "input" -> "*DPClash.CountryEC.europe-_*EuropeSovereign-"}, \ {"name" -> "EuropeExtended", "desc" -> "Europe with Russia and Turkey", "input" -> "*DPClash.CountryEC.europe-_*EuropeExtended-"}, { "name" -> "EuropeRussia", "desc" -> "Europe with Russia", "input" -> "*DPClash.CountryEC.europe-_*EuropeRussia-"}}}}, Typeset`assumptions$$ = {}, Typeset`open$$ = {1}, Typeset`querystate$$ = { "Online" -> True, "Allowed" -> True, "mparse.jsp" -> 0.330045`5.97011815131117, "Messages" -> {}}}, DynamicBox[ToBoxes[ AlphaIntegration`LinguisticAssistantBoxes["", 4, Automatic, Dynamic[Typeset`query$$], Dynamic[Typeset`boxes$$], Dynamic[Typeset`allassumptions$$], Dynamic[Typeset`assumptions$$], Dynamic[Typeset`open$$], Dynamic[Typeset`querystate$$]], StandardForm], ImageSizeCache->{58., {7., 16.}}, TrackedSymbols:>{ Typeset`query$$, Typeset`boxes$$, Typeset`allassumptions$$, Typeset`assumptions$$, Typeset`open$$, Typeset`querystate$$}], DynamicModuleValues:>{}, UndoTrackedVariables:>{Typeset`open$$}], BaseStyle->{"Deploy"}, DeleteWithContents->True, Editable->False, SelectWithContents->True]\)["Name"]

Get images of the flags of the countries and give them the name flags:

flags = \!\(\* NamespaceBox["LinguisticAssistant", DynamicModuleBox[{Typeset`query$$ = "europe", Typeset`boxes$$ = TemplateBox[{"\"Europe\"", RowBox[{"EntityClass", "[", RowBox[{"\"Country\"", ",", "\"Europe\""}], "]"}], "\"EntityClass[\\\"Country\\\", \\\"Europe\\\"]\"", "\"countries\""}, "EntityClass"], Typeset`allassumptions$$ = {{ "type" -> "Clash", "word" -> "europe", "template" -> "Assuming \"${word}\" is ${desc1}. Use as \ ${desc2} instead", "count" -> "2", "Values" -> {{ "name" -> "CountryClass", "desc" -> "a class of countries", "input" -> "*C.europe-_*CountryClass-"}, { "name" -> "Word", "desc" -> "a word", "input" -> "*C.europe-_*Word-"}}}, { "type" -> "SubCategory", "word" -> "europe", "template" -> "Assuming ${desc1}. Use ${desc2} instead", "count" -> "4", "Values" -> {{ "name" -> "Europe", "desc" -> "Europe", "input" -> "*DPClash.CountryEC.europe-_*Europe-"}, { "name" -> "EuropeSovereign", "desc" -> "sovereign states in Europe", "input" -> "*DPClash.CountryEC.europe-_*EuropeSovereign-"},\ {"name" -> "EuropeExtended", "desc" -> "Europe with Russia and Turkey", "input" -> "*DPClash.CountryEC.europe-_*EuropeExtended-"}, \ {"name" -> "EuropeRussia", "desc" -> "Europe with Russia", "input" -> "*DPClash.CountryEC.europe-_*EuropeRussia-"}}}}, Typeset`assumptions$$ = {}, Typeset`open$$ = {1}, Typeset`querystate$$ = { "Online" -> True, "Allowed" -> True, "mparse.jsp" -> 0.330045`5.97011815131117, "Messages" -> {}}}, DynamicBox[ToBoxes[ AlphaIntegration`LinguisticAssistantBoxes["", 4, Automatic, Dynamic[Typeset`query$$], Dynamic[Typeset`boxes$$], Dynamic[Typeset`allassumptions$$], Dynamic[Typeset`assumptions$$], Dynamic[Typeset`open$$], Dynamic[Typeset`querystate$$]], StandardForm], ImageSizeCache->{58., {7., 16.}}, TrackedSymbols:>{ Typeset`query$$, Typeset`boxes$$, Typeset`allassumptions$$, Typeset`assumptions$$, Typeset`open$$, Typeset`querystate$$}], DynamicModuleValues:>{}, UndoTrackedVariables:>{Typeset`open$$}], BaseStyle->{"Deploy"}, DeleteWithContents->True, Editable->False, SelectWithContents->True]\)["FlagImage"]

HIDE DETAILS
flags = \!\(\* NamespaceBox["LinguisticAssistant", DynamicModuleBox[{Typeset`query$$ = "europe", Typeset`boxes$$ = TemplateBox[{"\"Europe\"", RowBox[{"EntityClass", "[", RowBox[{"\"Country\"", ",", "\"Europe\""}], "]"}], "\"EntityClass[\\\"Country\\\", \\\"Europe\\\"]\"", "\"countries\""}, "EntityClass"], Typeset`allassumptions$$ = {{ "type" -> "Clash", "word" -> "europe", "template" -> "Assuming \"${word}\" is ${desc1}. Use as \ ${desc2} instead", "count" -> "2", "Values" -> {{ "name" -> "CountryClass", "desc" -> "a class of countries", "input" -> "*C.europe-_*CountryClass-"}, { "name" -> "Word", "desc" -> "a word", "input" -> "*C.europe-_*Word-"}}}, { "type" -> "SubCategory", "word" -> "europe", "template" -> "Assuming ${desc1}. Use ${desc2} instead", "count" -> "4", "Values" -> {{ "name" -> "Europe", "desc" -> "Europe", "input" -> "*DPClash.CountryEC.europe-_*Europe-"}, { "name" -> "EuropeSovereign", "desc" -> "sovereign states in Europe", "input" -> "*DPClash.CountryEC.europe-_*EuropeSovereign-"},\ {"name" -> "EuropeExtended", "desc" -> "Europe with Russia and Turkey", "input" -> "*DPClash.CountryEC.europe-_*EuropeExtended-"}, \ {"name" -> "EuropeRussia", "desc" -> "Europe with Russia", "input" -> "*DPClash.CountryEC.europe-_*EuropeRussia-"}}}}, Typeset`assumptions$$ = {}, Typeset`open$$ = {1}, Typeset`querystate$$ = { "Online" -> True, "Allowed" -> True, "mparse.jsp" -> 0.330045`5.97011815131117, "Messages" -> {}}}, DynamicBox[ToBoxes[ AlphaIntegration`LinguisticAssistantBoxes["", 4, Automatic, Dynamic[Typeset`query$$], Dynamic[Typeset`boxes$$], Dynamic[Typeset`allassumptions$$], Dynamic[Typeset`assumptions$$], Dynamic[Typeset`open$$], Dynamic[Typeset`querystate$$]], StandardForm], ImageSizeCache->{61., {7., 16.}}, TrackedSymbols:>{ Typeset`query$$, Typeset`boxes$$, Typeset`allassumptions$$, Typeset`assumptions$$, Typeset`open$$, Typeset`querystate$$}], DynamicModuleValues:>{}, UndoTrackedVariables:>{Typeset`open$$}], BaseStyle->{"Deploy"}, DeleteWithContents->True, Editable->False, SelectWithContents->True]\)["FlagImage"]

Get the dominant colors of the flags:

Note: run the code in the previous step first.

SHOW/HIDE DETAILS

This is the flag of the first country in the list, Austria:

flags[[1]]

Get its dominant colors:

DominantColors[flags[[1]]]

Get the dominant colors of each European flag by mapping DominantColors over the flags list:

DominantColors /@ flags

HIDE DETAILS
DominantColors /@ flags

Plot the colors. Try different point sizes:

SHOW/HIDE DETAILS

A chromaticity plot shows the positions of colors in a color space. Related colors are close together. Rotate the graphic with the mouse to see how the colors cluster in the color space:

ChromaticityPlot3D[DominantColors /@ flags]

Make the colors easier to see by increasing the size of the points:

ChromaticityPlot3D[DominantColors /@ flags, PlotStyle -> PointSize[.02]]

White colors in the plot dont show up on a white background. Make the background light gray so you can see them:

ChromaticityPlot3D[DominantColors /@ flags, PlotStyle -> PointSize[.02], Background -> LightGray]

Add the RGB color space gamut, which shows the range of possible colors, to the plot:

ChromaticityPlot3D[{DominantColors /@ flags, "RGB"}, PlotStyle -> PointSize[.02], Background -> LightGray]

HIDE DETAILS
ChromaticityPlot3D[{DominantColors /@ flags, "RGB"}, PlotStyle -> PointSize[.02], Background -> LightGray]

Share ItMake a website that shows a countrys flag and its dominant colors:

SHOW/HIDE DETAILS

Heres how to use Column to display a countrys flag with its dominant colors underneath:

country = \!\(\* NamespaceBox["LinguisticAssistant", DynamicModuleBox[{Typeset`query$$ = "ecuador", Typeset`boxes$$ = TemplateBox[{"\"Ecuador\"", RowBox[{"Entity", "[", RowBox[{"\"Country\"", ",", "\"Ecuador\""}], "]"}], "\"Entity[\\\"Country\\\", \\\"Ecuador\\\"]\"", "\"country\""}, "Entity"], Typeset`allassumptions$$ = {{ "type" -> "Clash", "word" -> "ecuador", "template" -> "Assuming \"${word}\" is ${desc1}. Use as \ ${desc2} instead", "count" -> "3", "Values" -> {{ "name" -> "Country", "desc" -> "a country", "input" -> "*C.ecuador-_*Country-"}, { "name" -> "Volcano", "desc" -> "a volcano", "input" -> "*C.ecuador-_*Volcano-"}, { "name" -> "TranslationData", "desc" -> " referring to translations", "input" -> "*C.ecuador-_*TranslationData-"}}}}, Typeset`assumptions$$ = {}, Typeset`open$$ = {1, 2}, Typeset`querystate$$ = { "Online" -> True, "Allowed" -> True, "mparse.jsp" -> 0.395302`6.048474005123957, "Messages" -> {}}}, DynamicBox[ToBoxes[ AlphaIntegration`LinguisticAssistantBoxes["", 4, Automatic, Dynamic[Typeset`query$$], Dynamic[Typeset`boxes$$], Dynamic[Typeset`allassumptions$$], Dynamic[Typeset`assumptions$$], Dynamic[Typeset`open$$], Dynamic[Typeset`querystate$$]], StandardForm], ImageSizeCache->{101., {7., 15.}}, TrackedSymbols:>{ Typeset`query$$, Typeset`boxes$$, Typeset`allassumptions$$, Typeset`assumptions$$, Typeset`open$$, Typeset`querystate$$}], DynamicModuleValues:>{}, UndoTrackedVariables:>{Typeset`open$$}], BaseStyle->{"Deploy"}, DeleteWithContents->True, Editable->False, SelectWithContents->True]\); Column[{country["FlagImage"], DominantColors[country["FlagImage"]]}]

Deploy a form that asks for a country and displays that countrys flag and its dominant colors:

CloudDeploy[ FormFunction[{"country" -> "Country"}, Column[{#country["FlagImage"], DominantColors[#country["FlagImage"]]}] &, "PNG" ], Permissions -> "Public" ]

Click on the link in the output to visit the site.

Tell the world about your creation by sharing the link via email, tweet, or other message.

HIDE DETAILS
CloudDeploy[ FormFunction[{"country" -> "Country"}, Column[{#country["FlagImage"], DominantColors[#country["FlagImage"]]}] &, "PNG" ], Permissions -> "Public" ]