Format the bar labels as integer (or omit entirely)
luckman212 opened this issue · 1 comments
I'm using the following command (example)
<...data...> | uplot bar -c blue -t "sindresorhus/awesome" --xlabel "commits (last 12m)"
to generate a bar chart like this:
In this case, the X value will always be an integer. Any way to drop that .0
and display it as a whole number? Or remove the label altogether and just print an x-axis at the top or bottom?
Hi @luckman212
Thank you for your suggestion to display bar labels as integers or no labels at all.
Current Status and Background
YouPlot is a simple wrapper for UnicodePlot.rb, slightly processing the standard input and calling UnicodePlot.rb. The Ruby language implementation of UnicodePlot is inspired by UnicodePlot.jl of the Julia language.
The following code in UnicodePlot displays the labels on the bar chart.
https://github.com/red-data-tools/unicode_plot.rb/blob/master/lib/unicode_plot/barplot.rb#L51-L53
bar_lbl = bar.to_s
print_styled(out, bar_str, color: @color)
print_styled(out, " ", bar_lbl, color: :normal)
If bar
is an Integer
, then bar_lbl
will be a String of Integer, and if it is a Float
number, then bar_lbl
will be a String of Float. And there appears to be no conditional branch that does not display bar_labl. There does not seem to be an option here to show or not show bar_labl.
labels as integers
Currently YouPlot assume that all inputs are Float. There are two ways of thinking about automatic recognition. The first is the idea that any string that does not have a decimal point is considered an integer. The second is the idea that after all inputs are received, it is considered an integer only if after all inputs are received, all of them are integers. For manual recognition, a new option must be set.
Do not show labels option
If you consider the option of not displaying labels at all, you will need to make some changes to UnicodePlot. And it must be consistent with UnicodePlot.jl.
Unfortunately I don't have much time for OSS these days. If anyone would like to help me improve UnicodePlot, I would appreciate it.