1, 锂离子电池倍率
library(reshape2)
library(ggplot2)
library(grid)
library(RColorBrewer) # 导入相关库
data <- read.csv("beilv.csv") # 读入数据
names(data) <- c("cycle","Annealed Charge","Annealed Discharge","Unannealed Charge","Unannealed Discharge") #数据列重命名
temp01 <- data # 将数据导入临时用数据
temp02 <- melt(temp01,id.vars = "cycle") # 合并数据
ggplot(temp02, aes(x=cycle, y=value)) +
#geom_line(aes(color=variable),lwd=2) + #根据variable的值设置线颜色
geom_point(aes(color=variable),size=4, shape=20) + #根据variable的值设置点颜色
ylim(0,500)+ # x取值范围
xlim(0,70)+ # y取值范围
xlab("Cycle number") + ylab("Capacity (mAh/g)") + #设置x轴和y轴的label
scale_x_continuous(breaks=seq(0, 70, 10))+# 设置x轴的坐标范围和间隔
annotate("text", x=4, y=400, parse=TRUE, size=6,
label="'0.1 A ' * g^{-1}")+ #添加文字
annotate("text", x=16, y=320, parse=TRUE, size=6,
label="'0.2 A ' * g^{-1}")+
annotate("text", x=26, y=290, parse=TRUE, size=6,
label="'0.5 A ' * g^{-1}")+
annotate("text", x=36, y=270, parse=TRUE, size=6,
label="'1 A ' * g^{-1}")+
annotate("text", x=46, y=240, parse=TRUE, size=6,
label="'2 A ' * g^{-1}")+
annotate("text", x=56, y=190, parse=TRUE, size=6,
label="'5 A ' * g^{-1}")+
annotate("text", x=66, y=330, parse=TRUE, size=6,
label="'0.1 A ' * g^{-1}")+
theme(axis.line = element_line(size=1, colour = "black"))+ #设置坐标轴颜色和尺寸
theme(axis.title = element_text(size = 24))+ #设置坐标轴标题颜色和尺寸
theme(axis.text = element_text(size = 24))+ #设置坐标数值的尺寸
theme(legend.title=element_blank())+ #设置图例
theme(legend.position=c(1,1), legend.justification=c(1,1))+ # 调整图例位置
theme(legend.background=element_blank())+ #设置图例的背景颜色
theme(legend.key=element_blank())+
theme(legend.text=element_text(size=16))+
theme(plot.background = element_blank())+
theme(panel.background = element_blank())+
theme(panel.grid.major = element_line(colour = NA))+
theme(panel.grid.minor = element_line(colour = NA))+
theme(panel.border = element_rect(colour = "black",fill = NA, size = 1))+
scale_fill_gradient()
ggsave("beilv.png",width=8, height=6, unit="in", dpi=300) #导出图片
网友评论