#Format number in Plotly table plot

1 messages · Page 1 of 1 (latest)

hearty terrace
#

I tried to plot(table(...)) of a data formatted in dataframe, I want to format the number so that only show one decimal place. according to this doc https://plotly.com/julia/reference/table/#table-cells-format, I expected that this code would do. is there something I missed?

v = ["DJI", 2456.3066, 450.334, 2.788, 999.999]
h = ["Ticker","1d","5d mean","10d mean","20d mean"]
plot(
  table(
    header=attr(
      values=h,
      fill_collor="paleturquoise",
      align="center"
    ),
    cells=attr(
      values=v,
      fill_color="lavender",
      align="right",
      format="%{value:.1f}"
    )
  )
)
marsh saffron
#

Julia doesn't use % as string interpolation, instead it's $ or $(). For rounding of numbers we have to use round, or Printf @printf macro

#

Try to using Printf and then read ?@printf and ?@sprintf to see if any of them could fit your needs

hearty terrace
#

as far as I used plotly with julia, plotly have their on styles when it comes to formatting numbers such as this texttemplate="%{label}<br>%{value:.2s}B<br>%{text:.3}%" where %{variable: fmt} but I just do not understand how to use it when it comes to plot(table(...))

marsh saffron
#

Oh right, I forgot that it can be annoying like that sometimes. I don't know the answer