Change font size and label names on x axis of plot

Hello R community,

I am fairly new to the R world but have created an R plot for Shiny that's supposed to show the results of several run throughs of a survey.
Now, I was wondering if I can somehow change the font size of the labels on the x axis. For the y axis the font size is fine. Can you help me?

This is my code:

#Duo2 <- read_excel(file.choose()) #Filename:Ryo_Lena_Duo2

#ggplot(data=Duo2) + geom_col(mapping=aes(x=Parameter, y=Erstens, fill=Parameter), show.legend=FALSE) + labs(x=NULL,y="Stimmen")
#Duo2plot <- ggplot(data=Duo2) + geom_col(mapping=aes(x=Parameter, y=Erstens, fill=Parameter), show.legend=FALSE) + labs(x=NULL,y="Stimmen")

ui <- fluidPage(
titlePanel("Ryos und Lenas interaktives Klavierduo"),
sidebarLayout(
sidebarPanel(
selectInput("var", "Abstimmung",
choices=colnames(Duo2)[-1])
),
mainPanel(
plotOutput("Duo2plot"))
)
)

server <- function(input, output) {
output$Duo2plot <- renderPlot({
ggplot(data= Duo2) +
geom_col(mapping=aes_string(
x="Parameter", y= input$var, fill="Parameter"),
show.legend=FALSE) +
labs(x=NULL,y="Stimmen")
})
}

shinyApp(ui = ui, server = server)

and this is what it looks like

Lots of good formatting examples can be found here

Try element.text(size=N), as in this example

library(tidyverse)
ggplot(data=mtcars) + 
  geom_col(mapping=aes(x=factor(carb), y=mpg, 
                       fill=factor(carb)), show.legend=FALSE) +   labs(x=NULL,y="mpg") +
  theme(axis.text.x = element_text(size=16))

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

Thanks!
This helps to change the font size in R however it doesn't change the font size in the shiny graphs...

1 Like

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

If you have a query related to it or one of the replies, start a new topic and refer back with a link.