Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Format the bar labels as integer (or omit entirely) #44

Open
luckman212 opened this issue Jul 12, 2023 · 1 comment
Open

Format the bar labels as integer (or omit entirely) #44

luckman212 opened this issue Jul 12, 2023 · 1 comment

Comments

@luckman212
Copy link

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:
image

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?

@kojix2
Copy link
Member

kojix2 commented Jul 18, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants