我的数据包含在Excel工作簿中,对于每张工作表(~30 +),我试图创建如下图所示的图表。
我使用Rstudio并导入一张工作表,然后运行代码并保存图表,然后加载下一张工作表并重复。
我的y轴断点并不是在每个单独的图表上显示相同的,在某些" show"标签不会出现,而在其他标签中则出现。
至于传奇中断,每个单独的图表的持续时间不同,我想设置一个统一的图例,但似乎无法设置中断
#cbbPalette <- c("#000000", "#E69F00", "#56B4E9", "#009E73", "#F0E442", "#0072B2", "#D55E00", "#CC79A7")
ggplot(data = Consolidated_Cadiz_prestartGB_p01, aes(x=Fix8, y=AOI, color = Duration)) +
geom_point(alpha=0.5) +
scale_colour_gradientn(colours = rainbow(10) ) +
#scale_colour_manual(values=cbbPalette) + ----- not working
geom_line(color = "grey") +
xlab("Fixation number") +
ylab("Area of interest") +
labs(colour = "Duration (ms)") +
# "show" label isnt appearing on all graphs
scale_y_continuous(breaks = c(1:23, 25),
labels = c("show", "Bow", "Mast", "Boom", "Control lines", "Watch", "Wind indicator", "Sail", "Window", "Tell-tales", "Laser other", "Opponent", "Stern-opponent", "Sea", "Sea2", "Stern-sea", "Stern-sea2", "Non-laser boat", "Sky", "Other", "Coaches boat", "Pin buoy", "Committee boat buoy", "No cursor")) +
#scale_shape_discrete(breaks=c(99, 500, 1000, 1500, 2000),
#labels=c("100", "500", "1000", "1500", "2000+")) + --not working
theme(panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
panel.background = element_blank(),
axis.line = element_line(colour = "black")
)
编辑:
> dput(head(Consolidated_Cadiz_prestartGB_p01))
structure(list(Fix8 = c(1, 2, 3, 4, 5, 6), AOIcode = c("sea2",
"pinBuoy", "sea", "pinBuoy", "noCursor", "controlLines"), Duration = c(100,
198, 563, 1059, 166, 298), AOI = c(15, 22, 14, 22, 25, 5)), .Names = c("Fix8",
"AOIcode", "Duration", "AOI"), row.names = c(NA, -6L), class = c("tbl_df",
"tbl", "data.frame"))
编辑2:Y轴问题已解决,现在需要设置图例