Creating a half-donut, or parliamentary seating, chart - r

I'd like to create a chart displaying the size of the seats to a parliament, such as the one below, in ggplot2. My main problem is, essentially, how do I turn a donut chart to a half-donut chart (half-circle arc)?
Using the picture above as an example, I don't know where to go from here:
df <- data.frame(Party = c("GUE/NGL", "S&D", "Greens/EFA", "ALDE", "EPP", "ECR", "EFD", "NA"),
Number = c(35, 184, 55, 84, 265, 54, 32, 27))
df$Party <- factor(df$Party)
df$Share <- df$Number / sum(df$Number)
df$ymax <- cumsum(df$Share)
df$ymin <- c(0, head(df$ymax, n= -1))
ggplot(df, aes(fill = Party, ymax = ymax, ymin = ymin, xmax = 2, xmin = 1)) + geom_rect() +
coord_polar(theta = "y") + xlim(c(0, 2))

To get labels etc you can use unit circle properties! I wrote a small function trying to recreate the style of the plot in your question :)
library(ggforce)
parlDiag <- function(Parties, shares, cols = NULL, repr=c("absolute", "proportion")) {
repr = match.arg(repr)
stopifnot(length(Parties) == length(shares))
if (repr == "proportion") {
stopifnot(sum(shares) == 1)
}
if (!is.null(cols)) {
names(cols) <- Parties
}
# arc start/end in rads, last one reset bc rounding errors
cc <- cumsum(c(-pi/2, switch(repr, "absolute" = (shares / sum(shares)) * pi, "proportion" = shares * pi)))
cc[length(cc)] <- pi/2
# get angle of arc midpoints
meanAngles <- colMeans(rbind(cc[2:length(cc)], cc[1:length(cc)-1]))
# unit circle
labelX <- sin(meanAngles)
labelY <- cos(meanAngles)
# prevent bounding box < y=0
labelY <- ifelse(labelY < 0.015, 0.015, labelY)
p <- ggplot() + theme_no_axes() + coord_fixed() +
expand_limits(x = c(-1.3, 1.3), y = c(0, 1.3)) +
theme(panel.border = element_blank()) +
theme(legend.position = "none") +
geom_arc_bar(aes(x0 = 0, y0 = 0, r0 = 0.5, r = 1,
start = cc[1:length(shares)],
end = c(cc[2:length(shares)], pi/2), fill = Parties)) +
switch(is.null(cols)+1, scale_fill_manual(values = cols), NULL) +
# for label and line positions, just scale sin & cos to get in and out of arc
geom_path(aes(x = c(0.9 * labelX, 1.15 * labelX), y = c(0.9 * labelY, 1.15 * labelY),
group = rep(1:length(shares), 2)), colour = "white", size = 2) +
geom_path(aes(x = c(0.9 * labelX, 1.15 * labelX), y = c(0.9 * labelY, 1.15 * labelY),
group = rep(1:length(shares), 2)), size = 1) +
geom_label(aes(x = 1.15 * labelX, y = 1.15 * labelY,
label = switch(repr,
"absolute" = sprintf("%s\n%i", Parties, shares),
"proportion" = sprintf("%s\n%i%%", Parties, round(shares*100)))), fontface = "bold",
label.padding = unit(1, "points")) +
geom_point(aes(x = 0.9 * labelX, y = 0.9 * labelY), colour = "white", size = 2) +
geom_point(aes(x = 0.9 * labelX, y = 0.9 * labelY)) +
geom_text(aes(x = 0, y = 0, label = switch(repr,
"absolute" = (sprintf("Total: %i MPs", sum(shares))),
"proportion" = "")),
fontface = "bold", size = 7)
return(p)
}
bt <- data.frame(parties = c("CDU", "CSU", "SPD", "AfD", "FDP", "Linke", "GrĂ¼ne", "Fraktionslos"),
seats = c(200, 46, 153, 92, 80, 69, 67, 2),
cols = c("black", "blue", "red", "lightblue", "yellow", "purple", "green", "grey"),
stringsAsFactors = FALSE)
parlDiag(bt$parties, bt$seats, cols = bt$cols)

Would this work for you?
ggplot(df, aes(fill = Party, ymax = ymax, ymin = ymin, xmax = 2, xmin = 1)) + geom_rect() +
coord_polar(theta = "y",start=-pi/2) + xlim(c(0, 2)) + ylim(c(0,2))
Basically you just set the ylim to be 2x your max so it only plots it on half. In this case we set the y limits to be from 0 to 2. Then you can offset the start in coord_polar(start=) to get it in proper place.

