条形图中的图表对齐

chart alignment in plotly bar chart

我的标题对齐方式在图表左侧不起作用。如何将标题左对齐。

我正在尝试对齐下方图表中左侧的标题但对我不起作用请帮助我在这里遗漏了什么或我必须更新哪一行

df <- data.frame("LOC" =c("CA","NY","WA","TX"),
                 "TAX" = c(3421.00,5640.00,7880.32,4569.00))

ttl ="Tax collection"

g <- plot_ly(df, x =~TAX, y = ~ LOC, type = 'bar',width = 1200, height =900, showlegend=F
             , text = ~paste0(roundUp(TAX*100), "%"), textposition = "outside",
             marker = list(color = "blue"))


tit <- list(
  text = ttl,
  font = cht_ttl,
  xref = "paper",
  yref = "paper",
  xanchor = "right",
  x = 0.1,
  y = 1,
  showarrow = FALSE
)
ax <- list(
  title = "",
  showgrid = FALSE,
  range = c(0, 1)
)

chart <- g %>% layout(annotations = tit,
                      xaxis = ax,
                      yaxis = list (title = " "),font=chrt_title, showline = TRUE)

chart

使用 xanchor = 'left'x 值小于 0。

library(plotly)

tit <- list(
  text = ttl,
  font = chrt_title,
  xref = "paper",
  yref = "paper",
  xanchor = "left",
  x = -0.04,
  y = 1,
  showarrow = FALSE
)


chart <- g %>% layout(annotations = tit,
                      xaxis = ax,
                      yaxis = list (title = " "),
                      font=chrt_title, showline = TRUE)

chart