plot icon indicating copy to clipboard operation
plot copied to clipboard

Show value of each bar on top of it

Open agzuniverse opened this issue 4 years ago • 8 comments

This change modifies the bar charts to show their values as a label on top of each bar if the user sets the new b.ShowLabel option to true.

This PR builds on #556 Closes #475

agzuniverse avatar Mar 11 '20 19:03 agzuniverse

@kortschak you mentioned #556 cannot be merged because it does not pass the CI build, so here's a PR which does.

agzuniverse avatar Mar 11 '20 19:03 agzuniverse

When can master branches use this feature?

xiaofeng-zerone avatar Mar 26 '20 02:03 xiaofeng-zerone

It would need to be merged first, and then it will be included in the next minor release. In order to be merged it needs to pass review, which will require that the change requests are satisfied.

kortschak avatar Mar 26 '20 03:03 kortschak

I'll look into adding a test for this soon.

agzuniverse avatar Mar 26 '20 08:03 agzuniverse

Is there any plan on moving forward with this feature ? It seems like a really nice addition and I'd personally love to use the master branch of gonum/plot rather than my own fork just for this feature.

lynxplay avatar May 06 '21 23:05 lynxplay

I think the only reason this PR wasn't merged is because I didn't write tests for this change. I thought of doing it but unfortunately couldn't find the time. @lynxplay if you could add a test the maintainers will probably merge this change in to master.

agzuniverse avatar May 08 '21 20:05 agzuniverse

Yeah I tried looking into this but the generated plots don't respect the written values on top of the bars when cropping so one value is always cropped off.

Tests on this are mainly just a single generated graph and an image comparison no?

lynxplay avatar May 08 '21 20:05 lynxplay

yes, we like to have a simple testdata/foo_golden.{png,svg,...} reference file and a test (or an example) generating that file to compare with and make sure we don't introduce regressions when refactoring code.

here is an example:

  • https://github.com/gonum/plot/blob/v0.9.0/plotter/barchart_example_test.go#L159 (example generating testdata/barChart_positiveNegative.png)
  • https://github.com/gonum/plot/blob/v0.9.0/plotter/barchart_test.go#L19 (the test that runs ExampleBarChart_positiveNegative and leverages the cmpimg package that compares with reference files)
  • https://github.com/gonum/plot/blob/v0.9.0/plotter/testdata/barChart_positiveNegative_golden.png (the reference file)

(with my apologies for the belated answer.)

sbinet avatar Jun 24 '21 07:06 sbinet