You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
[Bug]: bar chart with variable fill not working #29072
I prefer not to extend the fill parameter to support sequences. bar() currently uses a list or Rectangles as artists, and so individual fills would be possible. However, we may migrate to a Collection at some point. And collections do not support the fill property. The canonical apporach, which is also used in Collections is to use a sequence of facecolors and set unfilled elements to "none".
Yeah, I'll take the liberty of reopening. facecolor definitely doesn't work, though color instead of facecolor works fine. Not sure if this is a behavior issue or just documentation. It's a bit goofy that edgecolor works, but facecolor does not, in my opinion.
OK. It gets weirder, actually. I just noticed that both color and edgecolor are listed under "Other Parameters" and again under kwargs, with different descriptions. The descriptions under kwargs don't mention vectorization. It sounds like it might be really hard to straighten out this documentation issue, though.
(I know I did read both sets of descriptions earlier, but I just felt vaguely confused instead of noticing the repetition.)
facecolor should be made to accept sequences. I've opened #29090 for that.
color and edgecolor have special handling for accepting the sequences and are therefore listed explicitly. Generally, all kwargs are otherwise passed through to each Rectange - the list of rectangle properties is auto-generated and therefore also contains color and edgecolor in their original form. The auto-generation does not know about the special handling.
I think the documentation is okish as is, and it's not worth to jump extra hoops to remove the duplication. The specially handled parameters are documented explicitly and more prominently. Their functionality is a superset of the original functionality, so the auto-generated table is not wrong, only incomplete.
Activity
jklymak commentedon Nov 5, 2024
Did this work in the past? Fill is passed down ti Rectangle and I don't think it was ever done on a per-Rectangle basis, but I could be wrong.
igurin-invn commentedon Nov 5, 2024
I haven't tried this before.
QuLogic commentedon Nov 5, 2024
fillis not documented as being vectorized like that.timhoffm commentedon Nov 5, 2024
You can achieve the same effect by specifying
facecolorandedgecolor, which both accept sequences. Use "none" as facecolor for the unfolded bars.Satyanarayana3012 commentedon Nov 5, 2024
Try this code
rcomer commentedon Nov 5, 2024
@Satyanarayana3012 you can avoid the loop with
Satyanarayana3012 commentedon Nov 5, 2024
Okay
timhoffm commentedon Nov 5, 2024
I prefer not to extend the fill parameter to support sequences.
bar()currently uses a list or Rectangles as artists, and so individual fills would be possible. However, we may migrate to a Collection at some point. And collections do not support the fill property. The canonical apporach, which is also used in Collections is to use a sequence offacecolorsand set unfilled elements to "none".I therefore close this.
igurin-invn commentedon Nov 5, 2024
The documentation does not identify any of the
kwargsas accepting sequences, so I don't understand how I was supposed to figure this out.I also don't understand the solution. All of the following produced errors.
jklymak commentedon Nov 5, 2024
Yeah, I'll take the liberty of reopening. facecolor definitely doesn't work, though color instead of facecolor works fine. Not sure if this is a behavior issue or just documentation. It's a bit goofy that edgecolor works, but facecolor does not, in my opinion.
igurin-invn commentedon Nov 5, 2024
Thanks!
For the record, the single-line solution is:
Note also that
'none'is not a documented color. (Neither isNone, which does not in fact work, but is reasonable to try.)igurin-invn commentedon Nov 5, 2024
This is a bit down in the weeds, but a workaround using only documented colors is:
This is not identical (considering the possibility of a non-white background), and it does still use the undocumented vectorization of
edgecolor.rcomer commentedon Nov 5, 2024
The documentation does state that color and edgecolor may be lists.
I agree we should probably have "none" somewhere on that "Specifying colors" page.
igurin-invn commentedon Nov 5, 2024
OK. It gets weirder, actually. I just noticed that both
colorandedgecolorare listed under "Other Parameters" and again underkwargs, with different descriptions. The descriptions underkwargsdon't mention vectorization. It sounds like it might be really hard to straighten out this documentation issue, though.(I know I did read both sets of descriptions earlier, but I just felt vaguely confused instead of noticing the repetition.)
timhoffm commentedon Nov 5, 2024
"none" is now document as a color in #29081.
facecolorshould be made to accept sequences. I've opened #29090 for that.colorandedgecolorhave special handling for accepting the sequences and are therefore listed explicitly. Generally, all kwargs are otherwise passed through to eachRectange- the list of rectangle properties is auto-generated and therefore also containscolorandedgecolorin their original form. The auto-generation does not know about the special handling.I think the documentation is okish as is, and it's not worth to jump extra hoops to remove the duplication. The specially handled parameters are documented explicitly and more prominently. Their functionality is a superset of the original functionality, so the auto-generated table is not wrong, only incomplete.
I believe that's all to be done here.