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 }}
Repository navigation
Unhelpful ValueError raised when color array is incorrect format #15727
Bug summary
When colors passed to a plot are provided as tuples in the range [0, 255] instead of [0, 1], the error raised relates to the shape of the data (which is correct), not the values of the data.
The correct error is being raised from colors = mcolors.to_rgba_array(c) in _axes.py. However, this is caught in _axes.py and the incorrect ValueError is raised here.
The incorrect error is raised because valid_shape is False, which is being set here. This is caused by c.size == xsize evaluating to False when c is an array of tuples because c.size will be number of tuple X size of tuple, so for c=[(255, 0, 0), (0, 255, 0)], c.size == 6 when that statement is intended to check if it is 2.
I haven't had the time to work out exactly what the intention of this bit of the code is, so have not yet found a solution.
This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!
Activity
TTitcombe commentedon Nov 20, 2019
The correct error is being raised from
colors = mcolors.to_rgba_array(c)in_axes.py. However, this is caught in_axes.pyand the incorrectValueErroris raised here.The incorrect error is raised because
valid_shapeisFalse, which is being set here. This is caused byc.size == xsizeevaluating toFalsewhencis an array of tuples becausec.sizewill benumber of tuple X size of tuple, so forc=[(255, 0, 0), (0, 255, 0)],c.size == 6when that statement is intended to check if it is2.I haven't had the time to work out exactly what the intention of this bit of the code is, so have not yet found a solution.
github-actions commentedon Jun 30, 2023
This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!
QuLogic commentedon Jun 30, 2023
This was fixed by #17245 in 3.3.0.