Home > Blockchain >  Placing Spaces Between the Titles of Plots
Placing Spaces Between the Titles of Plots

Time:08-28

I made this pie chart in R:

# https://plotly.com/r/text-and-annotations/

    df <- read.csv("https://raw.githubusercontent.com/plotly/datasets/master/gapminderDataFiveYear.csv", stringsAsFactors = FALSE)
    df <- df[which(df$year==2007 & df$continent=='Asia'),]
    
    fig <- plot_ly(df, type='pie', labels = ~country, values = ~pop, textposition = 'inside')
    fig1 <- fig %>% layout(uniformtext=list(minsize=12, mode='hide'))
    
     fig1 <- fig1 %>% add_annotations(
        y=1.05, 
        x=0.5, 
        text="Countries of the World", 
        showarrow=F,
        font=list(size=15)
      )

enter image description here

Everything works fine here, but I notice that when I am working with my real data, the title of the pie chart and the actual pie chart always come very close to intersecting with each other - I would like to try and change this.

I was thinking if there might be a way to avoid this problem. I thought that perhaps I could add more space between the title and the actual pie chart to avoid this problem from happening. I found this post here (enter image description here

  • Related