1- """
2- Elegant color palette with main and darker versions
3- """
4- const PALETTE = Dict {String, RGB{Float64}} (
5- " Blue" => parse (RGB{Float64}, " #0076C2" ),
6- " Green" => parse (RGB{Float64}, " #4CAF50" ),
7- " Orange" => parse (RGB{Float64}, " #E0A458" ),
8- " Red" => parse (RGB{Float64}, " #D32F2F" ),
9- " Dark Blue" => parse (RGB{Float64}, " #005691" ),
10- " Dark Green" => parse (RGB{Float64}, " #388E3C" ),
11- " Dark Orange" => parse (RGB{Float64}, " #D17C1B" ),
12- " Dark Red" => parse (RGB{Float64}, " #B71C1C" ),
13- " White" => parse (RGB{Float64}, " #FFFFFF" ),
14- " Light Gray" => parse (RGB{Float64}, " #A9A9A9" ),
15- " Dark Gray" => parse (RGB{Float64}, " #696969" )
16- )
17-
18- """
19- get_color(color_name::String, alpha::Float64=1.0)
20-
21- Return the RGBA color for the given color name with specified transparency.
22- """
23- function get_color (color_name:: String , alpha:: Float64 = 1.0 )
24- color = get (PALETTE, color_name, RGB (0 ,0 ,0 )) # Default to black if not found
25- return RGBA (color, alpha)
26- end
27-
28- """
29- get_color_list()
30-
31- Return a vector of colors from the palette.
32- """
33- function get_color_list ()
34- return collect (values (PALETTE))
35- end
36-
37- """
38- visualize_palette()
39-
40- Display the color palette in a plot.
41- """
42- function visualize_palette ()
43- p = plot (
44- legend= false ,
45- showaxis= false ,
46- grid= false ,
47- size= (800 , 80 )
48- )
49-
50- n_colors = length (PALETTE)
51- for (i, (name, color)) in enumerate (PALETTE)
52- # Plot color rectangle
53- x = [(i- 1 )/ n_colors, i/ n_colors]
54- rectangle (w, h, x, y) = Shape (x .+ [0 ,w,w,0 ], y .+ [0 ,0 ,h,h])
55- plot! (p, rectangle (1 / n_colors, 1 , (i- 1 )/ n_colors, 0 ),
56- color= color, fillalpha= 1 )
57-
58- # Add color name
59- annotate! (p, (i- 0.5 )/ n_colors, 0.5 ,
60- text (name, 8 , name == " White" ? :black : :white ))
61- end
62-
63- plot! (p, ylims= (0 ,1 ), xlims= (0 ,1 ))
64- display (p)
65- end
66-
671"""
682 set_plot_style()
693
704Set the default style for plots using LaTeX.
715"""
726function set_plot_style (titel_size= 16 )
73- # plt.style.use('seaborn-whitegrid')
74- # plt.style.use("seaborn-v0_8-whitegrid")
757 rcParams = plt. PyDict (plt. matplotlib." rcParams" )
768 rcParams[" text.usetex" ] = true
779 rcParams[" font.family" ] = " serif"
7810 rcParams[" font.serif" ] = [" Computer Modern Roman" ]
7911 rcParams[" axes.titlesize" ] = titel_size
80- # rcParams["axes.ymargin"] = 0.1
8112 rcParams[" axes.labelsize" ] = 12
8213 rcParams[" axes.linewidth" ] = 1
8314 rcParams[" lines.linewidth" ] = 1
@@ -90,16 +21,3 @@ function set_plot_style(titel_size=16)
9021 rcParams[" pgf.rcfonts" ] = false
9122 rcParams[" figure.figsize" ] = (10 , 6 ) # Default figure size
9223end
93-
94- # """
95- # apply_palette!(p::Plots.Plot, colors::Vector{String})
96-
97- # Apply the color palette to a plot.
98- # """
99- # function apply_palette!(p::Plots.Plot, colors::Vector{String})
100- # for (i, series) in enumerate(p.series_list)
101- # color_name = colors[mod1(i, length(colors))]
102- # series.plotattributes[:linecolor] = get_color(color_name)
103- # end
104- # return p
105- # end
0 commit comments