Skip to content

Bar chart support - #323

Merged
shenwei356 merged 3 commits into
shenwei356:masterfrom
lovromazgon:plot-bar
May 5, 2025
Merged

shenwei356 merged 3 commits into
shenwei356:masterfrom
lovromazgon:plot-bar

Conversation

@lovromazgon

@lovromazgon lovromazgon commented Apr 25, 2025 •

Copy link
Copy Markdown
Contributor

I noticed that it was originally planned to support bar charts, but that feature wasn't implemented. I added the command csvtk plot bar that allows you to output a bar chart.

The PR is still missing documentation and examples. I was testing it with my own data, and it almost works as expected. I need to make sure labels and legend are set correctly and aligned to the bars in all scenarios (e.g. grouped data).

I wanted to first open the PR to see if this is something you'd be willing to include in csvtk so to know if it's worth finalizing the code and documentation.

For instance, running this:

cat testdata/date2value.csv \
    | csvtk gather -f 2- -k type -v count \
    | csvtk plot bar --group-field type -x date -y count --legend-top \
    > bar-chart.png

Creates this graph:
graph

Let me know what you think 🙂

@shenwei356

Copy link
Copy Markdown
Owner

I wanted to first open the PR to see if this is something you'd be willing to include in csvtk so to know if it's worth finalizing the code and documentation.

Looks great! Thanks!

@shenwei356
shenwei356 merged commit e9bc089 into shenwei356:master May 5, 2025
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

Successfully merging this pull request may close these issues.

2 participants