Skip to content

Commit

Permalink
de-duplicate code for visuals
Browse files Browse the repository at this point in the history
  • Loading branch information
heike committed May 25, 2024
1 parent 9b7f487 commit c14b87f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 32 deletions.
20 changes: 20 additions & 0 deletions app/helper.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,23 @@ identify_bullet <- function(words) {
samelist <- samelist %>% purrr::list_transpose()
make.names(paste(samelist[[1]], collapse="")) # delete all forbidden characters
}


groove_plot <- function(ccdata, grooves) {
ccdata %>%
ggplot(aes(x = x, y = value)) +
theme_bw()+
geom_vline(xintercept = 0, colour = "blue") +
geom_vline(xintercept = grooves[2]-grooves[1], colour = "blue") +
geom_line(linewidth = 1) + # put signal in front
scale_x_continuous(
breaks=c(0,round(as.numeric(grooves[2]-grooves[1]),0),round(seq(min(ccdata$x),max(ccdata$x),by=500),-2))) +
xlab("Position along width of Land [µm]") +
ylab("Surface Height [µm]") +
theme(
axis.text=element_text(size=16),
axis.title=element_text(size=18),
plot.title = element_text(size=22,face="bold")
#axis.text.x = element_text(angle = 90, hjust = 1)
)
}
37 changes: 5 additions & 32 deletions app/server.R
Original file line number Diff line number Diff line change
Expand Up @@ -469,40 +469,13 @@ server <- function(input, output, session) {
CCDataL <- BullCompBulls$ccdata[[GroovePlotLidx]] - GroovesL[1]
CCDataR <- BullCompBulls$ccdata[[GroovePlotRidx]] - GroovesR[1]
output[[paste0("GroovePlotL",idx)]] = renderPlot({
CCDataL %>%
ggplot(aes(x = x, y = value)) +
geom_line() +
theme_bw()+
geom_vline(xintercept = 0, colour = "blue") +
geom_vline(xintercept = GroovesL[2]-GroovesL[1], colour = "blue") +
scale_x_continuous(breaks=c(0,round(as.numeric(GroovesL[2]-GroovesL[1]),0),round(seq(min(CCDataL$x),max(CCDataL$x),by=500),-2))) +
xlab("Position along width of Land [µm]") +
ylab("Surface Height [µm]") +
ggtitle(paste0("Location of the grooves in Land : ",bsldata$land1[odridx[cidx]]))+
theme(
axis.text=element_text(size=16),
axis.title=element_text(size=18),
plot.title = element_text(size=22,face="bold")
# axis.text.x = element_text(angle = 0, hjust = 1)
)
groove_plot(CCDataL, GroovesL) +
ggtitle(sprintf("Land %s groove location",bsldata$land1[odridx[cidx]]))
})
output[[paste0("GroovePlotR",idx)]] = renderPlot({
CCDataR %>%
ggplot(aes(x = x, y = value)) +
geom_line() +
theme_bw()+
geom_vline(xintercept = 0, colour = "blue") +
geom_vline(xintercept = GroovesR[2]-GroovesR[1], colour = "blue") +
scale_x_continuous(breaks=c(0,round(as.numeric(GroovesR[2]-GroovesR[1]),0),round(seq(min(CCDataR$x),max(CCDataR$x),by=500),-2))) +
xlab("Position along width of Land [µm]") +
ylab("Surface Height [µm]") +
ggtitle(paste0("Location of the grooves in Land : ",bsldata$land2[odridx[cidx]]))+
theme(
axis.text=element_text(size=16),
axis.title=element_text(size=18),
plot.title = element_text(size=22,face="bold")
#axis.text.x = element_text(angle = 90, hjust = 1)
)
groove_plot(CCDataR, GroovesR) +
ggtitle(sprintf("Land %s groove location",bsldata$land2[odridx[cidx]]))

})
})
temp_groove <- fluidRow(
Expand Down

0 comments on commit c14b87f

Please sign in to comment.