I have a data frame, df:
df <- structure(list(animal = c("cat", "cat", "cat", "cat", "cat",
"cat", "cat", "cat", "cat", "cat", "cat", "cat", "cat", "cat",
"cat", "cat", "cat", "cat"), id = c("201", "202", "203", "204",
"215", "217", "201", "202", "203", "204", "215", "217", "201",
"202", "203", "204", "215", "217"), tissue = c("tail", "tail",
"tail", "tail", "tail", "tail", "whiskers", "whiskers", "whiskers",
"whiskers", "whiskers", "whiskers", "feet", "feet", "feet", "feet",
"feet", "feet"), value = c(0.5, 2.2, 0, 0.2, 0, 0, 2.8, 19.9,
0, 85, 0, 0, 1.9, 4.1, 0, 0.4, 0, 120)), row.names = c(NA, -18L
), class = "data.frame")
head(df)
animal id tissue value
1 cat 201 tail 0.5
2 cat 202 tail 2.2
3 cat 203 tail 0.0
4 cat 204 tail 0.2
5 cat 215 tail 0.0
6 cat 217 tail 0.0
I have the following plotting function:
p <- ggplot(df, aes_string(x = "id", y = "tissue", fill = "value")) +
geom_tile(color = "white") +
geom_text(aes_string(label = "value"), color = "black", size = 2) +
scale_fill_gradient(
low = "white", high = "red", na.value = "#D0D0D0") +
theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1))
This produces:
I would like the zero values to be plotted in white, but any value above zero to start from an off-red (eg. #FEECE3).
I have tried this:
p <- ggplot(df, aes_string(x = "id", y = "tissue", fill = "value")) +
geom_tile(color = "white") +
geom_text(aes_string(label = "value"), color = "black", size = 2) +
scale_fill_gradient2(
low = "white", mid = "#FEECE3", high = "red", na.value = "#D0D0D0",
midpoint = 1) +
theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1))
But it plots the zeros in the off-red colour.
How can I get just the zeros to plot in white?
You could use scale_fill_gradientn. Set your three colours to white, off-white and red, and set the values at which they reach these colors as 0, the smallest possible non-zero number, and 1.
ggplot(df, aes_string(x = "id", y = "tissue", fill = "value")) +
geom_tile(color = "white") +
geom_text(aes_string(label = "value"), color = "black", size = 2) +
scale_fill_gradientn(colours = c('white', "#FEECE3", 'red'),
values = c(0, .Machine$double.eps, 1)) +
theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1))
Related
I'm trying to show the values of each bar on the plot, so that there are twelve unique values in total across the plot, by or on each bar. Each bar is made up of several stacked variables, and I've made an additional data frame with the sum totals of each bar. But instead they duplicate, when using geom_text. Is there any way to fix this? I've never posted here before, so I don't know how much I should provide of my code (it is extremely messy because I've Frankensteined the code from too many google searches)
The following, Finx, is the basis for my plot.
Finx:
AROID Marktäcke Nutrient Area.km2 Konc.KgM3 Markan.
<chr> <chr> <chr> <dbl> <dbl> <chr>
1 646432-143677 ExtensivVall N 5.36 952. Jordbruk
2 645785-143513 ExtensivVall N 5.86 1040. Jordbruk
3 645157-143904 ExtensivVall N 3.09 549. Jordbruk
4 646432-143677 Grönträda N 2.87 3523. Jordbruk
5 645785-143513 Grönträda N 0.956 1174. Jordbruk
6 645157-143904 Grönträda N 0.100 123. Jordbruk
7 646432-143677 Havre N 1.07 1712. Jordbruk
8 645785-143513 Havre N 0.203 325. Jordbruk
9 645157-143904 Havre N 0.0173 27.7 Jordbruk
10 646432-143677 Höstraps N 1.16 2146. Jordbruk
# … with 69 more rows
Which I work with to present the data.
Finx1 <- Finx %>%
group_by(AROID, Nutrient) %>%
mutate(AROID = recode(AROID, "645157-143904" = "Dis. Utl. Bonderydssjön", "646432-143677" = "Inloppet Tåkern", "645785-143513" = "Nära S:t Åby" )) %>%
ungroup()
Fa <- Finx1 %>%
group_by(AROID, Nutrient, Markan.) %>%
summarize(Konc.KgM3) %>%
summarize_all(sum) %>%
mutate(Tot.kg = Konc.KgM3) %>%
select(-Konc.KgM3)
Fum <- left_join(Finx1, Fa, by = c("AROID", "Nutrient"))
Fum <- Fum[!duplicated(Fum[c('Tot.kg')]), ]
Fum[,'Tot.kg']=round(Fum[,'Tot.kg'], 0)
Fum <- Fum %>%
select(-Markan..x)
Then I make the ggplot,
ggplot(Finx1) +
aes(x = AROID, fill = Marktäcke, y = Konc.KgM3) +
geom_col(alpha = 0.8) +
scale_fill_manual(values = wes_palette("Darjeeling1", type = "continuous", n = 17)) +
theme_light() +
coord_flip() +
geom_text(aes(AROID, Tot.kg, label = Tot.kg, fill = NULL), size = 3, data = Fum2, hjust = 1) +
facet_grid(Markan. ~ Nutrient, scales = "free_x") +
ylab("Total mängd i Kg/år") +
xlab("Delavrinningsområde") +
labs(title='Utlakning av näringsämnen 2007') +
theme(plot.title = element_text(hjust = 0.5, color = "#5A5A5A"), axis.title.x = element_text(color = "#383838"), axis.title.y = element_text(color = "#383838"))
I probably make some mistake here, like showing too little data or something. Idk, but I have no idea what I'm supposed to do.
In principle your ggplot2 code was fine but you messed up the data wrangling, which could be simplifeid without the need of a join:
library(dplyr)
library(ggplot2)
library(wesanderson)
Finx1 <- Finx %>%
mutate(AROID = recode(AROID,
"645157-143904" = "Dis. Utl. Bonderydssjön",
"646432-143677" = "Inloppet Tåkern",
"645785-143513" = "Nära S:t Åby"
))
Fum <- Finx1 %>%
group_by(AROID, Nutrient, Markan.) %>%
summarize(Tot.kg = sum(Konc.KgM3))
ggplot(Finx1) +
aes(x = Konc.KgM3, y = AROID) +
geom_col(aes(fill = Marktäcke), alpha = 0.8) +
geom_text(aes(x = Tot.kg, label = Tot.kg), size = 3, data = Fum, hjust = -.1) +
scale_x_continuous(expand = c(0, 0, 0, 1500)) +
scale_fill_manual(values = wes_palette("Darjeeling1",
type = "continuous", n = 17
)) +
facet_grid(Markan. ~ Nutrient, scales = "free_x") +
theme_light() +
theme(
plot.title = element_text(hjust = 0.5, color = "#5A5A5A"),
axis.title = element_text(color = "#383838")
) +
labs(
x = "Total mängd i Kg/år",
y = "Delavrinningsområde",
title = "Utlakning av näringsämnen 2007"
)
DATA
Finx <- structure(list(AROID = c(
"646432-143677", "645785-143513", "645157-143904",
"646432-143677", "645785-143513", "645157-143904", "646432-143677",
"645785-143513", "645157-143904", "646432-143677"
), Marktäcke = c(
"ExtensivVall",
"ExtensivVall", "ExtensivVall", "Grönträda", "Grönträda",
"Grönträda", "Havre", "Havre", "Havre", "Höstraps"
), Nutrient = c(
"N",
"N", "N", "N", "N", "N", "N", "N", "N", "N"
), Area.km2 = c(
5.36,
5.86, 3.09, 2.87, 0.956, 0.1, 1.07, 0.203, 0.0173, 1.16
), Konc.KgM3 = c(
952,
1040, 549, 3523, 1174, 123, 1712, 325, 27.7, 2146
), Markan. = c(
"Jordbruk",
"Jordbruk", "Jordbruk", "Jordbruk", "Jordbruk", "Jordbruk", "Jordbruk",
"Jordbruk", "Jordbruk", "Jordbruk"
)), class = "data.frame", row.names = c(
"1",
"2", "3", "4", "5", "6", "7", "8", "9", "10"
))
This is my dataframe:
df = structure(list(qCountry = c("AT", "DE", "ES", "FI", "FR", "GR",
"HU", "IR", "IT", "LV", "NL", "POL", "PT", "RO", "SWE", "EU"),
Mean = c(1.34199395770393, 1.37664132688321, 1.29144095341278,
1.42088404868674, 1.45019920318725, 1.29786200194363, 1.24528301886792,
1.26937046004843, 1.38345864661654, 1.39706780696396, 1.38751714677641,
1.30804248861912, 1.28609062170706, 1.2320819112628, 1.32588699080158,
1.33425470556542), Sd = c(0.474520963779525, 0.484711259139164,
0.454549282145671, 0.493859200850428, 0.497678958439859,
0.45742966912063, 0.430377930416405, 0.443767080631815, 0.48638085640142,
0.489439780963027, 0.487350499450418, 0.461801022550429,
0.452051373271304, 0.422281105345888, 0.468859354590332,
0.467003889139754)), row.names = c(NA, -16L), class = c("tbl_df",
"tbl", "data.frame"))
I then plot it as follows:
c5_1 %>%
ggplot(aes(x = reorder(qCountry,-Mean), y = Mean, group = qCountry)) +
geom_point(size = 3.5) +
geom_errorbar(aes(ymin=Mean-Sd, ymax=Mean+Sd)) +
labs(title = "Some Title", subtitle = "Some subtitle",x = "", y="") +
scale_y_continuous(breaks = c(1, 2),
labels = c("Yes", "No"), limits = c(0.8, 2)) +
coord_flip() +
theme_classic()
The issue with this is that I would like "EU" only to be displayed in red, while the rest stays black.
Can anyone help me with that?
Thanks!
You can create a new column with the color name and call scale_color_identity():
df %>%
mutate(color_plot = ifelse(qCountry == "EU", "red", "black")) %>%
ggplot(aes(x = reorder(qCountry,-Mean), y = Mean, group = qCountry,
color = color_plot)) +
geom_point(size = 3.5) +
geom_errorbar(aes(ymin=Mean-Sd, ymax=Mean+Sd)) +
labs(title = "Increasing 1% of your personal tax bill for financing financial support to other EU member states", subtitle = "Natural Disaster",x = "", y="") +
scale_y_continuous(breaks = c(1, 2),
labels = c("Yes", "No"), limits = c(0.8, 2)) +
coord_flip() +
scale_color_identity() +
theme_classic()
Output is:
I am trying to add a vertical centered title to my colorbar legend but it stacks the title on top of the colorbar instead of the the right.
I have tried adding position = "right" but it does not help, i have tried vjust, hjust it does not work either.
The plot it produces:
what I would like:
Code:
ggplot(df, aes(x=img_type, y=metric),show.legend = FALSE) +
geom_point(aes(size = abs_corr, colour=corr))+scale_size(range =c(-0.1,20) )+
scale_colour_gradient2(
low = "#7e1952",
high = "#2f7a9a",
space = "Lab",
na.value = "white",
guide = "colourbar",
aesthetics = "colour",
mid = "white",
limits=c(-1,1), name = "Spearman's Correlation Coefficient"
)+ guides(size = "none")+
theme(legend.key.height = unit(2.5, "cm"))+
guides(fill = guide_colourbar(label.position = "right"))+
theme(legend.title = element_text(size = 12, angle = 90) )
Data:
metric pval corr img_type abs_corr
1 aes 0.0000 0.6820 T2_TSE 0.6820
2 aes 0.0000 0.7365 T2_FLAIR 0.7365
3 aes 0.0003 0.2412 T1_MPR 0.2412
4 aes 0.0000 0.3510 T1_TIRM 0.3510
5 tg 0.0000 0.4434 T2_TSE 0.4434
6 tg 0.0000 0.8093 T2_FLAIR 0.8093
7 tg 0.0000 0.2813 T1_MPR 0.2813
8 tg 0.0000 0.3513 T1_TIRM 0.3513
9 coent 0.0028 -0.2583 T2_TSE 0.2583
10 coent 0.0008 -0.4210 T2_FLAIR 0.4210
Here is a solution, inspired in this SO post.
Note that in the question you have fill = guide_colourbar(.) when it should be colour = guide_colourbar(.).
library(ggplot2)
ggplot(df, aes(x=img_type, y=metric),show.legend = FALSE) +
geom_point(aes(size = abs_corr, colour=corr))+
scale_size(range =c(-0.1,20) )+
scale_colour_gradient2(
low = "#7e1952",
high = "#2f7a9a",
space = "Lab",
na.value = "white",
guide = "colourbar",
aesthetics = "colour",
mid = "white",
limits=c(-1,1), name = "Spearman's Correlation Coefficient"
)+
guides(
size = "none",
colour = guide_colourbar(title.position = "right")
)+
theme(legend.key.height = unit(2.5, "cm"),
legend.title = element_text(size = 12, angle = 90),
legend.title.align = 0.5,
legend.direction = "vertical"
)
Data
df <-
structure(list(metric = c("aes", "aes", "aes", "aes", "tg", "tg",
"tg", "tg", "coent", "coent"), pval = c(0, 0, 3e-04, 0, 0, 0,
0, 0, 0.0028, 8e-04), corr = c(0.682, 0.7365, 0.2412, 0.351,
0.4434, 0.8093, 0.2813, 0.3513, -0.2583, -0.421), img_type = c("T2_TSE",
"T2_FLAIR", "T1_MPR", "T1_TIRM", "T2_TSE", "T2_FLAIR", "T1_MPR",
"T1_TIRM", "T2_TSE", "T2_FLAIR"), abs_corr = c(0.682, 0.7365,
0.2412, 0.351, 0.4434, 0.8093, 0.2813, 0.3513, 0.2583, 0.421)), class = "data.frame", row.names = c("1", "2", "3", "4", "5", "6", "7", "8", "9", "10"))
Hi, I'm trying to make a plot of a survey question with a likert scale using ggplots. I need to help to organize the middle "neutral" values correctly. I have used two data frames, one for the left side "low_col", and one for the right side "high_col", both have the neutral value divided by 2. This is the script I used for the plot, and how the graph looks. I would highly appreciate all the advice to correct the order, and also all the help to add the percentages that I have in both data frames in a column named per. I hope someone can help me. Thanks
ggplot()+ geom_bar(data = high_col, mapping = aes(x=Q6, y=per, fill=col), position = "stack", stat = "identity")+ geom_bar(data= low_col, mapping = aes(x=Q6, y=-per, fill=col), position = "stack", stat = "identity")+ geom_hline(yintercept = 0, color=c("white"))+coord_flip() +scale_fill_identity("", labels = mylevels, breaks=legend.pal, guide="legend") + theme_fivethirtyeight() + theme(plot.title = element_text(size=14, hjust=0.5)) + theme(axis.text.y = element_text(hjust=0)) + theme(legend.position = "bottom")
The structure of the low_col and high_col is as follows:
For high_col:
dput(high_col)
structure(list(Q6 = c("General", "0", "1", "2", "General", "0", "1", "2", "3", "General", "0", "1", "2", "3"), Q75 = c("Ni satisfecho, ni insatisfecho", "Ni satisfecho, ni insatisfecho", "Ni satisfecho, ni insatisfecho", "Ni satisfecho, ni insatisfecho", "Satisfecho", "Satisfecho", "Satisfecho", "Satisfecho", "Satisfecho", "Totalmente satisfecho", "Totalmente satisfecho", "Totalmente satisfecho", "Totalmente satisfecho", "Totalmente satisfecho"), n = c(5, 1, 3, 1, 53, 25, 19, 7, 2, 104, 52, 35, 14, 3), per = c(1.48809523809524, 0.609756097560975, 2.58620689655172, 2.17391304347826, 31.547619047619, 30.4878048780487, 32.7586206896551, 30.4347826086956, 40, 61.9047619047619, 63.4146341463414, 60.3448275862069, 60.8695652173913, 60), col = c("#DFDFDF", "#DFDFDF", "#DFDFDF", "#DFDFDF", "#92C5DE", "#92C5DE", "#92C5DE", "#92C5DE", "#92C5DE", "#0571B0", "#0571B0", "#0571B0", "#0571B0", "#0571B0")), row.names = c(NA, -14L), class = c("tbl_df", "tbl", "data.frame"))
For low_col:
dput(low_col)
structure(list(Q6 = c("General", "0", "General", "0", "1", "2", "General", "0", "1", "2"), Q75 = structure(c(2L, 2L, 3L, 3L, 3L, 3L, 1L, 1L, 1L, 1L), .Label = c("Totalmente insatisfecho", "Insatisfecho", "Ni satisfecho, ni insatisfecho"), class = "factor"), n = c(2, 2, 5, 1, 3, 1, 4, 2, 1, 1), per = c(1.19047619047619, 2.4390243902439, 1.48809523809524, 0.609756097560975, 2.58620689655172, 2.17391304347826, 2.38095238095238, 2.4390243902439, 1.72413793103448, 4.34782608695652), col = c("#F4A582", "#F4A582", "#DFDFDF", "#DFDFDF", "#DFDFDF","#DFDFDF", "#CA0020", "#CA0020", "#CA0020", "#CA0020")), row.names = c(NA, -10L), class = c("tbl_df", "tbl", "data.frame")).
As a reference, I'm trying to follow two blogs where some individuals already did this kind of likert plots. In the first, it uses the color "col" as fill in the geom_bar, however, in my case the order is not working properly. And the result is the graph I've attached.
In the second blog, I used the following script, but I cannot change the colors, nor the order of the legend, as the labels appear in alphabetical order, and the colors are selected by default. Thanks in advance for all the insights, and info.
ggplot()+ geom_bar(data = high_col, aes(x=Q6, y=per, fill=Q75), position = position_stack(reverse = TRUE), stat = "identity") + geom_bar(data= low_col, aes(x=Q6, y=-per, fill=Q75), position = "stack", stat = "identity") +coord_flip() + theme_fivethirtyeight() + theme(plot.title = element_text(size=14, hjust=0.5)) + theme(axis.text.y = element_text(hjust=0)) + theme(legend.position = "bottom") + scale_y_continuous(breaks = seq(-100,100, 5), limits = c(-25, 100)) + scale_color_manual(labels=c("Totalmente insatisfecho", "Insatisfecho", "Ni satisfecho, ni insatisfecho", "Satisfecho", "Totalmente satisfecho"), values=legend.pal, guide="legend")+geom_text(data = pro_labels, mapping = aes(x=Q6, y=left, label=paste(round(left), "%", sep = "")), hjust=2, color="white", size=3, position = "stack")+geom_text(data = pro_labels, mapping = aes(x=Q6, y=center, label=paste(round(center), "%")), hjust=1, color="white", size=3, position = "stack")+geom_text(data = pro_labels, mapping = aes(x=Q6, y=right, label=paste(round(right), "%")), hjust=2, color="white", size=3, position = "stack")+geom_hline(yintercept = 0, color=c("grey")) + scale_colour_manual("", values = legend.pal, guide="legend")
Updated version:
Hi, I have been trying to work this out and with the following code I got the neutral value in the middle, yet the colors do not match.
ggplot()+ geom_bar(data = high_col, aes(x=Q6, y=per, fill=Q75), position = position_stack(reverse = TRUE), stat = "identity") + geom_bar(data= low_col, aes(x=Q6, y=-per, fill=Q75), position = "stack", stat = "identity") +coord_flip() + theme_fivethirtyeight() + theme(plot.title = element_text(size=14, hjust=0.5)) + theme(axis.text.y = element_text(hjust=0)) + theme(legend.position = "bottom") + scale_y_continuous(breaks = seq(-100,100, 5), limits = c(-25, 100))+geom_text(data = pro_labels, mapping = aes(x=Q6, y=left, label=paste(round(left), "%", sep = "")), hjust=2, color="white", size=3, position = "stack")+geom_text(data = pro_labels, mapping = aes(x=Q6, y=center, label=paste(round(center), "%")), hjust=1, color="white", size=3, position = "stack")+geom_text(data = pro_labels, mapping = aes(x=Q6, y=right, label=paste(round(right), "%")), hjust=2, color="white", size=3, position = "stack")+ geom_hline(yintercept = 0, color=c("grey"))+ scale_fill_discrete(labels= c("Totalmente insatisfecho", "Insatisfecho", "Ni satisfecho, ni insatisfecho", "Satisfecho", "Totalmente satisfecho"))
The result is the second graph attached here.
I have a line graph with several lines, in which I want to highlight certain values with a different geom_point shape.
The dput of a similar data to mine is:
structure(list(Iso = structure(1:9, .Label = c("a", "b", "c",
"d", "e", "f", "g", "h", "i"), class = "factor"), z1 = c(342.6,
8.94, 6.91, 3.96, 1.89, 4.38, 1.43, 5.18, 189.1), z2 = c(187.34,
2.8, 8.42, 8.24, 2.36, 2.34, 7.6, 0.5, 136.01)), row.names = c(NA,
-9L), spec = structure(list(cols = list(Iso = structure(list(), class = c("collector_character",
"collector")), z1 = structure(list(), class = c("collector_double",
"collector")), z2 = structure(list(), class = c("collector_double",
"collector"))), default = structure(list(), class = c("collector_guess",
"collector")), skip = 1), class = "col_spec"), class = c("spec_tbl_df",
"tbl_df", "tbl", "data.frame"))
This is the code:
library(readr)
library(ggplot2)
library(RColorBrewer)
y <- read_csv("dummy.csv")
y$Iso <- factor(y$Iso, levels=y$Iso)
##
plot <- ggplot(y,aes(Iso,group=1)) +theme_bw() + ggtitle('') +
theme(plot.title = element_text(hjust = 0.5)) +
geom_point(aes(y=z1, colour='z1'), na.rm=FALSE, size=3, shape=16) +
geom_point(aes(y=z2, colour='z2'), na.rm=FALSE, size=3,shape=16) +
geom_line(aes(y=z1, colour='z1'), na.rm=FALSE, linetype=1,size=1) +
geom_line(aes(y=z2, colour='z2'), na.rm=FALSE,linetype=3, size=2) +
xlab('') +ylab('ZZ/CI') + scale_y_log10(limits=c(0.1,2000), breaks=c(1e-1,1,1e1,1e2,1e3))
##
plot + theme(axis.text.x = element_text(angle = 90, vjust = 0.5,size=19, face='bold'),
axis.text.y = element_text(size=12),
axis.title.y = element_text(size=15)) +
scale_colour_manual(name='',breaks=c('z1','z2'),values= c('brown','wheat'),labels= c('z1','z2')) +
guides(colour = guide_legend(override.aes = list (size = c(.75,.75),linetype=c(1,3),shape=c(16,16))))
I use the guide for every cosmetic element in order to make the legend more legible.
The data
# A tibble: 9 x 3
Iso z1 z2
<fct> <dbl> <dbl>
1 a 343.6 187.34
2 b 8.94 2.8
3 c 6.91 8.42
4 d 3.96 8.24
5 e 1.89 2.36
6 f 4.38 2.34
7 g 1.43 7.6
8 h 5.18 0.5
9 i 189.1 136.01
For example, in the case of these data, I want to change the shape from 16 to 13, in z1 for '342.6','1.43', and '5.18', and in z2 for '187.34,'2.36','7.6' and '0.5'.
How can I proceed?
Thank you for your time.
I think you should consider reformatting your data to long format, as it saves a lot of duplication. Secondly, you need to specify a new column in your data, which you map to shape. If there is no pattern like any value larger than 100 you need to cherry-pick the values you want to highlight by hand.
The following code should do what you want:
library(tidyverse)
y <- structure(list(Iso = structure(1:9, .Label = c("a", "b", "c",
"d", "e", "f", "g", "h", "i"),
class = "factor"),
z1 = c(342.6, 8.94, 6.91, 3.96, 1.89, 4.38, 1.43, 5.18, 189.1),
z2 = c(187.34, 2.8, 8.42, 8.24, 2.36, 2.34, 7.6, 0.5, 136.01)),
row.names = c(NA, -9L),
class = c("data.frame"))
## transform to long format
y.long <- y %>% gather(type, value, -Iso)
## add a new column which 'marks' the special rows
## NOTE: since we moved to long format rows corresponding to z2 are starting now at row 10
y.long <- y.long %>% mutate(highlight = ifelse(type == "z1",
ifelse(row_number() %in% c(1, 7, 8),
"special", "normal"),
ifelse(row_number() %in% c(10, 14, 16, 17),
"special", "normal")))
## in your ggplot you can now map the columns to the graphical elements like so:
ggplot(y.long, aes(Iso, value,
color = type, linetype = type, shape = highlight,
group = type)) +
geom_point(size = 3) +
geom_line(aes(size = type)) +
scale_y_log10(limits = c(0.1, 2000), breaks = c(1e-1, 1, 1e1, 1e2, 1e3)) +
scale_color_manual("", values = c(z1 = "brown", z2 = "wheat")) +
scale_size_manual("", values = c(z1 = 1, z2 = 2), guide = "none") +
scale_shape_manual("", values = c(normal = 16, special = 13), guide = "none") +
scale_linetype_manual("", values = c(z1 = "solid", z2 = "dotted"), guide = "none") +
labs(x = "", y = "ZZ/CI") +
theme_bw() +
theme(axis.text.x = element_text(angle = 90, vjust = 0.5, size = 19, face = "bold"),
axis.text.y = element_text(size = 12),
axis.title.y = element_text(size = 15))
This results in the following plot:
You can adapt the mutate satement to include/exclude other rows and the scale_* functions to show/hide legends.
Theoretically, you could use something like this in your mutate
mutate(highlight = ifelse(value %in% c(343.6, 1.43, 5.18, 187.34,
2.36, 7.6, 0.5),
"special", "normal"))
but due to floating point issues (cf. for instance this article), i would not do this and rather select by row number (as I did) or any other suitable criterion, or use all.equal to make proper floating point comparisons.