1616# ' @export
1717# ' @examples
1818# ' \dontrun{
19- # ' library(ggplot2)
20- # ' ggplot(data, aes(x, y, color = group)) +
21- # ' geom_line() +
22- # ' scale_color_manual(values = athlytics_palette_nature())
19+ # ' ggplot2::ggplot(data, ggplot2::aes(x, y, color = group)) +
20+ # ' ggplot2::geom_line() +
21+ # ' ggplot2::scale_color_manual(values = athlytics_palette_nature())
2322# ' }
2423athlytics_palette_nature <- function () {
2524 c(
@@ -45,10 +44,9 @@ athlytics_palette_nature <- function() {
4544# ' @export
4645# ' @examples
4746# ' \dontrun{
48- # ' library(ggplot2)
49- # ' ggplot(data, aes(x, y, color = group)) +
50- # ' geom_line() +
51- # ' scale_color_manual(values = athlytics_palette_academic())
47+ # ' ggplot2::ggplot(data, ggplot2::aes(x, y, color = group)) +
48+ # ' ggplot2::geom_line() +
49+ # ' ggplot2::scale_color_manual(values = athlytics_palette_academic())
5250# ' }
5351athlytics_palette_academic <- function () {
5452 c(
@@ -73,10 +71,9 @@ athlytics_palette_academic <- function() {
7371# ' @export
7472# ' @examples
7573# ' \dontrun{
76- # ' library(ggplot2)
77- # ' ggplot(data, aes(x, y, fill = category)) +
78- # ' geom_bar(stat = "identity") +
79- # ' scale_fill_manual(values = athlytics_palette_vibrant())
74+ # ' ggplot2::ggplot(data, ggplot2::aes(x, y, fill = category)) +
75+ # ' ggplot2::geom_bar(stat = "identity") +
76+ # ' ggplot2::scale_fill_manual(values = athlytics_palette_vibrant())
8077# ' }
8178athlytics_palette_vibrant <- function () {
8279 c(
@@ -226,62 +223,109 @@ athlytics_colors_ef <- function() {
226223# ' @return A ggplot2 theme object that can be added to plots
227224# '
228225# ' @examples
229- # ' library(ggplot2)
230226# ' # Apply theme to a plot
231- # ' ggplot(mtcars, aes(mpg, wt)) +
232- # ' geom_point() +
227+ # ' ggplot2:: ggplot(mtcars, ggplot2:: aes(mpg, wt)) +
228+ # ' ggplot2:: geom_point() +
233229# ' theme_athlytics()
234230# '
235231# ' @export
236232# ' @import ggplot2
237- theme_athlytics <- function (base_size = 12 , base_family = " " ) {
233+ theme_athlytics <- function (base_size = 13 , base_family = " " ) {
238234 ggplot2 :: theme_minimal(base_size = base_size , base_family = base_family ) +
239235 ggplot2 :: theme(
240- # Plot
236+ # Plot background - clean white
237+ plot.background = ggplot2 :: element_rect(fill = " white" , color = NA ),
238+ panel.background = ggplot2 :: element_rect(fill = " white" , color = NA ),
239+
240+ # Plot titles - modern, bold, left-aligned
241241 plot.title = ggplot2 :: element_text(
242242 face = " bold" ,
243- size = base_size * 1.2 ,
243+ size = base_size * 1.4 ,
244244 hjust = 0 ,
245- margin = ggplot2 :: margin(b = base_size * 0.5 )
245+ color = " #2c3e50" ,
246+ margin = ggplot2 :: margin(b = base_size * 0.8 )
246247 ),
247248 plot.subtitle = ggplot2 :: element_text(
248- size = base_size * 0.9 ,
249- color = " gray40 " ,
249+ size = base_size * 0.95 ,
250+ color = " #7f8c8d " ,
250251 hjust = 0 ,
251- margin = ggplot2 :: margin(b = base_size * 0.5 )
252+ lineheight = 1.2 ,
253+ margin = ggplot2 :: margin(b = base_size * 1 )
252254 ),
253255 plot.caption = ggplot2 :: element_text(
254- size = base_size * 0.8 ,
255- color = " gray50 " ,
256+ size = base_size * 0.75 ,
257+ color = " #95a5a6 " ,
256258 hjust = 1 ,
257- margin = ggplot2 :: margin(t = base_size * 0.5 )
259+ margin = ggplot2 :: margin(t = base_size * 0.8 )
258260 ),
261+ plot.margin = ggplot2 :: margin(t = 15 , r = 15 , b = 15 , l = 15 ),
259262
260- # Axes
261- axis.title = ggplot2 :: element_text(size = base_size , face = " bold" ),
262- axis.text = ggplot2 :: element_text(size = base_size * 0.9 , color = " gray20" ),
263- axis.line = ggplot2 :: element_line(color = " gray40" , linewidth = 0.5 ),
263+ # Axes - clean and minimal
264+ axis.title.x = ggplot2 :: element_text(
265+ size = base_size * 1.05 ,
266+ face = " bold" ,
267+ color = " #34495e" ,
268+ margin = ggplot2 :: margin(t = base_size * 0.6 )
269+ ),
270+ axis.title.y = ggplot2 :: element_text(
271+ size = base_size * 1.05 ,
272+ face = " bold" ,
273+ color = " #34495e" ,
274+ margin = ggplot2 :: margin(r = base_size * 0.6 )
275+ ),
276+ axis.text.x = ggplot2 :: element_text(
277+ size = base_size * 0.9 ,
278+ color = " #7f8c8d" ,
279+ margin = ggplot2 :: margin(t = base_size * 0.3 )
280+ ),
281+ axis.text.y = ggplot2 :: element_text(
282+ size = base_size * 0.9 ,
283+ color = " #7f8c8d" ,
284+ margin = ggplot2 :: margin(r = base_size * 0.3 )
285+ ),
286+ axis.line = ggplot2 :: element_blank(),
287+ axis.ticks = ggplot2 :: element_line(color = " #bdc3c7" , linewidth = 0.3 ),
288+ axis.ticks.length = ggplot2 :: unit(4 , " pt" ),
264289
265- # Legend
290+ # Legend - modern and spacious
266291 legend.position = " bottom" ,
267- legend.title = ggplot2 :: element_text(size = base_size , face = " bold" ),
268- legend.text = ggplot2 :: element_text(size = base_size * 0.9 ),
269- legend.key.size = ggplot2 :: unit(1 , " lines" ),
292+ legend.direction = " horizontal" ,
293+ legend.title = ggplot2 :: element_text(
294+ size = base_size * 0.95 ,
295+ face = " bold" ,
296+ color = " #34495e"
297+ ),
298+ legend.text = ggplot2 :: element_text(
299+ size = base_size * 0.85 ,
300+ color = " #7f8c8d"
301+ ),
302+ legend.key.size = ggplot2 :: unit(1.2 , " lines" ),
303+ legend.key = ggplot2 :: element_blank(),
304+ legend.spacing.x = ggplot2 :: unit(0.5 , " lines" ),
305+ legend.box.spacing = ggplot2 :: unit(0.5 , " lines" ),
306+ legend.margin = ggplot2 :: margin(t = base_size ),
270307
271- # Panel
272- panel.grid.major = ggplot2 :: element_line(color = " gray90" , linewidth = 0.3 ),
308+ # Panel grid - subtle and elegant
309+ panel.grid.major = ggplot2 :: element_line(
310+ color = " #ecf0f1" ,
311+ linewidth = 0.5 ,
312+ linetype = " solid"
313+ ),
273314 panel.grid.minor = ggplot2 :: element_blank(),
274315 panel.border = ggplot2 :: element_blank(),
316+ panel.spacing = ggplot2 :: unit(1.5 , " lines" ),
275317
276- # Strip (for facets)
318+ # Strip (for facets) - clean and modern
277319 strip.text = ggplot2 :: element_text(
278- size = base_size ,
320+ size = base_size * 1.05 ,
279321 face = " bold" ,
280- color = " gray20"
322+ color = " #2c3e50" ,
323+ margin = ggplot2 :: margin(b = base_size * 0.5 , t = base_size * 0.5 )
281324 ),
282325 strip.background = ggplot2 :: element_rect(
283- fill = " gray95" ,
284- color = NA
326+ fill = " #f8f9fa" ,
327+ color = " #dee2e6" ,
328+ linewidth = 0.5
285329 )
286330 )
287331}
@@ -296,10 +340,9 @@ theme_athlytics <- function(base_size = 12, base_family = "") {
296340# ' @return A ggplot2 scale object (scale_color_manual or scale_fill_manual)
297341# '
298342# ' @examples
299- # ' library(ggplot2)
300343# ' # Apply nature palette to plot
301- # ' ggplot(iris, aes(Sepal.Length, Sepal.Width, color = Species)) +
302- # ' geom_point() +
344+ # ' ggplot2:: ggplot(iris, ggplot2:: aes(Sepal.Length, Sepal.Width, color = Species)) +
345+ # ' ggplot2:: geom_point() +
303346# ' scale_athlytics("nature", "color")
304347# '
305348# ' @export
0 commit comments