Joe
Joe

Reputation: 369

modify font size on y axis for Plotly

When I try to modify my y axis title, it just disapears. Modifying the y axis ticks works just fine. Has anyone had this problem? Thanks!

library(plotly)
set.seed(2017)
x <- seq(1:10)
y <- x + rnorm(10)
plot_ly( x = ~x, y = ~y + rnorm(10)) %>%
     layout(
       xaxis = list(tickfont = list(size = 15)), 
       yaxis = list(tickfont = list(size = 25))) ## This works well.

 plot_ly( x = ~x, y = ~y + rnorm(10)) %>%
     layout(
       xaxis = list(tickfont = list(size = 15)), 
       yaxis = list(titlefont = list(size = 25))) ## This makes the y axis label disappear.

The goal is to modify the size of the y axis title, not to make it disappear all together.

Upvotes: 4

Views: 25884

Answers (2)

user16415140
user16415140

Reputation: 121

In case someone is looking for similar answer for python.
You can add fig.update_yaxes(title_font=dict(size=12))

Upvotes: 8

Julius Vainora
Julius Vainora

Reputation: 48241

It seems that it those cases it is necessary to also specify the title itself:

plot_ly( x = ~x, y = ~y + rnorm(10)) %>%
  layout(
    xaxis = list(tickfont = list(size = 15)), 
    yaxis = list(titlefont = list(size = 25), title = "test"))

enter image description here

Upvotes: 9

Related Questions