FWIW, one might also check out the nice ggforce package:
library(tidyverse)
library(ggforce)
library(scales)
df %>%
mutate_at(vars(starts_with("y")), rescale, to=pi*c(-.5,.5), from=0:1) %>%
ggplot +
geom_arc_bar(aes(x0 = 0, y0 = 0, r0 = .5, r = 1, start = ymin, end = ymax, fill=Party)) +
coord_fixed()

Related

Create a special Radial bar chart (race track plot)

I was able to replicate another good answers here to create a basic radial plot, but can anyone give me any clue of others functions/parameters/ideas on how to convert the basic one to something similar to this :
You could get pretty close like this:
df <- data.frame(x = c(10, 12.5, 15), y = c(1:3),
col = c("#fcfbfc", "#fbc3a0", "#ec6f4a"))
library(ggplot2)
ggplot(df, aes(x = 0, xend = x, y = y, yend = y, color = col)) +
geom_hline(yintercept = c(1:3), size = 14, color = "#dfdfdf") +
geom_hline(yintercept = c(1:3), size = 13, color = "#f7f7f7") +
geom_segment(color = "#bf2c23", size = 14, lineend = 'round') +
geom_segment(size = 13, lineend = 'round') +
scale_color_identity() +
geom_point(aes(x = x - 0.03 * y), size = 5, color = "#bf2c23",
shape = 21, fill = 'white') +
geom_point(aes(x = x - 0.03 * y), size = 2, color = "#bf2c23",
shape = 21, fill = 'white') +
scale_y_continuous(limits = c(0, 4)) +
scale_x_continuous(limits = c(0, 20)) +
coord_polar() +
theme_void()
Here's a start. Are there particular aspects you're trying to replicate? This is a fairly customized format.
df <- data.frame(type = c("on", "ia", "n"),
radius = c(2,3,4),
value = c(10,21,22))
library(ggplot2); library(ggforce)
ggplot(df) +
geom_link(aes(x = radius, xend = radius,
y = 0, yend = value),
size = 17, lineend = "round", color = "#bb353c") +
geom_link(aes(x = radius, xend = radius,
y = 0, yend = value, color = type),
size = 16, lineend = "round") +
geom_label(aes(radius, y = 30,
label = paste(type, ": ", value)), hjust = 1.8) +
scale_x_continuous(limits = c(0,4)) +
scale_y_continuous(limits = c(0, 30)) +
scale_color_manual(values = c("on" = "#fff7f2",
"ia" = "#f8b68f",
"n" = "#e4593a")) +
guides(color = "none") +
coord_polar(theta = "y") +
theme_void()

Adding manual colour palette to pie chart

