A method of automatically optimizing data visualization chart colors
By selecting a suitable color palette and optimizing the palette color allocation using a genetic algorithm, the problem of high data type diversity and complexity in the existing technology is solved, automatic color optimization of data visualization charts is achieved, and the perceived harmony of the charts is improved.
Patent Information
- Application Number
- CN202310111453.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-14
- Publication Date
- 2025-10-10
- Estimated Expiration
- 2043-02-14
AI Technical Summary
The existing technology lacks methods for automatically matching and optimizing the colors of visualization charts of all data types. The visualization charts generated by methods based on graph data structures have poor color harmony, and methods based on genetic algorithms are unstable and highly complex.
A genetic algorithm is used to optimize the palette color distribution. By selecting Colorgorical and ColorBuilder palettes, combining the CIEDE2000 color difference formula and genetic algorithm, the number and distribution of palette colors are optimized. The crossover and mutation operations of the genetic algorithm are used to optimize the palette color distribution effect.
It realizes automatic color matching and optimization of visual charts of all data types, reduces the complexity of the algorithm, ensures the perception and harmony of chart colors, and avoids the impact of high complexity when the chart structure is complex.
Smart Images

Figure CN116009846B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of data visualization, and in particular relates to a method for automatically optimizing the colors of data visualization charts. Background Art
[0002] Charts are one of the primary ways to visualize data and are a crucial window for users to perceive, understand, and analyze data. In statistics, data types primarily include categorical data and numerical data. Categorical data is best visualized using bar charts, pie charts, and donut charts. Numerical data is best visualized using a variety of charts, including bar charts, pie charts, and donut charts, as well as histograms, line charts, and curve charts. When displaying visualizations for security situation awareness, banking data, geographic information data, and more on large screens, it's crucial for users to quickly perceive, understand, and analyze the data.
[0003] To enhance user perception of data, designers typically adjust visual charts by adjusting factors such as size, color, or position. The color scheme of a chart significantly impacts user perception of data. A harmonious and aesthetically pleasing color scheme helps users fully and systematically understand the data content. Conversely, an inharmonious color scheme can hinder user perception of data and even mislead users, creating an illusion. Therefore, it is important to prioritize color matching and establish a correlation between color and the importance of data content.
[0004] Current research focuses on automated color matching and optimization of visualization charts for categorical data. The main charts include scatter plots, maps, pie charts, and bar charts. For color matching optimization of scatter plots, the distance and color difference between points in the scatter plot are mainly considered. An objective function for measuring class discrimination is defined, and the average class ratio of the two nearest neighbors of each point in the target class is used to calculate the characteristics of each point. The color assignment is optimized in an iterative manner. There are two main methods for automated color matching of maps, pie charts, and bar charts. First, a graph data structure is used to model the visualization chart, and then a graph matching algorithm is used to assign colors. Finally, the color assignment results are optimized and evaluated. Second, a genetic algorithm is used to optimize the palette colors, and then the geometric relationship between the data and the visualization results is considered to optimize the palette color to data assignment scheme.
[0005] Current related research has the following problems: First, there is a lack of methods for automatically matching and optimizing the colors of visualization charts of all data types; second, methods based on graph data structures usually focus on the perception of color, and the color harmony of the visualization charts they generate is poor. In addition, when the graph structure is relatively complex, the graph matching-based methods are extremely complex; third, because the initialization population of the genetic algorithm is random, there is instability when optimizing the palette color; therefore, there is an urgent need for a method to automatically optimize the color of data visualization charts to solve the above problems. Summary of the Invention
[0006] In view of the above-mentioned technical deficiencies, the purpose of the present invention is to provide a method for automatically optimizing the colors of data visualization charts to solve the problems raised in the background technology.
[0007] In order to solve the above technical problems, the present invention adopts the following technical solutions:
[0008] The present invention provides a method for automatically optimizing the color of a data visualization chart, comprising the following steps:
[0009] Step 1: Select a color palette;
[0010] Step 2: Pre-optimize the palette colors. Usually, the number of palette colors is greater than the number of colors actually required. Using a graph matching algorithm or a genetic algorithm to assign colors will increase the complexity of the algorithm. In addition, in order to avoid the colors in the chart being too similar, which would affect the perception and harmony, the number and color of the palette need to be pre-processed.
[0011] Step 3: While Step 2 ensures the perceptual and harmonious color palette, this step considers the geometric correspondence between the data and the final visualization results to optimize the palette color distribution. This involves finding the optimal mapping between data categories and colors, ensuring that different data have different colors and that the overall color perception and harmony of the data visualization chart are maintained. This step defines the target equation for optimizing the palette color distribution.
[0012] Step 4: Use genetic algorithm to optimize the palette color distribution effect.
[0013] Preferably, in step 1, for categorical data, a discrete palette in the Colorgorical visualization tool is selected, and for numerical data, a continuous palette in the ColorBuilder visualization tool is selected, and the number of colors in the initial palette is twice the number of categories of the categorical data or the number of numerical data.
[0014] Preferably, in the step two, if the dominant color is blue, the user is more inclined to achieve harmonious color by adjusting the consistency, if the dominant color is red, the user is more inclined to achieve harmonious color by adjusting the complementarity;
[0015] Let C = {C1,...C 2n} be a color palette with 2n colors, calculate the sum of the red and blue components of the RGB values of the 2n colors respectively. Define case S1, the sum of the blue components is greater than or equal to the sum of the red components, define the consistency color difference ΔE1, using the CIEDE2000 color difference formula; define case 2, the sum of the blue components is less than the sum of the red components, define the complementarity color difference ΔE2, let the RGB value of color C1 be (R1, G1, B1), and the RGB value of color C2 be (R2, G2, B2), ΔE2 = (Max(B1, B2) - Min(B1, B2)) / (B1 + B2);
[0016] Then, let C = {C1,...C 2n} be a color palette with 2n colors, |C| = 2n, and the number of palette colors expected to be obtained is n, defined as R = {R1,...,R n}, R is a subset of C; when |R|! = n, calculate the color difference ΔE of each two colors in R, if it is case S1, ΔE is ΔE1, if it is case S2, ΔE is ΔE2; first, sort according to the smallest color difference, if the smallest color difference is the same, then sort according to the second smallest color difference, and so on; after sorting, delete the first color in R, which has the smallest difference with other colors; until |R| = n, R is obtained.
[0017] Preferably, in the step three, first, define O(R x ,R y ) to calculate the harmony degree of two adjacent color blocks as follows, H Δxy , C Δxy and L Δxy correspond to the hue difference, saturation difference and brightness difference in CIELAB space respectively:
[0018] O(R x ,R y ) = 0.2O ΔH + 0.3O ΔC + O ΔL + O Hsum + O Csum + O Lsum ;
[0019] O ΔH = -0.6tanh(-1.3 + 0.03H Δxy );
[0020] O ΔC =-0.8tanh(-0.6+0.06C Δxy )
[0021] O ΔL =0.3tanh(-0.6+0.06L Δxy )
[0022] O Hsum =0.5+0.3tanh[-3+0.01(H x +H y )]
[0023] O Csum =0.4+0.7tanh[5.1+0.022(C x +C y )]
[0024] O Lsum =0.6+0.3tanh[-2.1+0.03(L x +L y )]
[0025] Then, define Z(R x ,R y ) Calculate the perceived difference between two adjacent color blocks as follows, ΔE is the CIEDE2000 color difference formula, s x and s y They are color blocks R x and R y The area size, and the x and s y The areas of all color blocks in the visualization chart are converted into percentages:
[0026] Z(R x ,R y )=ΔE(R x ,R y )*(s x +s y )
[0027] Then, define D={D1,...,D n} is a label with m categories of data, R={R1,...,R n For a palette with n colors, establish an injective function τ:D→R to assign a color to each data in D, that is, τ(D i )=R j ,i∈[1,n]∨j∈[1,n]. Define G i =[D x ,...],i∈[1,n],G iFor D i A collection of adjacent color blocks;
[0028] Finally, the objective equation for optimizing the palette color assignment effect is defined as follows, E H Measure the harmony of the color distribution scheme, E D Measures the degree of perceptual difference between color distribution schemes, E L Measures the brightness difference between the current color and the background color;
[0029]
[0030]
[0031]
[0032] τ(A i )=C x ,τ(A k )=C y
[0033] E L (A i ,τ)=s i L(C x ,C b ), C b Is the background color.
[0034] Preferably, the step 4 further includes the following steps:
[0035] (1) The chromosome encoding is selected as real number encoding, and different chromosomes represent different palette color allocation schemes;
[0036] (2) Randomly generate N feasible solutions, i.e., the first generation of chromosomes, where N is the population size of chromosomes;
[0037] (3) Using the fitness function to calculate the fitness of each chromosome, determine whether the chromosome group meets the termination condition at this time, and terminate the calculation if it does;
[0038] (4) Define formula 4.1 as follows: The probability of chromosome i being selected = the fitness of chromosome i / the sum of the fitness of all chromosomes. Based on the fitness and formula 4.1, calculate the probability p of each chromosome being selected in the next evolution. m ;
[0039] (5) Perform replication. From the current chromosome population consisting of N chromosomes, the probability p of each chromosome being selected can be calculated according to step (4). m, the chromosomes are selected, and each selection may repeatedly select a chromosome, from which M chromosomes are selected as part of the next generation chromosome group (M <N);
[0040] (6) Within the M chromosome group obtained in step (5), with a crossover probability p of 0.6 x Perform a crossover operation to generate NM chromosomes, and then perform a mutation operation on the NM chromosomes generated after the crossover, with a mutation probability p y =0.07. Since the number of palette colors is processed in step 2, the number of data categories is consistent with the number of palette colors. All colors will appear in the color allocation scheme. It is only necessary to randomly exchange the genes at two positions on the chromosome. The mutated NM chromosomes and the M chromosomes generated by copying in step (5) are merged to form a new chromosome population.
[0041] (7) Return to step (3) and check whether the newly generated chromosome population meets the termination condition. If so, the calculation is terminated; if not, the next round of iteration is performed.
[0042] Preferably, the crossover operation is performed by using a roulette wheel algorithm to select parent chromosomes from the M chromosomes, and using a crossover probability p of 0.6 for the selected parents. x Determine whether to crossover, randomly select crossover positions for the crossover parents, exchange genes with each other, and produce new individuals;
[0043] Roulette algorithm: Among M chromosomes, each chromosome corresponds to a fitness value and a probability p of being selected in the next evolution m , and M chromosomes may be the same, calculate the cumulative probability of each individual chromosome, that is, merge the same chromosomes, and then regenerate M chromosomes according to the current probability distribution, and the probability of selection is based on the cumulative probability;
[0044] The specific steps of the mutation step are as follows: perform each bit unit on the binary system with probability p y Change a gene in the string.
[0045] The beneficial effects of the present invention are: the scheme of the present invention proposes an automatic color matching and optimization scheme for visualization charts of all data types, while the current known research only provides automatic color matching and optimization schemes for some visualization charts of classified data; then, because the initialization population of the genetic algorithm is random, there is instability when optimizing the palette color, and harmonious colors can be obtained from two perspectives when the main colors are different, so the present invention designs a new algorithm for optimizing the color of the palette; finally, because the method based on graph data structure usually focuses on the perception of color, the color harmony of the visualization chart generated by it is poor, and when the graph structure is relatively complex, the method based on graph matching has extremely high complexity, so the present invention selects a genetic algorithm to optimize the palette color allocation scheme, the complexity of the algorithm is lower than that of the method based on graph matching, and when the graph structure is relatively complex, it will not affect the scheme proposed by the present invention; the purpose of the present invention is to provide a method for automatically optimizing the color of data visualization charts, which is used to automatically match the colors of visualization charts of all data types, and ensure the perception and harmony of the colors of visualization charts with the lowest possible complexity. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0047] Figure 1 A flowchart of a method for automatically optimizing the colors of data visualization charts provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0048] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present invention.
[0049] In the description of the present invention, it should be understood that the terms "upper", "lower", "front", "back", "left", "right", "top", "bottom", "inside", "outside", etc., indicating directions or positional relationships, are based on the directions or positional relationships shown in the accompanying drawings, and are only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific direction, be constructed and operated in a specific direction, and therefore should not be understood as limiting the present invention.
[0050] Example:
[0051] like Figure 1 As shown, the present invention provides a method for automatically optimizing the color of a data visualization chart, comprising the following steps:
[0052] Step 1: Select a color palette;
[0053] For categorical data, select the discrete palette in the Colorgorical visualization tool. For numerical data, select the continuous palette in the ColorBuilder visualization tool. The number of colors in the initial palette should be twice the number of categories in the categorical data or the number of numerical data.
[0054] Step 2: Pre-optimize the palette colors. Usually, the number of palette colors is greater than the number of colors actually required. Using a graph matching algorithm or a genetic algorithm to assign colors will increase the complexity of the algorithm. In addition, in order to avoid the colors in the chart being too similar, which would affect the perception and harmony, the number and color of the palette need to be pre-processed.
[0055] First, if the dominant color is blue, users are more inclined to achieve harmonious colors by adjusting consistency. If the dominant color is red, users are more inclined to achieve harmonious colors by adjusting complementarity. Define C = {C1, ...C 2n Let} be a palette with 2n colors. Calculate the sum of the red and blue scores in the RGB color values of each of the 2n colors. Define case S1: the sum of the blue scores is greater than or equal to the sum of the red scores. Define the consistent color difference ΔE1 using the CIEDE2000 color difference formula. Define case 2: the sum of the blue scores is less than the sum of the red scores. Define the complementary color difference ΔE2. Suppose the RGB values of color C1 are (R1, G1, B1) and the RGB values of color C2 are (R2, G2, B2), and ΔE2 = (Max(B1, B2) - Min(B1, B2)) / (B1 + B2).
[0056] Then, define C={C1,...C 2n} is a palette with 2n colors, |C|=2n, the expected number of palette colors is n, defined as R={R1,...,Rn}, R is a subset of C. When |R|! = n, calculate the color difference ΔE between each two colors in R. If it is case S1, ΔE is ΔE1, and if it is case S2, ΔE is ΔE2. First, sort by the smallest color difference. If the smallest color difference is the same, sort by the second smallest color difference, and so on. After sorting, delete the first color in R, which has the smallest difference with the other colors. This is done until |R| = n, and R is obtained.
[0057] Step 3: While Step 2 ensures the perceptual and harmonious color palette, this step considers the geometric correspondence between the data and the final visualization results to optimize the palette color distribution. This involves finding the optimal mapping between data categories and colors, ensuring that different data have different colors and that the overall color perception and harmony of the data visualization chart are maintained. This step defines the target equation for optimizing the palette color distribution.
[0058] First, define O(R x ,R y ) Calculate the harmony between two adjacent color blocks as follows, H Δxy , C Δxy and L Δxy These correspond to hue differences, saturation differences, and brightness differences in the CIELAB space:
[0059] O(R x ,R y )=0.2O ΔH +0.3O ΔC +O ΔL +O Hsum +O Csum +O Lsum ;
[0060] O ΔH =-0.6tanh(-1.3+0.03H Δxy )
[0061] O ΔC =-0.8tanh(-0.6+0.06C Δxy )
[0062] O ΔL =0.3tanh(-0.6+0.06L Δxy )
[0063] O Hsum =0.5+0.3tanh[-3+0.01(H x +H y )]
[0064] O Csum=0.4+0.7tanh[5.1+0.022(C x +C y )]
[0065] O Lsum =0.6+0.3tanh[-2.1+0.03(L x +L y )]
[0066] Then, define Z(R x ,R y ) Calculate the perceived difference between two adjacent color blocks as follows, ΔE is the CIEDE2000 color difference formula, s x and s y They are color blocks R x and R y The area size, and the x and s y The areas of all color blocks in the visualization chart are converted into percentages:
[0067] Z(R x ,R y )=ΔE(R x ,R y )*(s x +s y )
[0068] Then, define D={D1,...,D n} is a label with m categories of data, R={R1,...,R n For a palette with n colors, establish an injective function τ:D→R to assign a color to each data in D, that is, τ(D i )=R j ,i∈[1,n]∨j∈[1,n]. Define G i =[D x ,...],i∈[1,n],G i For D i A collection of adjacent color blocks.
[0069] Finally, the objective equation for optimizing the palette color assignment effect is defined as follows, E H Measure the harmony of the color distribution scheme, E D Measures the degree of perceptual difference between color distribution schemes, E L A measure of the brightness difference between the current color and the background color.
[0070]
[0071]
[0072]
[0073] τ(A i )=C x ,τ(A k )=C y
[0074] E L (A i ,τ)=s i L(C x ,C b ), C b Is the background color.
[0075] Step 4: Use genetic algorithm to optimize the palette color distribution effect, which requires the following steps:
[0076] (1) The chromosome encoding is selected as real number encoding, and different chromosomes represent different palette color allocation schemes;
[0077] (2) Randomly generate N feasible solutions, i.e., the first generation of chromosomes, where N is the population size of chromosomes;
[0078] (3) Using the fitness function to calculate the fitness of each chromosome, determine whether the chromosome group meets the termination condition at this time, and terminate the calculation if it does;
[0079] (4) Define formula 4.1 as follows: The probability of chromosome i being selected = the fitness of chromosome i / the sum of the fitness of all chromosomes. Based on the fitness and formula 4.1, calculate the probability p of each chromosome being selected in the next evolution. m ;
[0080] (5) Perform replication. From the current chromosome population consisting of N chromosomes, the probability p of each chromosome being selected can be calculated according to step (4). m , the chromosomes are selected, and each selection may repeatedly select a chromosome, from which M chromosomes are selected as part of the next generation chromosome group (M <N);
[0081] (6) Within the M chromosome group obtained in step (5), with a crossover probability p of 0.6 x Perform a crossover operation to generate NM chromosomes, and then perform a mutation operation on the NM chromosomes generated after the crossover, with a mutation probability p y=0.07. Since the number of palette colors is processed in step 2, the number of data categories is consistent with the number of palette colors. All colors will appear in the color allocation scheme. It is only necessary to randomly exchange the genes at two positions on the chromosome. The mutated NM chromosomes and the M chromosomes generated by copying in step (5) are merged to form a new chromosome population.
[0082] (7) Return to step (3) and check whether the newly generated chromosome population meets the termination condition. If so, the calculation is terminated; if not, the next round of iteration is performed.
[0083] The specific method of crossover operation is: use roulette wheel algorithm to select parent chromosomes among M chromosomes, and use crossover probability p of 0.6 for the selected parents. x Determine whether to crossover, randomly select crossover positions for the crossover parents, exchange genes with each other, and produce new individuals.
[0084] Roulette algorithm: Among M chromosomes, each chromosome corresponds to a fitness value and a probability p of being selected in the next evolution m , and the M chromosomes may be the same, calculate the cumulative probability of each individual chromosome, that is, merge the same chromosomes, and then regenerate M chromosomes according to the current probability distribution, and the probability of selection is based on the cumulative probability.
[0085] The specific steps of the mutation step are as follows: perform each bit unit on the binary system with probability p y Change a gene in the string.
[0086] First, the solution of the present invention proposes an automatic color matching and optimization solution for visualization charts of all data types. Currently known research only provides automatic color matching and optimization solutions for some visualization charts of classified data; then, because the initialization population of the genetic algorithm is random, there is instability when optimizing the palette color, and harmonious colors can be obtained from two perspectives when the main colors are different, so the present invention designs a new algorithm for optimizing the color of the palette; finally, because the methods based on graph data structures usually focus on the perception of color, the color harmony of the visualization charts they generate is poor, and when the graph structure is relatively complex, the methods based on graph matching have extremely high complexity, so the present invention selects a genetic algorithm to optimize the palette color allocation scheme. The complexity of the algorithm is lower than that of the method based on graph matching, and it will not affect the solution proposed by the present invention when the graph structure is relatively complex.
[0087] The purpose of the present invention is to provide a method for automatically optimizing the colors of data visualization charts, which is used to automatically match the colors of visualization charts of all data types, ensuring the perception and harmony of the colors of the visualization charts with the lowest possible complexity.
[0088] Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include these changes and variations.
Claims
1. A method for automatically optimizing the color of a data visualization chart, characterized by: The following steps are involved: Step 1: Select a color palette; Step 2: Define C = {C1,...C 2n } is a color palette with 2n colors. Calculate the sum of the red and blue scores in the RGB color values of the 2n colors respectively. Define case S1, where the sum of the blue scores is greater than or equal to the sum of the red scores. Define the consistency color difference ΔE1 using the CIEDE2000 color difference formula. Define case 2, where the sum of the blue scores is less than the sum of the red scores. Define the complementary color difference ΔE2. Suppose the RGB values of color C1 are (R1, G1, B1) and the RGB values of color C2 are (R2, G2, B2). ΔE2 = (Max(B1, B2) - Min(B1, B2)) / (B1 + B2). Then, define C={C1,...C 2n } is a palette with 2n colors, |C|=2n, the expected number of palette colors is n, defined as R={R1,...,R n }, R is a subset of C; when |R|! = n, calculate the color difference ΔE between each two colors in R. If it is case S1, ΔE is ΔE1, if it is case S2, ΔE is ΔE2; first sort by the smallest color difference, if the smallest color difference is the same, then sort by the second smallest color difference, and so on; after sorting, delete the first color in R, which has the smallest difference with other colors; until |R| = n, we get R; Step 3: First define O(R x ,R y ) Calculate the harmony between two adjacent color blocks as follows, H Δxy , C Δxy and L Δxy These correspond to hue differences, saturation differences, and brightness differences in the CIELAB space: O(R x , R y )=0.2O ΔH +0.3O ΔC +Oh ΔL +Oh Hsum +Oh Csum +Oh Lsum ; O ΔH =-0.6tanh(-1.3+0.03H Δxy ); THE ΔC =-0.8tanh(-0.6+0.06C Δxy ) O ΔL =0.3tanh(-0.6+0.06L Δxy ) O Hsum =0.5+0.3tanh[-3+0.01(H x +H y )] O Csum =0.4+0.7tanh[5.1+0.022(C x +C y )] O Lsum =0.6+0.3tanh[-2.1+0.03(L x +L y )] Then, define Z(R x ,R y ) Calculate the perceived difference between two adjacent color blocks as follows, ΔE is the CIEDE2000 color difference formula, s x and s y They are color blocks R x and R y The area size, and for s x and s y The areas of all color blocks in the visualization chart are converted into percentages: Z(R x ,R y )=ΔE(R x ,R y )*(s x +s y ) Then, define D={D1,...,D n } is a label with m categories of data, R={R1,...,R n For a palette with n colors, establish an injective function τ:D→R to assign a color to each data in D, that is, τ(D i )=R j ,i∈[1,n]∨j∈[1,n];Define G i =[D x ,...],i∈[1,n],G i For D i A collection of adjacent color blocks; Finally, the objective equation for optimizing the palette color assignment effect is defined as follows, E H Measure the harmony of the color distribution scheme, E D Measures the degree of perceptual difference between color distribution schemes, E L Measures the brightness difference between the current color and the background color; τ(A i )=C x ,τ(A k )=C y E L (A i ,τ)=s i L(C x ,C b ), C b is the background color; Step 4: Use genetic algorithm to optimize the palette color distribution effect.
2. The method for automatically optimizing the color of a data visualization chart according to claim 1, characterized in that: In step 1, for categorical data, select the discrete palette in the Colorgorical visualization tool; for numerical data, select the continuous palette in the ColorBuilder visualization tool. The number of colors in the initial palette is twice the number of categories of the categorical data or the number of numerical data.
3. The method for automatically optimizing the color of a data visualization chart according to claim 1, characterized in that: In the step 2, if the main color of the palette is blue, the user is more inclined to achieve harmonious colors by adjusting consistency. If the main color is red, the user is more inclined to achieve harmonious colors by adjusting complementarity.
4. The method for automatically optimizing the color of a data visualization chart according to claim 1, wherein: The step 4 also includes the following steps: (1) The chromosome encoding is selected as real number encoding, and different chromosomes represent different palette color allocation schemes; (2) Randomly generate N feasible solutions, i.e., the first generation of chromosomes, where N is the population size of chromosomes; (3) Using the fitness function to calculate the fitness of each chromosome, determine whether the chromosome group meets the termination condition at this time, and terminate the calculation if it does; (4) Define formula 4.1 as follows: The probability of chromosome i being selected = the fitness of chromosome i / the sum of the fitness of all chromosomes. Based on the fitness and formula 4.1, calculate the probability p of each chromosome being selected in the next evolution. m ; (5) Perform replication. From the current chromosome population consisting of N chromosomes, the probability p of each chromosome being selected can be calculated according to step (4). m , the chromosomes are selected, and each selection may repeatedly select a chromosome, from which M chromosomes are selected as part of the next generation chromosome group (M <N); (6) Within the M chromosome group obtained in step (5), with a crossover probability p of 0.6 x Perform a crossover operation to generate NM chromosomes, and then perform a mutation operation on the NM chromosomes generated after the crossover, with a mutation probability p y =0.
07. Since the number of palette colors is processed in step 2, the number of data categories is consistent with the number of palette colors. All colors will appear in the color allocation scheme. It is only necessary to randomly exchange the genes at two positions on the chromosome. The mutated NM chromosomes and the M chromosomes generated by copying in step (5) are merged to form a new chromosome population. (7) Return to step (3) and check whether the newly generated chromosome population meets the termination condition. If so, the calculation is terminated; if not, the next round of iteration is performed.
5. The method for automatically optimizing the color of a data visualization chart according to claim 4, characterized in that: The specific method of the crossover operation is as follows: the roulette wheel algorithm is used to select the parent chromosomes among the M chromosomes, and the crossover probability p of 0.6 is used for the selected parents. x Determine whether to crossover, randomly select crossover positions for the crossover parents, exchange genes with each other, and produce new individuals; Roulette algorithm: Among M chromosomes, each chromosome corresponds to a fitness value and a probability p of being selected in the next evolution m , and M chromosomes may be the same, calculate the cumulative probability of each individual chromosome, that is, merge the same chromosomes, and then regenerate M chromosomes according to the current probability distribution, and the probability of selection is based on the cumulative probability; The specific steps of the mutation step are as follows: perform each bit unit on the binary system with probability p y Change a gene in the string.