nschloe / termplotlib

:chart_with_upwards_trend: Plotting on the command line
GNU General Public License v3.0
675 stars 19 forks source link

Feature request: Configure formatting for bin labels #80

Open tardigradus opened 1 year ago

tardigradus commented 1 year ago

With commit https://github.com/nschloe/termplotlib/commit/2811fafbd6bece69ff57abdf23968e8874995d3e the format of the bin edge labels for histograms was changed to exponential format. The application I want to use, https://github.com/ycrc/seff-array, mainly produces bin labels which are percentages, e.g.

CPU Efficiency (%)
---------------------
+0.00e+00 - +1.00e+01  [ 1]  ███▋
+1.00e+01 - +2.00e+01  [ 0]
+2.00e+01 - +3.00e+01  [ 0]
+3.00e+01 - +4.00e+01  [ 0]
+4.00e+01 - +5.00e+01  [ 0]
+5.00e+01 - +6.00e+01  [ 0]
+6.00e+01 - +7.00e+01  [ 0]
+7.00e+01 - +8.00e+01  [ 9]  ████████████████████████████████▊
+8.00e+01 - +9.00e+01  [11]  ████████████████████████████████████████
+9.00e+01 - +1.00e+02  [ 0]

Here the exponential format makes the labeling rather unclear.

Would it be possible to make this configurable?

tardigradus commented 1 year ago

As a local fix, in the file hist.py in my venv I have replaced the line

f"{bin_edges[k]:+.2e} - {bin_edges[k+1]:+.2e}"

with

f"{bin_edges[k]:>6.2f} - {bin_edges[k+1]:>6.2f}"