I'm having some troubles with adding manually created color palette to pie chart.
Let's consider my pie chart function - it has the feature following : if value in % is less or equal 4% then this value will be beside pie chart with arrow followed.
pie_chart <- function(vec,col){
df <- as.data.frame(table(vec))
colnames(df)[1] <- 'group'
df$label <- paste0(df$Freq,' (', percent(df$Freq / sum(df$Freq)),')')
df$angle <- ((cumsum(df$Freq) - 0.5 * df$Freq) / sum(df$Freq) * 360) %% 180 - 90
ggplot(df, aes(x = "", y = Freq, fill = group)) +
geom_col(width = 1, show.legend = TRUE) +scale_fill_brewer(palette=col)+
geom_text(
aes(x = ifelse(Freq/sum(Freq) < 0.04, 1.8, 1),
y = sum(Freq) - (cumsum(c(0, Freq[-length(Freq)])) + 0.5 * Freq),
label = label, angle = angle),
position = position_identity(), vjust = 0.25,
size = 4
) + geom_segment(aes(x = 1.6, xend = 1.5,
y = rev(Freq)/2 + c(0, cumsum(rev(Freq))[-length(Freq)]),
yend = after_stat(y),
colour = I(ifelse(rev(Freq) / sum(Freq) < 0.04, "black",
"transparent"))),
arrow = arrow(length = unit(1, "mm"))) +
coord_polar("y", start = 0) +
theme_void()
}
pie_chart(vec=c(rep(1,30),rep(2,40),rep(3,2)),col="Greens",save=0)
Problem I'm facing occurs when trying to change color palette to manually created.
pie_chart <- function(vec){
load(paste0(getwd(),'/my_palette'))
df <- as.data.frame(table(vec))
colnames(df)[1] <- 'group'
df$label <- paste0(df$Freq,' (', percent(df$Freq / sum(df$Freq)),')')
df$angle <- ((cumsum(df$Freq) - 0.5 * df$Freq) / sum(df$Freq) * 360) %% 180 - 90
ggplot(df, aes(x = "", y = Freq, fill = group)) +
geom_col(width = 1, show.legend = TRUE) +scale_color_manual(values = my_palette)+
geom_text(
aes(x = ifelse(Freq/sum(Freq) < 0.04, 1.8, 1),
y = sum(Freq) - (cumsum(c(0, Freq[-length(Freq)])) + 0.5 * Freq),
label = label, angle = angle),
position = position_identity(), vjust = 0.25,
size = 4
) + geom_segment(aes(x = 1.6, xend = 1.5,
y = rev(Freq)/2 + c(0, cumsum(rev(Freq))[-length(Freq)]),
yend = after_stat(y),
colour = I(ifelse(rev(Freq) / sum(Freq) < 0.04, "black",
"transparent"))),
arrow = arrow(length = unit(1, "mm"))) +
coord_polar("y", start = 0) +
theme_void()
}
pie_chart(vec=c(rep(1,30),rep(2,40),rep(3,2)))
And as you can see I got something very strange in output and I'm thinking why.
The thing which is very important to notice is that problem do not occurs without arrows. I think the problem might be there but I'm not so sure about it.Is this a problem connected with my manually created color palette that it's not capable to include arrows ? Or I wrote the code incorrectly ?

annotate ggplot above plot

