-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.R
86 lines (70 loc) · 2.6 KB
/
app.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# This is a Shiny web application. You can run the application by clicking
# the 'Run App' button above.
#
# Find out more about building applications with Shiny here:
#
# http://shiny.rstudio.com/
#
library(shiny)
library(colourpicker)
library(ggplot2)
# Define UI for application that draws a histogram
ui <- fluidPage(
# Application title
titlePanel("Phyllotaxis app"),
# Sidebar with a slider input for number of bins
sidebarLayout(
sidebarPanel(
sliderInput("angle",
"Magic angle",
min = 1,
max = 3500,
value = 1871),
sliderInput("points", "Number of points",
min = 100,
max = 3000,
value = 1530),
sliderInput("shape", "Shape",
min = 1,
max = 20,
value = 1),
sliderInput("psize",
"Point size",
min = 1,
max = 200,
value = 155),
numericInput("alpha", "Transparency", min = 0.1,
max = 1,
value = 0.1, 0.1 ),
colourInput("color", "Point color", "white"),
colourInput("background", "Background color", "black")
),
# Show a plot of the generated distribution
mainPanel(
plotOutput("distPlot",height = 700, width = 700)
)
)
)
# Define server logic required to draw a histogram
server <- function(input, output) {
output$distPlot <- renderPlot({
# generate bins based on input$bins from ui.R
angle <- 0.05 * input$angle
# draw the histogram with the specified number of bins
points <- input$points
t <- (1:points) * angle
x <- sin(t)
y <- cos(t)
df <- data.frame(t, x, y)
p <- ggplot(df, aes(x*t, y*t))
p + geom_point(aes(size = t), shape = input$shape, alpha = input$alpha, size = input$psize, color = input$color) +
theme(panel.background = element_rect(fill=input$background),
panel.grid = element_blank(),
axis.title = element_blank(),
axis.text = element_blank(),
axis.ticks = element_blank(),
legend.position = "none")
})
}
# Run the application
shinyApp(ui = ui, server = server)