Skip to content

Commit 199605c

Browse files
committed
version 0.1.2
1 parent 4725637 commit 199605c

File tree

5 files changed

+26
-5
lines changed

5 files changed

+26
-5
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: ggconf
22
Type: Package
33
Title: Simpler Appearance Modification of 'ggplot2'
4-
Version: 0.1
4+
Version: 0.1.2
55
Authors@R: c(person('Yasutaka', 'Tanaka', , '[email protected]', c('aut', 'cre')))
66
Description: A flexible interface for ggplot2::theme(), potentially saving 50% of your typing.
77
License: GPL-3

R/approx_match.R

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@
2020
#'
2121
#' get_analogue("axis.txt", c("axis.text", "axis.text.x", "axis.ticks"))
2222
#' # returns "axis.text" "axis.text.x" "axis.ticks"
23+
#'
24+
#' get_analogue("p.bg", c("plot.background", "panel.background"))
25+
#' # returns "plot.background" as first, and then "panel.background"
26+
#'
2327
#'
2428
#' @importFrom utils adist
2529
#' @importFrom stats na.omit

R/compiler.R

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ ggregex <- list(
2222
charaes = paste0("[a-z]+=('|\\\").*?('|\\\")"),
2323
constaes = "[a-z\\.]+=c\\([0-9\\.,\\)]+", # FIXME adhoc for binw=c(.1, .1)
2424
# Note: ggregex$constaes and t_CONSTAES rules are duplicated
25-
unit = "[0-9\\.,]+\\s*['\"]?(cm|in|inch|inches)['\"]?"
25+
unit = "[0-9\\.,]+\\s*['\"]?(cm|in|inch|inches)['\"]?",
26+
func = "[a-z\\.]+=(arrow|rel|paste|paste0|c)\\([^#]*\\)"
2627
)
2728

2829
Ggplot2Lexer <-
@@ -69,10 +70,10 @@ Ggplot2Lexer <-
6970
ggconf_dbgmsg(" t_COMMA: ", t$value)
7071
t$type <- "COMMA"; return(t)
7172
},
72-
t_0_FUNC = function(re="[a-z\\.]+=(arrow|rel|paste|paste0)\\([^#]*\\)", t) {
73-
# FIXME any function
73+
t_0_FUNC = function(re = "[a-z\\.]+=(arrow|rel|paste|paste0|c)\\([^#]*\\)(\\[[0-9a-zA-Z\\._]+\\])?", t) {
7474
ggconf_dbgmsg(" t_0_FUNC: ", t$value)
75-
t$type <- "0_FUNC"; return(t)
75+
t$type <- "0_FUNC";
76+
return(t)
7677
},
7778
t_1_NAME = function(re="(\\\"|')?[\\.a-zA-Z0-9_\\(\\)\\-][a-zA-Z_0-9\\.,=\\(\\)\\-\\+\\/\\*]*(\\\"|')?(\\s*inches|\\s*inch|\\s*in|\\s*cm)?(\\\"|')?", t) {
7879
if (grepl("theme\\(", t$value)) {

R/ggconf.R

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,10 @@ exec_ggconf <- function(raw_input="",
104104
#' plt.margin(.3, .3, .3, .1, "inch")
105105
#' )
106106
#'
107+
#'
108+
#' ggplot(mtcars) + geom_point(aes(wt, hp, color=cyl)) +
109+
#' theme2(a.txt(family = c("Consolas", "Times")[1]))
110+
#'
107111
#' # all of the following three generate the same plot
108112
#'
109113
#' ggplot(mtcars) + geom_point(aes(wt, hp, color=cyl)) +
@@ -119,6 +123,7 @@ exec_ggconf <- function(raw_input="",
119123
#' theme2(txt(sz=20, f="bold"), aline(sz=2), l.key(c="black"))
120124
#'
121125
#'
126+
#'
122127
#' }
123128
#'
124129
#'

tests/testthat/test-theme2.R

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,17 @@ test_that("theme2", {
8080

8181
ee(theme2(ax.ttl(col=paste0('sky','blue'))),
8282
theme(axis.title = element_text(color=paste0('sky','blue'))))
83+
84+
ee(theme2(a.txt(family=c("consolas", "Times New Roman")[1])),
85+
theme(axis.text = element_text(family="consolas")))
86+
87+
ee(theme2(a.txt(family=c("consolas", "Times New Roman")[2])),
88+
theme(axis.text = element_text(family="Times New Roman")))
89+
90+
my.se_1_ection <<- 1
91+
ee(theme2(a.txt(family=c("consolas", "Times New Roman")[my.se_1_ection])),
92+
theme(axis.text = element_text(family="consolas")))
93+
8394
})
8495

8596
test_that("partial-match", {

0 commit comments

Comments
 (0)