Skip to content

Commit

Permalink
Fix #8
Browse files Browse the repository at this point in the history
  • Loading branch information
jwijffels committed Jul 17, 2022
1 parent 6597170 commit 6097d2b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: textplot
Type: Package
Title: Text Plots
Version: 0.2.1
Version: 0.2.2
Maintainer: Jan Wijffels <[email protected]>
Authors@R: c(
person('Jan', 'Wijffels', role = c('aut', 'cre', 'cph'), email = '[email protected]'),
Expand Down Expand Up @@ -39,4 +39,4 @@ Suggests:
ggalt,
uwot
VignetteBuilder: knitr
RoxygenNote: 7.1.1
RoxygenNote: 7.1.2
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## CHANGES IN textplot VERSION 0.2.2

- textplot_dependencyparser.default now gains an argument layout, allowing to change the layout to something else than 'linear'

## CHANGES IN textplot VERSION 0.2.1

- Fix bug in textplot_bitermclusters.default (and plot.BTM as it uses textplot_bitermclusters.default) which
Expand Down
4 changes: 3 additions & 1 deletion R/textplot_dependencies.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ textplot_dependencyparser <- function(x, ...){
#' @param edge_color character with the color of the edges between the nodes. Defaults to red.
#' @param size size of the labels in the plot. Defaults to 3.
#' @param base_family character passed on to \code{theme_void} setting the base font family
#' @param layout the type of layout, defaults to 'linear', passed on to \code{\link[ggraph]{ggraph}}
#' @param ... not used yet
#' @return an object of class ggplot
#' @seealso \code{\link[udpipe]{udpipe}}
Expand Down Expand Up @@ -57,6 +58,7 @@ textplot_dependencyparser.default <- function(x,
edge_color = "red",
size = 3,
base_family = "",
layout = "linear",
...){
stopifnot(is.data.frame(x) & all(c("sentence_id", "token_id", "head_token_id", "dep_rel",
"token_id", "token", "upos") %in% colnames(x)))
Expand All @@ -75,7 +77,7 @@ textplot_dependencyparser.default <- function(x,
vertices = x[, c("token_id", "token", "upos")],
directed = TRUE)

ggraph::ggraph(g, layout = "linear") +
ggraph::ggraph(g, layout = layout) +
ggraph::geom_edge_arc(ggplot2::aes(label = dep_rel, vjust = -0.20),
arrow = grid::arrow(length = ggplot2::unit(4, 'mm'), ends = "last", type = "closed"),
end_cap = ggraph::label_rect("wordswordswords"),
Expand Down
3 changes: 3 additions & 0 deletions man/textplot_dependencyparser.Rd

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

0 comments on commit 6097d2b

Please sign in to comment.