首页 > 解决方案 > ggplot2-不知道如何摆脱交互式绘图上的线条

问题描述

我的情节添加了连接数据点的线,但我只想要没有连接它们的线的数据点。我将如何更改我的代码以使连接点的线消失?下面是我的代码以及插入数据后的图

ucsplot <- ggplot(data1()$dfplot, aes(data1()$ucs,data1()$depth)) +   
    annotate("rect", xmin=0, xmax=3700, ymin=max(data1()$dfplot[,1])+10, ymax=min(data1()$dfplot[,1])-15, fill = "blue", alpha = 0.2)+
    annotate("rect", xmin=3700, xmax=7000, ymin=max(data1()$dfplot[,1])+10, ymax=min(data1()$dfplot[,1])-15, fill = "gray50", alpha = 0.2)+
    annotate("rect", xmin=7000, xmax=15000, ymin=max(data1()$dfplot[,1])+10, ymax=min(data1()$dfplot[,1])-15, fill = "green", alpha = 0.2)+
    annotate("rect", xmin=15000, xmax=35000, ymin=max(data1()$dfplot[,1])+10, ymax=min(data1()$dfplot[,1])-15, fill = "darkorange", alpha = 0.2)+
    annotate("rect", xmin=35000, xmax=475000, ymin=max(data1()$dfplot[,1])+10, ymax=min(data1()$dfplot[,1])-15, fill = "red", alpha = 0.2) +
    geom_path() + xlab("UCS (psi)") + ylab("Depth (ft)") + labs(title=paste(data1()$well[1], " Depth vs. UCS", sep="")) +
    theme(plot.title = element_text(hjust=0.5)) +
    geom_point_interactive(aes(tooltip = data1()$dfplot[,1], data_id = data1()$dfplot[,1]), size = .75) +
    scale_x_continuous(position = "top", limits = c(0, max(data1()$dfplot[,3]+5000)), expand=c(0,0)) +
    scale_y_reverse(limits = c(max(data1()$dfplot[,1])+10, min(data1()$dfplot[,1])-15 ), expand = c(0, 0)) +
    geom_text(aes(x=1850, y=min(data1()$dfplot[,1]-10), label="Very Weak"), size=3) +
    geom_text(aes(x=5350, y=min(data1()$dfplot[,1]-10), label="Weak"), size=3) +
    geom_text(aes(x=11000, y=min(data1()$dfplot[,1]-10), label="Fair"), size=3) +
    geom_text(aes(x=25000, y=min(data1()$dfplot[,1]-10), label="Strong"), size=3) +
    geom_text(aes(x=41250, y=min(data1()$dfplot[,1]-10), label="Very Strong"), size=3)

ggiraph(code = print(ucsplot), hover_css = "cursor:pointer;fill:red;stroke:red;")

用线条绘制

标签: rggplot2

解决方案


推荐阅读