Title - break, left align

Hi,

I'd like to ask for help with the long title. What would you suggest to address it?

image

ggplot(data = sf) +
  geom_sf(aes(fill = value), colour = "grey10",size=0.2)+
  scale_fill_gradientn(colours= rev(palette),labels= function(x) paste0(format(round(x, 0), nsmall = 0), ""))+
  labs(title = "Počet neuspokojených žádostí o pečovatelskou službu a osobní asistenci na 1000 obyvatel 65+ 2018",
       fill = "") +
  theme(legend.text.align = 1,
        legend.title.align = 0.5,
        legend.text=element_text(size=7),
        plot.title = element_text(hjust = .1,vjust=0.2,size=15),
        panel.grid.major = element_blank(), 
        panel.grid.minor = element_blank(),
        panel.background = element_blank(),
        axis.text.x=element_blank(),
        axis.text.y=element_blank(),
        axis.ticks=element_blank(),
        axis.title.x=element_blank(),
        axis.title.y=element_blank())+
  geom_sf_text(aes(label =nazev),size=3,family="sans")+
  annotate("text",x = 14.5, y = 49.8, label = "Středočeský",size=3)+
  annotate("text",x = 17.3, y = 49.6, label = "Olomoucký",size=3)+
  annotate("text",x = 16.7, y = 49.0, label = "Jihomoravský",size=3)+
  ggsave(filename="kraje_neuspesne_zadosti_sluzba.png",dpi="print")

Than you!

You can put \n before a word to creat a line break.

Sorry, I forgot to mention that I know this way. However, it isn't aligned to the left.

image

Hi Jakub,

I don't have a copy of your data.frame sf to reproduce your map, but here is a toy example using mtcars with stringr::str_wrap wrapping the title at 55 characters.

library("ggplot2")
library("stringr")

plot_title <- "Počet neuspokojených žádostí o pečovatelskou službu a osobní asistenci na 1000 obyvatel 65+ 2018"

ggplot(mtcars, aes(mpg, hp)) +
  geom_point() +
  labs(title = str_wrap(plot_title,  width = 55))

Created on 2020-07-26 by the reprex package (v0.3.0)

Ok, sorry, now i understand.

Here is a nother potential solution, beside the one suggested by jrmuirhead:

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