labels with geom_text

I'm trying to no avail adding the degree symbol to my points' labels using "labels" or "label" with "paste" and "expression" in ggplot to no avail. Any help would be greatly appreciated.

ggplot(df1,aes(min,xend=max,variable))+
geom_dumbbell(size = 1,
size_x =2.5,
size_xend =2.5,
colour = "grey",
colour_x = "blue",
colour_xend = "red")+
geom_point(aes(mean,alpha=0.5))+
geom_text(aes(mean,variable,label=round(mean,digits=2),hjust=0,vjust=-2),size=3)+
scale_size(guide=FALSE)+scale_alpha(guide=FALSE)+
theme_minimal()+
labs(title = "Indoor Air Temperature (°C)",
subtitle = "Minimum, Mean and Maximum",
x = "Temperature",
y = "")

Hello, I believe this is not within the ggplot2 package, so its probably an extension ?
Which package is this from.
Also it would make it easier/convenient for forum users to look at your code and try solutions if you could provide example data. Perhaps enough for two of your seven dumbells would be sufficient.

here the data in the data frame:

df1

A tibble: 7 x 4

variable mean min max

1 base 21.6 19.8 23.3
2 urban.blue 21.4 19.8 23.0
3 intensive.green 20.5 19.8 21.3
4 extensive.green 20.4 19.8 21.1
5 max.built 21.4 19.8 23.1
6 cool.pavement 21.7 19.8 23.5
7 combined 20.3 19.8 21.0

paste0 is a convenience , it is equivalent to paste(...., sep="") (i.e. an empty seperator)

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

I'm not 100% sure as I have a plethora of packages loaded but I believe it comes from 'ggalt'. can u suggest an alternative method. thanks for your help

library(tidyverse)
library(ggalt)
df1<- tribble(~variable,~mean,~min,~max,
"base",21.6,19.8,23.3,
"urban.blue",21.4,19.8,23.0,
"intensive.green",20.5,19.8,21.3,
"extensive.green",20.4,19.8,21.1,
"max.built",21.4,19.8,23.1,
"cool.pavement",21.7,19.8,23.5,
"combined",20.3,19.8,21.0)


ggplot(df1,aes(min,xend=max,variable))+
  geom_dumbbell(size = 1,
                size_x =2.5,
                size_xend =2.5,
                colour = "grey",
                colour_x = "blue",
                colour_xend = "red")+
  geom_point(aes(mean,alpha=0.5))+
  geom_text(aes(mean,variable,label=paste0(round(mean,digits=2),"°C"),hjust=0,vjust=-2),size=3)+
  scale_size(guide=FALSE)+scale_alpha(guide=FALSE)+
  theme_minimal()+
  labs(title = "Indoor Air Temperature (°C)",
       subtitle = "Minimum, Mean and Maximum",
       x = "Temperature",
       y = "")

this is a problematic way to share the data unfortunately.
please try the dput() function on your data, so that a copy pasteable representation is possible

Excellent. Thank you so much for your help. Very much appreciated. All the best. I see I should have used past0 instead of just paste.