style.bar: add support for axis=None (tablewise application instead of rowwise or columnwise)
State: closed

- eliminate code duplication related to style.bar with different align modes
- add support for axis=None
- fix minor bug with align 'zero' and width < 100
- make generated CSS gradients more compact

- [x] Closes #21525
- [x] tests added / passed
- [x] passes `git diff origin/master -u -- "*.py" | flake8 --diff`
- [x] whatsnew entry


Labels:
name: Output-Formatting
description: __repr__ of pandas objects, to_string
name: IO HTML
description: read_html, to_html, Styler.apply, Styler.applymap

Comments:
example with `axis=0` (top) and `axis=None` (bottom):
<img width="725" alt="screen shot 2018-06-20 at 01 11 39" src="https://user-images.githubusercontent.com/44946/41628917-f4ef4092-7426-11e8-8ff6-5afdb1de596d.png">

related  for `style.background_gradient` PR: #21259 
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/21548?src=pr&el=h1) Report
> Merging [#21548](https://codecov.io/gh/pandas-dev/pandas/pull/21548?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/68273a7a8b05049b311ea207f78e6d6f30c6eaf5?src=pr&el=desc) will **increase** coverage by `<.01%`.
> The diff coverage is `97.5%`.

[![Impacted file tree graph](https://codecov.io/gh/pandas-dev/pandas/pull/21548/graphs/tree.svg?width=650&token=eZ4WkYLtcO&height=150&src=pr)](https://codecov.io/gh/pandas-dev/pandas/pull/21548?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master   #21548      +/-   ##
==========================================
+ Coverage   92.05%   92.05%   +<.01%     
==========================================
  Files         169      169              
  Lines       50733    50736       +3     
==========================================
+ Hits        46702    46706       +4     
+ Misses       4031     4030       -1
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.46% <97.5%> (ø)` | :arrow_up: |
| #single | `42.24% <5%> (-0.01%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/21548?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/io/formats/style.py](https://codecov.io/gh/pandas-dev/pandas/pull/21548/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2Zvcm1hdHMvc3R5bGUucHk=) | `96.42% <97.5%> (+0.26%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/21548?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/21548?src=pr&el=footer). Last update [68273a7...e32c333](https://codecov.io/gh/pandas-dev/pandas/pull/21548?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

can you search the issues to see if we have something an for this? IIRC we do
@jreback   did a quick search but couldn't find anything yet

note to self: #21526  should be straightforward to include in another iteration of this issue
Hello @soxofaan! Thanks for updating the PR.





Cheers ! There are no PEP8 issues in this Pull Request. :beers: 

##### Comment last updated on August 21, 2018 at 14:03 Hours UTC
I added a commit to handle issue #21526
@soxofaan can you update the original post to include `Closes #21525`

will try to review this sometime soon.
Maybe also to be considered in this pull request:
I find the align mode names `mid` and `zero` very confusing:
- `mid` claims "midpoint is centered in the cell", but if all values are strictly positive or negative, this is not the case as zero is forced into the value range
- `zero` is about "zero is centered in the cell", which I would have called `center` (because there already is `left`), but this sounds a lot like `mid` of course.

Also: the `left` mode can lead to poor visualisation and is a bad choice as default IMHO. The bars do not start from zero at the left but from the minimum value. When this minimum is negative (or all values are negative), you get in the territory of poor/confusing visualisation.

In my refactor, I kept the original modes to avoid "bike shedding" issues, but I think I should at least raise the issue here. 
What do you think?
(rebased)
@TomAugspurger : I addressed the docstring style remarks and rebased
Thanks.

There's a linting failure: https://travis-ci.org/pandas-dev/pandas/jobs/403324861#L2928.

If you could fix that, then +1 from me.
@TomAugspurger done and rebased
@TomAugspurger done and rebased
@TomAugspurger done and rebased


Thanks @soxofaan!