Package 'plot4fun'

Title: 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!
Authors: Chen Peng [aut, cre]
Maintainer: Chen Peng <[email protected]>
License: GPL-3
Version: 0.1.2
Built: 2025-02-12 04:11:30 UTC
Source: https://github.com/asa12138/plot4fun

Help Index


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


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()

Give you a rose

Description

Give you a rose

Usage

give_you_a_rose(color = "red3", mode = "plot3D")

Arguments

color

"skyblue3"

mode

"plot3D" or "plotly"

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!")

Draw a Moon_cake (Mid- Autumn Festival) using ggplot2

Description

Draw a Moon_cake (Mid- Autumn Festival) using ggplot2

Usage

Moon_cake(cake_color = "orange", cake_fill = "white", stuffing = "五仁")

Arguments

cake_color

Color of the cake, default is "orange"

cake_fill

Fill color of the cake, default is "white"

stuffing

Stuffing of the cake

Value

ggplot


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 the Olympic rings

Description

Plot the Olympic rings

Usage

Olympic_rings()

Value

ggplot

Examples

Olympic_rings()

Plot a pixel image

Description

Plot a pixel image

Usage

pixel_plot(image, size = 32, geom = c("point", "tile"), geom_param = list())

Arguments

image

image path

size

plot size, default: 32

geom

point or tile, default: "point"

geom_param

geom_param, default: list(size = 4)

Value

ggplot


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