Change format of y axis in plotly

Marta

I'm trying to format y axis numbers' format (in plotly) and - after hours of googling - I've decieded to ask here.

I've got a plot like here:

enter image description here

generated with this code:

library("plotly")
library("dplyr")

data.frame(miesiac_label = as.character(as.roman(c(1:12))),
           ile = c(12000, 12100, 11100, 12000, 12000, 11900, 12200, 12100, 6000, 12100, 12100, 12100)) -> dane
dane$miesiac_label <- factor(dane$miesiac_label, levels = dane[["miesiac_label"]])

plot_ly(dane) %>%
    add_trace(x = ~miesiac_label, y = ~ile,
              type = 'bar', marker = list(color = '#99d3df'))

My goal is to change yaxis formatting from 12k, 10k, 8k, ... to more "polish one", so 12 tys, 10 tys, 8 tys, .... I know how to change it setting ticktext and ticktext, but I don't want to set values on my own, I prefer to have them more automatic.

I've read about thickformat but I didn't find there option, which would change k to tys.

Thanks for your help!

MLavoie

I think using layout() gives you what you want. First, you need to divide your y by 1000 (maybe there is another way) and then use ticksuffix to add tys.

plot_ly(dane) %>%
add_trace(x = ~miesiac_label, y = ~ile/1000, type = 'bar', marker = list(color = '#99d3df')) %>% 
layout(yaxis = list(ticksuffix= "tys", title = "ile"))

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

TOP Ranking

HotTag

Archive