p+labs(x = "", y = "") + #scale_x_continuous(breaks = seq(min(data$ID), max(data$ID), by = 1)) + # Add this line scale_y_continuous(expand = c(0,0),limits = c(0,100),breaks = seq(0, 100, by = 20)) + theme_classic() + theme( panel.background = element_rect(fill="white", colour="white", size=0.25), axis.line = element_line(colour="black", size=0.5), axis.title = element_text(size=13, color="black"), axis.text = element_text(size=12, color="black"), legend.position = c(1.29, 0.5), #修改图例位置 legend.text = element_text(size =10), aspect.ratio = 1, # set figure size to 8x6 inches plot.title = element_text(size = 10), # optional, add a title axis.text.x = element_text(angle = 45, hjust = 1), # Rotate x-axis labels by 45 degrees legend.box.spacing = unit(0.01, "cm"), # 设置图例中每个元素的间距 #legend.key.width = 0.5, # 缩小图例颜色方块的宽度 legend.background = element_blank() # 设置图例背景为透明 ) + guides(fill = guide_legend(reverse = TRUE), ncols = 1) 请修改脚本,使图例呈一列显示
时间: 2023-12-04 11:01:37 浏览: 131
SI472X.rar_Si472X_si472x datasheet
修改后的脚本如下:
```
p+labs(x = "", y = "") +
scale_y_continuous(expand = c(0,0),limits = c(0,100),breaks = seq(0, 100, by = 20)) +
theme_classic() +
theme(
panel.background = element_rect(fill="white", colour="white", size=0.25),
axis.line = element_line(colour="black", size=0.5),
axis.title = element_text(size=13, color="black"),
axis.text = element_text(size=12, color="black"),
legend.position = "right", # 修改图例位置为右侧
legend.text = element_text(size =10),
aspect.ratio = 1,
plot.title = element_text(size = 10),
axis.text.x = element_text(angle = 45, hjust = 1),
legend.box.spacing = unit(0.01, "cm"),
legend.background = element_blank()
) +
guides(fill = guide_legend(reverse = TRUE), ncols = 1) # 将图例呈一列显示
```
阅读全文