############
#' A Self-made Median Function
#'
#' This function allows you to calculate the median from a numeric vector.
#' @param x A numeric vector.
#' @keywords median
#' @export
#' @examples
#' median_function(seq(1:10))
#'
LinePlot = function( P1,
LegPos = c(0.75, 0.15),LegBox = "vertical",LegDir="vertical",
LegTextSize = 12,
TH= 0.05,TV= -10, TitleSize = 20,
XtextSize=17, YtextSize=17,
XaThick=1.2, YaThick=1.2, xangle =0,
AxisTitleSize=1, AspRat=1,SubTitSize = 15,
scale_x_c = seq(0, 12, 2),
scale_y_c = seq(0, 12, 2),
OL_Thick = 2.5){
library(ggplot2)
library(graphics)
P2 <- P1 +
geom_line(size = 1) + geom_point(size = 3) +
scale_color_brewer(palette = "Set1")+
geom_point(shape = 12, size = 4, fill = "white")+
scale_x_continuous(breaks = scale_x_c) +
scale_y_continuous(breaks = scale_y_c)+
theme_set(theme_bw())+ # Remove the background
theme(panel.grid.major=element_line(colour=NA))+ # Remove the grid+
theme(axis.text.x = element_text(face="bold", size = XtextSize,angle = xangle, hjust = 1, vjust = .5), # Change the size along the x axis
axis.text.y = element_text(face="bold",size = YtextSize), # Change the size along the y axis
axis.line = element_line(colour = "darkblue", size = 2, linetype = "solid"),
axis.title = element_text(size = rel(AxisTitleSize),face="bold"),
plot.title = element_text(color="black",
size=TitleSize,
face="bold.italic",
hjust = TH,vjust =TV), # margin = margin(t = 0.5, b = -7),
# plot.background = element_rect(fill = 'chartreuse'),
legend.title = element_text(size=20, color = "black", face="bold"),
legend.text = element_text(colour="black", size= LegTextSize,face="bold"),
legend.background = element_rect(fill = alpha("white", 0.5)),
# legend.position = c(0.1, 0.18),
# plot.text = element_text(size = 20),
aspect.ratio=AspRat) + #square plot
theme(axis.line.x = element_line(colour = "black", size = XaThick),
axis.line.y = element_line(colour = "black", size = YaThick))+
theme(legend.position = LegPos , legend.box = LegBox ,legend.direction=LegDir)+ # vertical, horizontal
#theme(legend.position = "top" , legend.direction = LegDir) # vertical, horizontal
theme(strip.text = element_text(size=SubTitSize))+
# Add outline thick
# https://www.cnblogs.com/liujiaxin2018/p/14257944.html
theme(panel.border = element_rect(fill=NA,color="black", size= OL_Thick, linetype="solid"))
return(P2)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.