# Flag colors

**URL:** <https://discourse.julialang.org/t/flag-colors/55853>\
**Category:** Visualization\
**Created:** [February 23, 2021, 2:15pm UTC](https://discourse.julialang.org/t/flag-colors/55853 "2021-02-23T14:15:09Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![gustaphe](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gustaphe/32/18174_2.png) [@gustaphe](https://discourse.julialang.org/u/gustaphe)\
**Post date:** [February 23, 2021, 2:15pm UTC](https://discourse.julialang.org/t/flag-colors/55853/1 "2021-02-23T14:15:09Z")

</div>

I made another dumb thing. Here’s a collection of flag colors. Do you think something like this would be useful to you? Is this a reasonable way to use it, or should it hook in to some other Colors functionality?

> **[GitHub - gustaphe/FlagColors.jl](https://github.com/gustaphe/FlagColors.jl)**
>
> Contribute to gustaphe/FlagColors.jl development by creating an account on GitHub.

![Example flag colors](https://global.discourse-cdn.com/julialang/original/3X/e/6/e6c1167d895c47dd3787ad3d19b9024672169dc7.png)

---

<div class="post-metadata">

**Author:** ![moeddel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/moeddel/32/18641_2.png) [@moeddel](https://discourse.julialang.org/u/moeddel)\
**Post date:** [February 23, 2021, 3:29pm UTC](https://discourse.julialang.org/t/flag-colors/55853/2 "2021-02-23T15:29:36Z")

</div>

In my opinion `ColorSchemes` would be the perfect place.

---

<div class="post-metadata">

**Author:** ![gustaphe](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gustaphe/32/18174_2.png) [@gustaphe](https://discourse.julialang.org/u/gustaphe)\
**Post date:** [February 24, 2021, 6:20pm UTC](https://discourse.julialang.org/t/flag-colors/55853/3 "2021-02-24T18:20:41Z")

</div>

I wasn’t going to, but then it was that or go to bed so it’s in there now.

---

<div class="post-metadata">

**Author:** ![BLI](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bli/32/37206_2.png) [@BLI](https://discourse.julialang.org/u/BLI)\
**Post date:** [February 24, 2021, 6:58pm UTC](https://discourse.julialang.org/t/flag-colors/55853/4 "2021-02-24T18:58:53Z")

</div>

Seems nice. I’m a little surprised by the rendering, though… Nordic countries such as Finland, Denmark, and Sweden have a background color (white, red, blue, respectively), and a cross with a smaller area and with another color (blue, white, yellow, respectively). The Finnish flag scheme is _dominated_ by blue (which covers a minor part of the flag), the Danish flag scheme has very little white (admittedly the colors that covers the smallest part of the area), while the Swedish flag scheme is almost as much dominated by the minority color as the Finnish flag – and looks somewhat strange in that a large fraction of the Swedish scheme appears as green – a color that is not in the flag.

Anyway, I’m curious as to how you made the schemes :-).

---

<div class="post-metadata">

**Author:** ![gustaphe](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gustaphe/32/18174_2.png) [@gustaphe](https://discourse.julialang.org/u/gustaphe)\
**Post date:** [February 24, 2021, 9:21pm UTC](https://discourse.julialang.org/t/flag-colors/55853/5 "2021-02-24T21:21:37Z")

</div>

I made a counscious decision to automate the process as much as possible, to avoid both work and diplomatic liability.

The current colorschemes in [Colorschemes](https://juliagraphics.github.io/ColorSchemes.jl/latest/basics/#Flags) were generated as follows:

1. For each flag code, the svg flag is opened
2. If there are any `g` tags containing a `fill` or `stroke` specification, those colors are added to a color list
3. If there is any css `fill:` or `stroke:` specification, those colors are added
4. If there are any `stop-color` specifications, those colors are added (this is for gradients, which are otherwise very difficult to handle)
5. If there are any `path`, `circle` or `rect` tags without a color specification, and no colors were added in points 2 – 4, black is added (for some reason svg will default to black if no color is inherited
6. All color specifications from `path`, `circle` or `rect` tags are added
7. The list is `unique`d

All this is to say, there might be a black or white extra or missing in some flags, but that is because they have a complicated flag with a weird svg file. Also, colors appear (roughly) in the order they do in the file, which doesn’t necessarily correspond to their order or abundance on the flag.

The picture above is the `cgrad` of the scheme, basically the colors it takes if you go continuously from one end to the other. The link above displays the normal color scheme better, and there the Nordic flags make more sense.There is still no order or abundance information though. It was either do it like this or edit over 300 flags manually.

---

<div class="post-metadata">

**Author:** ![BLI](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bli/32/37206_2.png) [@BLI](https://discourse.julialang.org/u/BLI)\
**Post date:** [February 25, 2021, 5:59pm UTC](https://discourse.julialang.org/t/flag-colors/55853/6 "2021-02-25T17:59:43Z")

</div>

Nice idea. Still, it is complicated to make it so that people are happy when you attach the “flag” label to it: I’d guess that, e.g., Swedes, may find it strange with a green color in the mixture. But that is perhaps unavoidable when using `cgrad()`. I’m don’t have any ideas to fix the color mixing problem 😮…

---

<div class="post-metadata">

**Author:** ![gustaphe](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gustaphe/32/18174_2.png) [@gustaphe](https://discourse.julialang.org/u/gustaphe)\
**Post date:** [February 25, 2021, 6:03pm UTC](https://discourse.julialang.org/t/flag-colors/55853/7 "2021-02-25T18:03:09Z")

</div>

I’m Swedish incidentally.

The solution is simple, only use these as discrete color schemes.

---

<div class="post-metadata">

**Author:** ![moeddel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/moeddel/32/18641_2.png) [@moeddel](https://discourse.julialang.org/u/moeddel)\
**Post date:** [February 25, 2021, 7:06pm UTC](https://discourse.julialang.org/t/flag-colors/55853/8 "2021-02-25T19:06:35Z")

</div>

Just throwing in ideas. If you would use a raster image, you could make a histogram of the colors and use this for colormap creation.
