mkaz / termgraph

a python command-line tool which draws basic graphs in the terminal

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Question regarding the format specifier

moravveji opened this issue · comments

Hi.

I am trying to create some stacked bar graphs, using integer values. However, the default format is 5.2f float. trying to override that with e.g. 3d literally prints out the 3d to the r.h.s of each bar. See the attached figure.

How can I show integral values on the graph?

Thanks
Ehsan
image

@moravveji You can use it like so: termgraph --format '{:3.0f}'

Also, all numbers are treated as floats, so use f instead of d.

See this String Format Cookbook for help with syntax if you need something additional:
https://mkaz.blog/code/python-string-format-cookbook/

Thanks a lot for the tip.