I tried lately to annotate a graph with boxes above a ggplot.
Here is what I want:
I found a way using grid, but I find it too complicated, and I am quite sure there is a better way to do it, more ggplot2 friendly. Here is the example and my solution:
the data:
y2 <- 350
mesure_pol <- data.frame(x1 = c(1,4,7),
x2 = c(4,7,10),
politiquecat = c(1:3),
politique = c("Phase 1\n","Phase 2\n","Phase 3\n"),
y = c(y2,y2,y2)
)
mesure_pol$x_median <- (mesure_pol$x1 + mesure_pol$x2)/2
colorpal <- viridis::inferno(n=3,direction = -1)
plot
the main plot
p <- ggplot(data = mesure_pol) +
geom_rect(aes(xmin = x1,
xmax = x2,
ymin = 0,
ymax = 300,
fill = as.factor(politiquecat)),
fill = colorpal,
color = "black",
size = 0.3,
alpha = 0.2)+
theme(plot.margin=unit(c(60, 5.5, 5.5, 5.5), "points"))+
coord_cartesian(clip = 'off')
the annotation part
Here is the part I am not happy with:
for (i in 1:dim(mesure_pol)[1]) {
text <- textGrob(label = mesure_pol[i,"politique"], gp = gpar(fontsize=7,fontface="bold"),hjust = 0.5)
rg <- rectGrob(x = text$x, y = text$y, width = stringWidth(text$label) - unit(3,"mm") ,
height = stringHeight(text$label) ,gp = gpar(fill=colorpal[i],alpha = 0.3))
p <- p + annotation_custom(
grob = rg,
ymin = mesure_pol[i,"y"], # Vertical position of the textGrob
ymax = mesure_pol[i,"y"],
xmin = mesure_pol[i,"x_median"], # Note: The grobs are positioned outside the plot area
xmax = mesure_pol[i,"x_median"]) +
annotation_custom(
grob = text,
ymin = mesure_pol[i,"y"], # Vertical position of the textGrob
ymax = mesure_pol[i,"y"],
xmin = mesure_pol[i,"x_median"], # Note: The grobs are positioned outside the plot area
xmax = mesure_pol[i,"x_median"])
}
Is there a simplier/nicer way to obtain similar result ? I tried with annotate, label but without any luck.
An alternative approach to achieve the desired result would be to make the annotations via a second ggplot which could be glued to the main plot via e.g. patchwork.
For the annotation plot I basically used your code for the main plot, added a geom_text layer, get rid of the axix, etc. via theme_void and set the limits in line with main plot. Main difference is that I restrict the y-axis to a 0 to 1 scale. Besides that I shifted the xmin, xmax, ymin and ymax values to add some space around the rectangels (therefore it is important to set the limits).
library(ggplot2)
library(patchwork)
y2 <- 350
mesure_pol <- data.frame(x1 = c(1,4,7),
x2 = c(4,7,10),
politiquecat = c(1:3),
politique = c("Phase 1\n","Phase 2\n","Phase 3\n"),
y = c(y2,y2,y2)
)
mesure_pol$x_median <- (mesure_pol$x1 + mesure_pol$x2)/2
colorpal <- viridis::inferno(n=3,direction = -1)
p <- ggplot(data = mesure_pol) +
geom_rect(aes(xmin = x1,
xmax = x2,
ymin = 0,
ymax = 300,
fill = as.factor(politiquecat)),
fill = colorpal,
color = "black",
size = 0.3,
alpha = 0.2)
ann <- ggplot(data = mesure_pol) +
geom_rect(aes(xmin = x1 + 1,
xmax = x2 - 1,
ymin = 0.2,
ymax = 0.8,
fill = as.factor(politiquecat)),
fill = colorpal,
color = "black",
size = 0.3,
alpha = 0.2) +
geom_text(aes(x = x_median, y = .5, label = politique), vjust = .8, fontface = "bold", color = "black") +
coord_cartesian(xlim = c(1, 10), ylim = c(0, 1)) +
theme_void()
ann / p +
plot_layout(heights = c(1, 4))
By setting a second x-axis and filling the background of the new axis labels with element_markdown from the ggtext package. You may achieve this:
Here is the code:
library(ggtext)
y2 <- 350
mesure_pol <- data.frame(x1 = c(1,4,7),
x2 = c(4,7,10),
politiquecat = c(1:3),
politique = c("Phase 1\n","Phase 2\n","Phase 3\n"),
y = c(y2,y2,y2)
)
mesure_pol$x_median <- (mesure_pol$x1 + mesure_pol$x2)/2
p <- ggplot(data = mesure_pol) +
geom_rect(aes(xmin = x1,
xmax = x2,
ymin = 0,
ymax = 300,
fill = as.factor(politiquecat)),
fill = c("yellow", "red", "black"),
color = "black",
size = 0.3,
alpha = 0.2) +
scale_x_continuous(sec.axis = dup_axis(name = "",
breaks = c(2.5, 5.5, 8.5),
labels = c("Phase 1", "Phase 2", "Phase 3"))) +
theme(plot.margin=unit(c(60, 5.5, 5.5, 5.5), "points"),
axis.ticks.x.top = element_blank(),
axis.text.x.top = element_markdown(face = "bold",
size = 12,
fill = adjustcolor(c("yellow", "red", "black"),
alpha.f = .2)))+
coord_cartesian(clip = 'off')

R ggplot background color boxplot

I have a dataframe like this one:
value = runif(n = 1000)
type = rep(c("a","b","c","d"),250)
type2 = rep(c("a","b"),500)
number = sample(1:4, 1000, replace=TRUE, prob=c(0.25, 0.25, 0.25, 0.25) )
feature = c(rep("small",500),rep("big",500))
allResults <- data.frame(value,type,type2,number,feature)
I'd like to color the background of boxplot by type2 value. If i use fill and col, it's not very clear. I think is more intutitive the background color if is possible.
library("ggplot2")
ggplot(allResults, aes(y=value, x=type)) + geom_boxplot(alpha=.3, aes(fill = type,col=type2)) +
ggtitle("comparison") + facet_grid(feature ~ number) +
theme(legend.position = "bottom",axis.text.x = element_text(angle = 90, hjust = 1)) +
scale_y_continuous(breaks = seq(0, 1, by = 0.05),limits = c(0,1))
This is my result at the moment:
I have seen that is possible to color the backgroud using geom_rect() but I don't understand how to apply.
You could use geom_rect and set your divisions. I originally had a and b as your rects factors, but to match colors in your type fill just set them to a and c.
value = runif(n = 1000)
type = rep(c("a","b","c","d"),250)
type2 = rep(c("a","b"),500)
number = sample(1:4, 1000, replace=TRUE, prob=c(0.25, 0.25, 0.25, 0.25) )
feature = c(rep("small",500),rep("big",500))
nFac <- 4 # define number of factors (types) here
rects <- data.frame(xmin = head(seq <- seq(0.5, nFac + .5, 1), -1),
xmax = tail(seq, -1), rect_type = c("a", "c")) #set your divisions here
allResults <- data.frame(value,type,type2,number,feature, rects)
ggplot(allResults, aes(y=value, x=type)) + geom_boxplot(aes(fill = type, col=type2)) +
geom_rect(aes(xmin = xmin, xmax = xmax, ymin = -Inf, ymax = Inf, fill = rect_type), alpha = 0.009) +
ggtitle("comparison") + facet_grid(feature ~ number) +
theme(legend.position = "bottom",axis.text.x = element_text(angle = 90, hjust = 1)) +
scale_y_continuous(breaks = seq(0, 1, by = 0.05),limits = c(0,1))

