How to fill polygon with multiple equally different colors (3, 4, 5 and more colors) - Code needed (Symbology - Geometry generator)

I need to make a map with politics of the European Union and found that the numbers of members from some parties are equal, for example:

Netherlands : EPP - 6, S&D - 6, Renew Europe - 6

I tried searching on the internet how to divide polygon into different colors and found only this : Filling polygon with 2 different colours representing 2 different sets of data using QGIS, which mentions only how to divide a polygon in 2 equal colors.

I do not have 2 datasets, I just need to edit the name of the colors within the legend.

I would like to know how should that code be modified in order to divide a polygon in 3 / 4 / 5 or more equal colors. Or if that code can not be modified, how to code what I need from 0 because I am clueless. I tried to play around with the code but nothing worked out.

Here you have Austria as an example divided in 2 equal colors ( not from the map I want to make ) . I need to divide a polygon just like Austria in 3 equal colors and if it possible divide other polygons in 4 / 5 or more colors :

Here is what I would like to achieve in QGIS through coding in Symbology - Geometry generator and not digitizing ( the images are edited in Paint ) :

3 equally sized polygons :

4 equally sized polygons :

5 equally sized polygons :

6 equally sized polygons :

Etc. and more than 6 , the code should be similar from here on

19 equally sized polygons with 4 lines north-south and 4 line west-east

• Can you provide an example of what you're trying to achieve?
– Erik
Commented Jan 9, 2023 at 11:35
• I need to divide a polygon in 3 / 4 / 5 colors or more just like in this post : gis.stackexchange.com/questions/384898/… . I tried changing the code to I tried changing \$geometry to \$boundary , \$bounds etc. I also changed the values from 100000 to 10000000 more or less . I tried to make a second line which could go east - west besides north south .
– Zoro
Commented Jan 9, 2023 at 12:14
• I do not know what else should be done . I try to achieve something visually something like this within a polygon : puzzling.stackexchange.com/questions/44740/… . You have a square with 4 more equally sized and colored squares .
– Zoro
Commented Jan 9, 2023 at 12:15
• I try to add another line from north to south which divides a polygon like Austria in 3 equally sized regions and another line from west to east which could divide the Austria polygon in 6 regions if I have 2 lines north south , or 4 regions if I have only 1 line north south .
– Zoro
Commented Jan 9, 2023 at 12:26
• Since the data seems fairly static, you could pre-process it like in this post
– JGH
Commented Jan 9, 2023 at 13:17