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
@anntzer pointed out on #9340 that the behavior for plt.plot([23, "23"]) should be two data points with identical labels. Currently it collapses them into one value:
As an additional point where allowing uncontrolled mixing of strings and numbers can be puzzling:
fill_between([0, 1, 2], [2, 3, 2])
great, let's plot this in red
fill_between([0, 1, 2], [2, 3, 2], "r")
(saved on the same figure to save some room)
Ah, that's because the second parameter is "y2" (so I needed to write color="r") and "r" got converted to "0" by the categorical converter... (I would say once an axes has used the scalar (passthrough) converter it should disable the categorical converter, just as the categorical converter should not pass scalars through.)
I knew exactly the issue with categoricals, and that behavior still led to a bit a head scratching...
I agree that's a bug, but the issue seems to be that the second positional parameter is ambiguous. Like it's technically doing the correct thing, given that this works the exact same way:
Errors out spectacularly because it tries to do a lookup on 'r' against the existing mapping and doesn't see it as a new value:
~/projects/matplotlib/lib/matplotlib/category.py in convert(value, unit, axis)
47
48 if isinstance(value, six.string_types):
---> 49 return vmap[value]
50
51 str_value = shim_array(value)
KeyError: 'r'
Also, it's not hitting the update and instead going straight to the convert, which is why this isn't working either:
ETA: Ok, I think your point is that once I've set the yaxis to being scaler, it should have a flag of sorts that all other values passed to it need to use the same units? That seems reasonable/I agree.
Activity
tacaswell commentedon Oct 10, 2017
I am not super concerned about this, it is string catagoricals.
efiring commentedon Oct 10, 2017
Which brings us back to @anntzer's earlier suggestion that we should raise an error instead of accepting this nonsensical input.
anntzer commentedon Oct 20, 2017
As an additional point where allowing uncontrolled mixing of strings and numbers can be puzzling:
great, let's plot this in red
(saved on the same figure to save some room)

Ah, that's because the second parameter is "y2" (so I needed to write
color="r") and "r" got converted to "0" by the categorical converter... (I would say once an axes has used the scalar (passthrough) converter it should disable the categorical converter, just as the categorical converter should not pass scalars through.)I knew exactly the issue with categoricals, and that behavior still led to a bit a head scratching...
story645 commentedon Oct 20, 2017
I agree that's a bug, but the issue seems to be that the second positional parameter is ambiguous. Like it's technically doing the correct thing, given that this works the exact same way:
What I mean is
Errors out spectacularly because it tries to do a lookup on 'r' against the existing mapping and doesn't see it as a new value:
Also, it's not hitting the update and instead going straight to the convert, which is why this isn't working either:
ETA: Ok, I think your point is that once I've set the yaxis to being scaler, it should have a flag of sorts that all other values passed to it need to use the same units? That seems reasonable/I agree.
tacaswell commentedon Feb 12, 2018
Closed by #9783
Still some broken edge cases (which we have tests for now).