Type: Package
Title: Just Plot for Fun
Version: 0.1.1
Description: Explore the world of R graphics with fun and interesting plot functions! Use make_LED() to create dynamic LED screens, draw interconnected rings with Olympic_rings(), and make festive Chinese couplets with chunlian(). Unleash your creativity and turn data into exciting visuals!
License: GPL-3
Encoding: UTF-8
RoxygenNote: 7.2.3
Depends: R (≥ 4.1.0)
Imports: magrittr, ggplot2, stats, utils, grDevices, reshape2, graphics, pcutils, ggforce, plot3D, magick, gifski, showtext, sysfonts
Suggests: wordcloud2, geomtextpath
NeedsCompilation: no
Packaged: 2024-03-20 11:25:19 UTC; asa
Author: Chen Peng ORCID iD [aut, cre]
Maintainer: Chen Peng <pengchen2001@zju.edu.cn>
Repository: CRAN
Date/Publication: 2024-03-20 12:30:05 UTC

plot4fun: Just Plot for Fun

Description

Explore the world of R graphics with fun and interesting plot functions! Use make_LED() to create dynamic LED screens, draw interconnected rings with Olympic_rings(), and make festive Chinese couplets with chunlian(). Unleash your creativity and turn data into exciting visuals!

Author(s)

Maintainer: Chen Peng pengchen2001@zju.edu.cn (ORCID)


Pipe operator

Description

See magrittr::%>% for details.

Usage

lhs %>% rhs

Arguments

lhs

A value or the magrittr placeholder.

rhs

A function call using the magrittr semantics.

Value

The result of calling rhs(lhs).


Plot a DNA double helix

Description

Plot a DNA double helix

Usage

DNA_plot(
  col_DNA = "#377EB8",
  col_ATCG = c("#7FC97F", "#FB8072", "#FFFFB3", "#A6CEE3"),
  DNA_length = 2
)

Arguments

col_DNA

col_DNA, "#377EB8"

col_ATCG

col_ATCG, c("#7FC97F","#FB8072","#FFFFB3","#A6CEE3")

DNA_length

DNA_length, 2

Value

ggplot

References

https://github.com/SherryDong/create_plot_by_R_base

Examples

DNA_plot()

Plot the Olympic rings

Description

Plot the Olympic rings

Usage

Olympic_rings()

Value

ggplot

Examples

Olympic_rings()

Draw a Chunlian (Spring Festival couplet) using ggplot2

Description

Draw a Chunlian (Spring Festival couplet) using ggplot2

Usage

chunlian(
  words = NULL,
  bg_size = 20,
  bg_shape = 22,
  bg_fill = "red2",
  text_size = 10,
  text_params = list(),
  font_file = NULL,
  download_dir = "plot4fun_temp"
)

Arguments

words

A character vector containing three strings for the three lines of the couplet

bg_size

Size of the points in geom_point, 20

bg_shape

Shape of the points in geom_point (21~25), 22 or 23 are very good.

bg_fill

Fill color of the points in geom_point

text_size

Size of the text in geom_text, 10

text_params

parameters parse to geom_text

font_file

font file, e.g XX.ttf, XX.ttc

download_dir

download_dir for font_file

Value

A ggplot object representing the Chunlian


Plot clock

Description

Plot clock

Usage

clock(
  x = format(Sys.time(), "%H:%M"),
  time_label = as.roman(1:12),
  rotate_text = FALSE,
  text_color = "black",
  bg_color = "white",
  pointer_color = "black"
)

Arguments

x

time, defalut: format(Sys.time(), "%H:%M"), e.g. 12:30

time_label

time_label, default: as.roman(1:12)

rotate_text

rotate_text, FALSE

text_color

text_color, "black"

bg_color

bg_color, "white"

pointer_color

pointer_color, "black"

Value

ggplot

References

https://allancameron.github.io/geomtextpath/

Examples

clock()

convert a character to 01 matrix

Description

convert a character to 01 matrix

Usage

convert_chr_to_matrix(
  char,
  size = 32,
  font_file = NULL,
  picture_dir = tempdir()
)

Arguments

char

a character

size

32

font_file

font_file

picture_dir

where to save the temporary picture

Value

chr_mat

Examples

convert_chr_to_matrix("A")

convert a imgage to 01 matrix

Description

convert a imgage to 01 matrix

Usage

convert_img_to_matrix(image_file, size = 32, breaks = 2)

Arguments

image_file

image_file

size

32

breaks

breaks, default 2

Value

chr_mat


Give you a rose

Description

Give you a rose

Usage

give_you_a_rose(color = "red3")

Arguments

color

"skyblue3"

Value

plot

References

https://mp.weixin.qq.com/s/W-BYPR3UXL120XWpTmN3rA


Life Game Simulation

Description

Life Game Simulation

Usage

life_game(
  save_file = NULL,
  size = 20,
  time = 20,
  fps = 0.75,
  colors = c("black", "green4"),
  ...
)

Arguments

save_file

gif filename

size

size of the world

time

how many times the life game continue.

fps

fps, 0.75

colors

c("green4", "black")

...

add

Value

a gif file

References

https://zhuanlan.zhihu.com/p/136727731

Examples


if (interactive()) life_game()


make a LED screen

Description

make a LED screen

Usage

make_LED(
  chars = "SOS!",
  save_file = NULL,
  LED_width = NULL,
  speed = 32,
  fps = 10,
  colors = c("grey", "red2"),
  LED_height = 32,
  image_scale = 10,
  ...
)

Arguments

chars

chars

save_file

save_file

LED_width

LED_width

speed

pixel speed, default 32

fps

frame per second, 10

colors

c("grey","red2")

LED_height

LED_height, 64

image_scale

image scale, 10

...

add

Value

gif file

Examples


if (interactive()) make_LED("SOS!")


Word cloud plot

Description

Word cloud plot

Usage

my_wordcloud(
  str_vector,
  ignore_words = "Unclassified|uncultured|Ambiguous|Unknown|unknown|metagenome|Unassig",
  topN = 50
)

Arguments

str_vector

string vector

ignore_words

ignore_words

topN

topN, 50

Value

a htmlwidget

Examples


data(otutab, package = "pcutils")
if (requireNamespace("wordcloud2")) {
  my_wordcloud(taxonomy$Genus)
}


Plot a chr_mat

Description

Plot a chr_mat

Usage

## S3 method for class 'chr_mat'
plot(x, colors = c("grey", "red2"), random = FALSE, ...)

Arguments

x

chr_mat object

colors

c("grey","red2")

random

add random

...

add

Value

plot


Plot a github style calendar

Description

Plot a github style calendar

Usage

show_github_calendar(usr = "asa12138", color = NULL, save_file = NULL, ...)

Arguments

usr

github username

color

color, NULL

save_file

save_file, NULL

...

add

Value

a svg file