I'm writing some software that involves a breakdown of data by country. For it, I plan on using a pie chart where each slice corresponds to the activity in a certain country. I'm wondering - is there any recommended way to choose which color goes with which country? The USA seems like red white or blue, but that's the same as the UK and Australia. Or would it best to just choose distinct colors, not worrying about them being obvious which country it is?
USA, UK, Chile, Czech republic, Russia, Serbia, Philippines all have Red, White and Blue as primary colors in their flags. It might be an overkill to identify the best color to represent each country for a pie chart.
However, if you would like to build a color pallet, one source you can check out is the Passport colors of various countries > https://www.passportindex.org/index.php
You can also look at the Sports uniforms that countries wear for global events like Olympics.
I would choose just random colors, depending on your target audience, it may discourage, or could create an offensive feeling.
Remember, color affects emotion, therefore, depending on your data you are going to show, choose randomly but in similar hue, or saturation.
I would also consider to choose what type of other UI it will be interacting, like background colors, and overall theme of your UI.
As you can see here, publishers of world maps don't agree on any standard colours, but if you chose to reuse a palette from one of these map publishers, at least your palette would conform to some standard, rather than an entirely new scheme.
Another simple theme you can consider is political: left wing countries can be red, right wing countries blue, and middle (liberal) countries yellow. How these will be interpreted might depend on your audience. In the USA the phrase "red states and blue states" embodies this idea.
In the past it was also common for British maps to show Commonwealth countries in pink.
Taking that to its extreme, you could consider using miniaturized and tiled country flags as the texture for each country!
I suggest to steer clear from the country colors, because so many countries are sharing the dominating colors of the flag — US, UK, France and Russia all have the red-blue-white flag, so if you use the connection flag color — country, it can be extremely confusing.
Just use the palette that rhymes with your UI coloring. Colors in the palette should all equally be different from each other, so they don't blend in the chart.
Palette tools: colorschemedesigner.com, color.adobe.com.