Skip to content

Commit

Permalink
Updated autoplot.dna_barplot help page
Browse files Browse the repository at this point in the history
  • Loading branch information
leifeld committed Jan 8, 2023
1 parent 50397a6 commit 4db14be
Show file tree
Hide file tree
Showing 6 changed files with 153 additions and 36 deletions.
15 changes: 15 additions & 0 deletions rDNA/NAMESPACE
Expand Up @@ -3,6 +3,7 @@
S3method(as.matrix,dna_network_onemode)
S3method(as.matrix,dna_network_twomode)
S3method(autoplot,dna_backbone)
S3method(autoplot,dna_barplot)
S3method(plot,dna_backbone)
S3method(print,dna_backbone)
S3method(print,dna_barplot)
Expand All @@ -21,15 +22,28 @@ export(dna_printDetails)
export(dna_queryCoders)
export(dna_sample)
export(dna_saveConnectionProfile)
importFrom(ggplot2,.pt)
importFrom(ggplot2,aes_string)
importFrom(ggplot2,annotate)
importFrom(ggplot2,autoplot)
importFrom(ggplot2,coord_flip)
importFrom(ggplot2,element_blank)
importFrom(ggplot2,element_text)
importFrom(ggplot2,geom_bar)
importFrom(ggplot2,geom_line)
importFrom(ggplot2,geom_text)
importFrom(ggplot2,ggplot)
importFrom(ggplot2,ggtitle)
importFrom(ggplot2,position_stack)
importFrom(ggplot2,scale_color_identity)
importFrom(ggplot2,scale_fill_identity)
importFrom(ggplot2,scale_x_discrete)
importFrom(ggplot2,theme)
importFrom(ggplot2,theme_bw)
importFrom(ggplot2,theme_minimal)
importFrom(ggplot2,xlab)
importFrom(ggplot2,ylab)
importFrom(grDevices,col2rgb)
importFrom(graphics,lines)
importFrom(rJava,.jarray)
importFrom(rJava,.jcall)
Expand All @@ -43,4 +57,5 @@ importFrom(stats,filter)
importFrom(utils,download.file)
importFrom(utils,packageDescription)
importFrom(utils,packageVersion)
importFrom(utils,stack)
importFrom(utils,unzip)
68 changes: 33 additions & 35 deletions rDNA/R/rDNA.R
Expand Up @@ -10,9 +10,9 @@ dnaEnvironment <- new.env(hash = TRUE, parent = emptyenv())
packageStartupMessage(
'Version: ', desc$Version, '\n',
'Date: ', desc$Date, '\n',
'Author: Philip Leifeld (University of Essex)\n',
'Contributors: Tim Henrichsen (University of Warwick)\n',
' Johannes B. Gruber (Vrije Universiteit Amsterdam),\n',
'Author: Philip Leifeld (University of Essex)\n',
'Contributors: Tim Henrichsen (University of Warwick),\n',
' Johannes B. Gruber (Vrije Universiteit Amsterdam)\n',
'Project home: github.com/leifeld/dna'
)
}
Expand Down Expand Up @@ -1304,6 +1304,7 @@ as.matrix.dna_network_twomode <- as.matrix.dna_network_onemode
#' plot(b)
#'
#' # plot diagnostics with ggplot2
#' library("ggplot2")
#' p <- autoplot(b)
#' p
#'
Expand Down Expand Up @@ -1656,6 +1657,8 @@ autoplot.dna_backbone <- function(object, ..., ma = 500) {
#' }
#'
#' @author Philip Leifeld
#'
#' @seealso \link{print.dna_barplot}, \link{autoplot.dna_barplot}
#'
#' @importFrom rJava .jarray
#' @importFrom rJava .jcall
Expand Down Expand Up @@ -1790,7 +1793,7 @@ dna_barplot <- function(statementType = "DNA Statement",
#'
#' @author Philip Leifeld
#'
#' @seealso \link{dna_barplot}
#' @seealso \link{dna_barplot}, \link{autoplot.dna_barplot}
#' @export
print.dna_barplot <- function(x, trim = 30, attr = TRUE, ...) {
x2 <- x
Expand All @@ -1813,27 +1816,29 @@ print.dna_barplot <- function(x, trim = 30, attr = TRUE, ...) {
#'
#' Plot a barplot generated from \code{\link{dna_barplot}}.
#'
#' This function plots \code{dna_barplot} objects generated by the
#' \code{\link{dna_barplot}} function. It plots agreement and disagreement with
#' DNA statements for different entities such as, e.g., \code{"concept"},
#' \code{"organization"} or \code{"person"}. Colors can be modified before
#' This function plots \code{dna_barplot} objects generated by the
#' \code{\link{dna_barplot}} function. It plots agreement and disagreement with
#' DNA statements for different entities such as \code{"concept"},
#' \code{"organization"}, or \code{"person"}. Colors can be modified before
#' plotting (see examples).
#'
#' @param object A \code{dna_barplot} object.
#' @param lab.pos,lab.neg Names for (dis-)agreement labels.
#' @param lab Should (dis-)agreement labels and title be displayed?
#' @param colors If \code{TRUE}, the \code{Colors} column in the
#' \code{dna_barplot} object will be used to fill the bars. Also accepts
#' character objects matching one of the attribute variables of the
#' \code{dna_barplot} object.
#' @param fontSize Text size in pts.
#' @param colors If \code{TRUE}, the \code{Colors} column in the
#' \code{dna_barplot} object will be used to fill the bars. Also accepts
#' character objects matching one of the attribute variables of the
#' \code{dna_barplot} object.
#' @param fontSize Text size in pt.
#' @param barWidth Thickness of the bars. Bars will touch when set to \code{1}.
#' When set to \code{0.5}, space between two bars is the same as thickness of
#' bars.
#' @param axisWidth Thickness of the x-axis which separates agreement from
#' disagreement.
#' @param truncate Sets the number of characters to which axis labels should be truncated.
#' @param exclude.min Reduces the plot to entities with a minimum frequency of statements.
#' @param truncate Sets the number of characters to which axis labels should be
#' truncated.
#' @param exclude.min Reduces the plot to entities with a minimum frequency of
#' statements.
#'
#' @examples
#' \dontrun{
Expand All @@ -1847,36 +1852,29 @@ print.dna_barplot <- function(x, trim = 30, attr = TRUE, ...) {
#' variable = "concept",
#' qualifier = "agreement")
#'
#' # plot barplot with ggplot2
#' # plot barplot with ggplot2
#' library("ggplot2")
#' autoplot(b)
#'
#' ## Change barplot colors to other colors than specified in color attribute
#'
#' # compute barplot data for organizations
#' # use entity colours (here: colors of organizations as an illustration)
#' b <- dna_barplot(statementType = "DNA Statement",
#' variable = "organization",
#' qualifier = "agreement")
#'
#' # Change color for NGOs to red
#' b$Color[b$Type == "NGO"] <- "red"
#'
#' # Change color for Government to blue
#' b$Color[b$Type == "Government"] <- "blue"
#' autoplot(b, colors = TRUE)
#'
#' # edit the colors before plotting
#' b$Color[b$Type == "NGO"] <- "red" # change NGO color to red
#' b$Color[b$Type == "Government"] <- "blue" # change government color to blue
#' autoplot(b, colors = TRUE)
#'
#' ## Use different color attribute and add colors using ggplot2
#' # use an attribute, such as type, to color the bars
#' autoplot(b, colors = "Type") +
#' scale_colour_manual(values = "black")
#'
#' # compute barplot data for organizations
#' b <- dna_barplot(statementType = "DNA Statement",
#' variable = "organization",
#' qualifier = "agreement")
#'
#' # Plot barplot with Type attribute and add three colors for the three
#' # organization types
#' # replace colors for the three possible actor types with custom colors
#' autoplot(b, colors = "Type") +
#' scale_fill_manual(values = c("red", "blue", "green")) +
# scale_colour_manual(values = "black")
#' scale_fill_manual(values = c("red", "blue", "green")) +
#' scale_colour_manual(values = "black")
#' }
#'
#' @author Johannes B. Gruber, Tim Henrichsen
Expand Down
100 changes: 100 additions & 0 deletions rDNA/man/autoplot.dna_barplot.Rd

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

1 change: 1 addition & 0 deletions rDNA/man/dna_backbone.Rd

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

3 changes: 3 additions & 0 deletions rDNA/man/dna_barplot.Rd

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

2 changes: 1 addition & 1 deletion rDNA/man/print.dna_barplot.Rd

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

0 comments on commit 4db14be

Please sign in to comment.