我有困難時間在水平上閃閃發亮的情節(ggplots)子集,沒有找到任何示例來幫助... 我想能夠選擇x和y水平與複選框和陰謀選定的水平。閃亮的應用程序無法選擇輸入與ggplots水平
這裏我的數據的一個子集:
Jahr <- c(2014,2015,2020)
RW<- c(0,45,80)
Aus<- c(0,10,80)
Revit<- c(0,10,50)
Point_size<-c(0,30,0)
df3 <- data.frame(Jahr,RW,Aus,Revit,Point_size)
df3_melt <- melt(df3 , id=c("Jahr","Point_size"))
我的UI:
ui <- fluidPage(
headerPanel('Gewaesser'),
sidebarPanel(
checkboxGroupInput("jahr", "Jahr", choices = levels(df3_melt$Jahr)),
checkboxGroupInput("thema", "Thema", choices = levels(df3_melt$variable)),
mainPanel(
plotOutput('plot1')
)
))
和服務器:
server <- function(input, output) {
# selectedData <- reactive({
# all[,levels(df3_melt$variable]
# })
output$plot1 <- renderPlot({
ggplot(df3_melt, aes(x=input$jahr,y=value)) +
geom_line(aes(group=input$thema, color=input$thema),size=0.5,linetype="dashed")+
geom_segment(aes(x = 2014, y = 0, xend = 2015, yend = 45),colour="red",size=0.4)+ #ist
geom_segment(aes(x = 2014, y = 0.5, xend = 2015, yend = 10.5),colour="green",size=0.4)+ #ist
geom_segment(aes(x = 2014, y = 0, xend = 2015, yend = 9.8),colour="blue",size=0.4)+ #ist
coord_cartesian(ylim = c(0,101),xlim=c(2014,2020.5))+
scale_x_continuous(breaks=c(2014,2015, 2016, 2017,2018,2019,2020), labels=c("Baseline","GJ 2015","GJ 2016","GJ 2017","GJ 2018","GJ 2019","Sollwert 2020"),minor_breaks=seq(2015, 2019, by=2))+
geom_segment(aes(x = 2020, y = 0, xend = 2020, yend = 100,alpha=0.5),colour="chartreuse3",size=4)+ #Zielwert
geom_segment(aes(x = 2015, y = 0, xend = 2015, yend = 100),colour="black",size=0.5)+
theme(plot.background = element_blank(),
axis.title.y = element_blank(),
axis.title.x = element_blank(),
panel.border = element_blank(),
panel.background = element_rect(color="white",fill="white"),
axis.text.x = element_text(size=6, angle=45, hjust=1, color="black"),
axis.text.y = element_text(size=6, hjust=1, color="black"),
legend.title = element_blank(),
#legend.key.size=unit(1),
legend.key = element_rect(colour = 'white', fill = 'white', size = 0.5)
)+
guides(fill = guide_legend(label.position = "bottom"))
})
}
幫助將不勝感激,有光澤看起來驚人,但棘手與水平... 謝謝
謝謝,但這並沒有解決問題....仍然有一些維度問題...另外,當使用無功(...) –
請注意,你會把所有'輸入'到'aes_string()'而不是'aes()'。此外,如果您創建一個* minimal *示例,它會很有用:從代碼中刪除與您的問題無關的所有內容。 a)更容易發現問題b)人們不喜歡消化與問題無關的大塊代碼。 – Thierry