Description
Bug report
Bug summary
Code for reproduction
from matplotlib import pyplot as plt
fig, axs = plt.subplots(2)
axs[0].bar("thing", 1, data={"thing": 1})
axs[1].bar("other", 1, data={"thing": 1})
plt.show()
Actual outcome
The first plot's x-value ("thing") is interpreted as a lookup into the data dict and replaced by 1.
The second plot's x-value does not appear in the data dict and is interpreted as a categorical.
Expected outcome
Not sure what the best option is, but silently changing the interpretation of input based on whether it is present or not in another dict seems a bit finnicky. I have proposed in other places to not allow scalar categoricals at all (always need to be passed in a container -- list, array, dataframe, etc.), which also solves the inconsistency that plot(1, "x")
currently specs a marker whereas plot("x", 1)
treats "x"
as a categorical.
Unlike other categorical issues I don't actually think this is release critical per se, but it would still be nice to get the behavior clarified/simplified...
Matplotlib version
- Operating system:
- Matplotlib version: 2.1
- Matplotlib backend (
print(matplotlib.get_backend())
): - Python version:
- Jupyter version (if applicable):
- Other libraries: