qscatter: qscatter

View source: R/ggExpress.R

qscatterR Documentation

qscatter

Description

Draw and save a 2D-scatter plot.

Usage

qscatter(
  df_XYcol,
  x = 1,
  y = 2,
  plotname = FixPlotName(substitute(df_XYcol)),
  subtitle = NULL,
  suffix = NULL,
  caption = suffix,
  filename = NULL,
  also.pdf = TRUE,
  save.obj = FALSE,
  col = c(NULL, 3)[1],
  label = NULL,
  repel = TRUE,
  palette_use = c("RdBu", "Dark2", "Set2", "jco", "npg", "aaas", "lancet", "ucscgb",
    "uchicago")[4],
  hide.legend = FALSE,
  ext = MarkdownHelpers::ww.set.file.extension(default = "png", also_pdf = also.pdf),
  logX = FALSE,
  logY = FALSE,
  annotation_logticks_Y = logY,
  annotation_logticks_X = logX,
  xlab = NULL,
  ylab = NULL,
  xlab.angle = 90,
  hline = FALSE,
  vline = FALSE,
  abline = FALSE,
  line.col = "darkgrey",
  line.width = 0.5,
  line.type = "dashed",
  add_contour_plot = FALSE,
  correlation_r2 = FALSE,
  plot = TRUE,
  save = TRUE,
  mdlink = MarkdownHelpers::unless.specified("b.mdlink", def = FALSE),
  grid = "xy",
  w = 7,
  h = w,
  ...
)

Arguments

df_XYcol

Data, as 2 column data frame, where col.1 is X axis.

x

The index or name of the column to be plotted on the X axis. Default: 1.

y

The index or name of the column to be plotted on the Y axis. Default: 2.

plotname

The name of the file and title of the plot.

subtitle

Optional subtitle text added below the title. Default is NULL.

suffix

Optional suffix added to the filename. Default is NULL.

caption

Optional text added to bottom right corner of the plot. Default = suffix

filename

Manually provided filename (optional). Default: parse from plotname,

also.pdf

Save plot in both png and pdf formats.

save.obj

Save the ggplot object to a file. Default: FALSE.

col

Color of the plot.

label

Point labels. Default: NULL.

repel

Repel labels from each other. Default: TRUE.

palette_use

GGpubr Color palette to use.

hide.legend

hide legend

ext

File extension (.pdf / .png).

logX

Make X axis log10-scale.

logY

Make Y axis log10-scale.

annotation_logticks_Y

Logical indicating whether to add annotation logticks on Y-axis. Default follows the value of logY.

annotation_logticks_X

Logical indicating whether to add annotation logticks on X-axis. Default follows the value of logX.

xlab

X-axis label. Default: NULL.

ylab

Y-axis label. Default: NULL.

xlab.angle

Rotate X-axis labels by N degree. Default: 90

hline

Draw a horizontal line on the plot, yintercept or FALSE

vline

Draw a vertical line on the plot, xintercept or FALSE.

abline

Draw a sloped line on the plot. Set to FALSE, or ⁠intercept = abline[1], slope = abline[2]⁠.

line.col

Color of the lines (vline, hline, abline). Default: "darkgrey".

line.width

Width of the line (vline, hline, abline). Default: 0.5.

line.type

Type of the line (vline, hline, abline). Default: "dashed".

add_contour_plot

Add 2D contour plot. See: http://www.sthda.com/english/articles/32-r-graphics-essentials/131-plot-two-continuous-variables-scatter-graph-and-alternatives/#continuous-bivariate-distribution

correlation_r2

Add a correlation value to the plot

plot

Display the plot.

save

Save the plot into a file.

mdlink

Insert a .pdf and a .png image link in the markdown report, set by "path_of_report".

grid

Character indicating the axis to add gridlines. Options are 'x', 'y', or 'xy'. Default is 'y'.

w

Width of the plot.

h

Height of the plot.

...

Pass any other parameter of the corresponding plotting function(most of them should work).

Examples

dfx <- as.data.frame(cbind("AA" = rnorm(500), "BB" = rnorm(500)))
qscatter(dfx, suffix = "2D.gaussian")


vertesy/ggExpress documentation built on Nov. 24, 2024, 10:44 p.m.