Skip to contents

Rotate a 2D plot by specified number of degrees

Usage

ggrotate_xy(df, x, y, deg = 45)

Arguments

df

Original dataframe object

x

Name of column containing data plotted on x-axis

y

Name of column containing data plotted on x-axis

deg

Degrees to rotate the plotted data

Value

dataframe with x and y coordinates rotated by specified number of degrees

Note

Mostly using this to rotate plots from Slide-seq spatial transcriptomics data for figure prep.

Examples

library(jmvtools)
jmvtools:::spatial_data |>
    ggplot2::ggplot(ggplot2::aes(x, y, color=factor(cluster))) +
    ggplot2::geom_point() +
    ggplot2::theme_void() +
    ggsci::scale_color_igv()


jmvtools:::spatial_data |>
    ggrotate_xy(x, y, deg=90) |>
    ggplot2::ggplot(ggplot2::aes(x, y, color=factor(cluster))) +
    ggplot2::geom_point() +
    ggplot2::theme_void() +
    ggsci::scale_color_igv()