Skip to content

Commit

Permalink
Feature ptsize (#27)
Browse files Browse the repository at this point in the history
* Add support for pt.size per #26

* Add documentation for use of pt.size argument per #26

* Update DESCRIPTION

Switch to latest fixest CRAN release

* Reverting to pt.size = 2.5 as default

---------

Co-authored-by: Grant McDermott <grant.mcdermott@gmail.com>
  • Loading branch information
jcvdav and grantmcdermott authored Dec 4, 2023
1 parent b3799fa commit 25c9d15
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
1 change: 0 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.3.9000
URL: http://grantmcdermott.com/ggiplot/
BugReports: https://github.com/grantmcdermott/ggiplot/issues
Remotes: lrberge/fixest
Depends:
ggplot2 (>= 2.2.0)
Imports:
Expand Down
19 changes: 10 additions & 9 deletions R/ggiplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
#' example, `zero.par = list(col = 'orange')`.
#' * `ref.line` and `ref.line.par` for defining or adjusting the vertical
#' reference line. For example, `ref.line.par = list(col = 'red', lty = 4)`.
#' * `pt.pch` and `pt.join` for overriding the default point estimate shapes and joining them, respectively.
#' * `pt.pch`, `pt.size`, and `pt.join` for overriding the default point estimate shapes, size, and joining them, respectively.
#' * `col` for manually defining line, point, and ribbon colours.
#' * `ci_level` for changing the desired confidence level (default = 0.95).
#' Note that multiple levels are allowed, e.g. `ci_level = c(0.8, 0.95)`.
Expand Down Expand Up @@ -321,6 +321,7 @@ ggiplot = function(
dict = if (!is.null(dots[['dict']])) dots[['dict']] else fixest::getFixest_dict()
col = if (!is.null(dots[['col']])) dots[['col']] else NULL
pt.pch = if (!is.null(dots[['pt.pch']])) dots[['pt.pch']] else NULL
pt.size = if (!is.null(dots[['pt.size']])) dots[['pt.size']] else 2.5 # Hard-coded as 2.5 based on dicussion here: https://github.com/grantmcdermott/ggiplot/pull/27#issuecomment-1837850786
pt.join = if (!is.null(dots[['pt.join']])) dots[['pt.join']] else FALSE
## hold off deciding zero line until we have seen the data
# zero = if (!is.null(dots[['zero']])) dots[['zero']] else TRUE
Expand Down Expand Up @@ -454,9 +455,9 @@ ggiplot = function(
names(pt_values) = pt_values_df$group
}

ptsize = 2.5

if (multi_style == "facet") {
ptsize = ptsize - 0.25 * n_fcts
pt.size = pt.size - 0.25 * n_fcts
}

if (multi_style == "none") {
Expand Down Expand Up @@ -619,35 +620,35 @@ ggiplot = function(
if (multi_style == "dodge") {
if (length(ci_level) == 1) {
geom_point(
shape = pt.pch, size = ptsize,
shape = pt.pch, size = pt.size,
position = position_dodge2(width = ci.width, padding = ci.width)
)
} else {
geom_point(
data = ~ subset(.x, ci_level == max(ci_level)),
shape = pt.pch, size = ptsize,
shape = pt.pch, size = pt.size,
position = position_dodge2(width = ci.width, padding = ci.width)
)
}
} else {
geom_point(shape = pt.pch, size = ptsize)
geom_point(shape = pt.pch, size = pt.size)
}
} else {
if (multi_style == "dodge") {
if (length(ci_level) == 1) {
geom_point(
size = ptsize,
size = pt.size,
position = position_dodge2(width = ci.width, padding = ci.width)
)
} else {
geom_point(
data = ~ subset(.x, ci_level == max(ci_level)),
size = ptsize,
size = pt.size,
position = position_dodge2(width = ci.width, padding = ci.width)
)
}
} else {
geom_point(size = ptsize)
geom_point(size = pt.size)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion man/ggiplot.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 25c9d15

Please sign in to comment.