buffer areas around lines ggplot2

I would like a chart that as a function of the day in the year, advances from 0 -> 100% in both x and y axes (where each axis is a separate metric). Depending on where the data is relative to the day in the year, I'd like to show whether that's good or bad. Quite simply, I can show it like this:
So the above plot shows we're in a good sitaution because the "tip" (darkest biggest points) are past the 50% mark (and assume we are 50% through the year). But I wanted to add gradient lines around the horizontal and vertical lines to show more nuance. Here's an explanation of the areas (first drawing is the explanation... and the second one is the way I would like to show this in ggplot... with the area fully filled-in.
This is how far I have come in ggplot:
Problems I'm having:
For some reason, the vertical gradient isn't accepting the alpha parameter
I can't assign two different gradients, once I define the gradient, it applies to the vertical and horizontal one.
This looks terrible. Is there a better approach I should be following?
Are Problems 1-2 solvable? If anyone has a better approach not using geom_line, please feel free to suggest approach.
EDIT: As the lines move, so would the gradients, so a static background wouldn't work here.
Code follows:
dff <- data.frame(x = 1:60+(runif(n = 60,-2,2)),
y = 1:60+(runif(n = 60,-2,2)),
z = 1:60)
dfgrad <- data.frame(static = c(rep(50,1000)), line = seq(0,100,length.out=100))
## To see the gradientlines thinner, change the size on the geom_line to like 200
ggplot(dff,aes(x,y)) +
geom_line(data = dfgrad, aes(x=static, y=line, color=line),size=1000,alpha=0.5) +
geom_line(data = dfgrad, aes(x=line, y=static, color=line),size=1000,alpha=0.5) +
scale_colour_gradientn( colours = c( "yellow", "darkgreen","darkred"),
breaks = c( 0, 3, 100),
limits = c( 0,100)) +
geom_hline(yintercept = 50, linetype="dashed") +
geom_vline(xintercept = 50, linetype="dashed") +
geom_point(aes(alpha=dff$z,size= (dff$z))) +
theme(legend.position="none") +
scale_x_continuous(expand = c(0, 0)) + scale_y_continuous(expand = c(0, 0))
FINAL EDIT: The submitted answer is correct, but in order to change the gradient depending on the "today" lines, I had to mess with it a bit more... so I paste it here in case it's useful to anyone:
g1 <- colorRampPalette(c("darkgreen", "darkgreen","red"))(20) %>%
alpha(0.3) %>% matrix(ncol=1) %>% # up and down gradient
rasterGrob(width = 1, height = 1) # full-size (control it by ggplot2)
g2 <- colorRampPalette(c("yellow", "darkgreen","red"))(20) %>%
alpha(0.3) %>% matrix(nrow=1) %>% # left and right gradient
rasterGrob(width = 1, height = 1)
timeOfYear <- 5
maxx <- max(timeOfYear,(100-timeOfYear))
ggplot(dff,aes(x,y)) +
annotation_custom(g1, xmin = timeOfYear-maxx, xmax = timeOfYear+maxx, ymin = timeOfYear-maxx, ymax = timeOfYear+maxx) +
annotation_custom(g2, xmin = timeOfYear-maxx, xmax = timeOfYear+maxx, ymin = timeOfYear-maxx, ymax = timeOfYear+maxx) +
# annotation_custom(g1, xmin = 35, xmax = 65, ymin = -3, ymax = 100) +
# annotation_custom(g2, xmin = -3, xmax = 100, ymin = 35, ymax = 65) +
geom_hline(yintercept = timeOfYear, linetype="dashed") +
geom_vline(xintercept = timeOfYear, linetype="dashed") +
geom_point(aes(alpha=dff$z,size= (dff$z))) +
theme(legend.position="none") +
coord_cartesian(xlim = c(0, 100), ylim = c(0, 100), expand = F)
If I were you, I'd make rectangles by grid package and put them on the graph using annotation_custom(). (your problem.1 is due to overlaying, try alpha=0.05)
Here is my example:
library(ggplot2); library(grid); library(dplyr)
g1 <- colorRampPalette(c("yellow", "darkgreen","darkred"))(20) %>%
alpha(0.5) %>% matrix(ncol = 1) %>% # up and down gradient
rasterGrob(width = 1, height = 1) # full-size (control it by ggplot2)
g2 <- colorRampPalette(c("cyan", "darkgreen","darkblue"))(20) %>%
alpha(0.5) %>% matrix(nrow = 1) %>% # left and right gradient
rasterGrob(width = 1, height = 1)
ggplot(dff,aes(x,y)) +
annotation_custom(g1, xmin = 35, xmax = 65, ymin = -3, ymax = 100) +
annotation_custom(g2, xmin = -3, xmax = 100, ymin = 35, ymax = 65) +
geom_hline(yintercept = 50, linetype="dashed") +
geom_vline(xintercept = 50, linetype="dashed") +
geom_point(aes(alpha=dff$z,size= (dff$z))) +
theme(legend.position="none") +
coord_cartesian(xlim = c(-3, 100), ylim = c(-3, 100), expand = F)
[EDITED]
Here is my approach to keep the same degree of gradient for each timeOfYear (I refered to #Amit Kohli's code) (left graph is concept);
# I added both limits colors as outside colors
# to avoid that graph becomes almost green when timeOfYear is about 50.
g1.2 <- c(rep("yellow", 5), colorRampPalette(c("yellow", "darkgreen","red"))(20), rep("red", 5)) %>%
rev() %>% alpha(0.3) %>% matrix(ncol=1) %>% rasterGrob(width = 1, height = 1)
g2.2 <- c(rep("yellow", 5), colorRampPalette(c("yellow", "darkgreen","red"))(20), rep("red", 5)) %>%
alpha(0.3) %>% matrix(nrow=1) %>% rasterGrob(width = 1, height = 1)
timeOfYear <- 5
ggplot(dff, aes(x, y)) +
annotation_custom(g1.2, timeOfYear - 100, timeOfYear + 100, timeOfYear - 100, timeOfYear + 100) +
annotation_custom(g2.2, timeOfYear - 100, timeOfYear + 100, timeOfYear - 100, timeOfYear + 100) +
geom_hline(yintercept = timeOfYear, linetype="dashed") +
geom_vline(xintercept = timeOfYear, linetype="dashed") +
geom_point(aes(alpha=dff$z,size= (dff$z))) +
theme(legend.position="none") +
coord_cartesian(xlim = c(0, 100), ylim = c(0, 100), expand = F)
If you need, SpaDES::divergentColors() gives you a color-vector with non-symmetric range (probably some packages have a similar function).
library(SpaDES)
timeOfYear <- 5
# ?divergentColors(start.color, end.color, min.value, max.value, mid.value = 0, mid.color = "white")
# It makes a vector of colors (length: max.value - min.value)
# and you can define mid.color's val (i.e., position)
g3 <- divergentColors("yellow", "red", 0, 100, timeOfYear, mid.color = "darkgreen") %>%
rev() %>% alpha(0.3) %>% matrix(ncol = 1) %>% rasterGrob(width = 1, height = 1)
g4 <- divergentColors("yellow", "red", 0, 100, timeOfYear, mid.color = "darkgreen") %>%
alpha(0.3) %>% matrix(nrow = 1) %>% rasterGrob(width = 1, height = 1)
ggplot(dff,aes(x,y)) +
annotation_custom(g3, xmin = 0, xmax = 100, ymin = 0, ymax = 90) +
annotation_custom(g4, xmin = 0, xmax = 90, ymin = 0, ymax = 100) +
geom_hline(yintercept = timeOfYear, linetype="dashed") +
geom_vline(xintercept = timeOfYear, linetype="dashed") +
geom_point(aes(alpha=dff$z,size= (dff$z))) +
theme(legend.position="none") +
coord_cartesian(xlim = c(0, 100), ylim = c(0, 100), expand = F)

Resources