I found a really strange behaviour of Matplotlib. I written a little script which reproduces this issue, please check this gist repository for the file.
The file referenced in the gist makes two 3D histogram plots. Each of those plots consists of nested bars (a bar inside of bar), they differ with edge colors, size and transparency (alpha).
What I find strange is, running this script multiple times produces different plot at each run. The script accepts an argument for modifying a file name, I run it in following way
$ python plottest.py a
$ python plottest.py b
$ python plottest.py c
$ python plottest.py c
$ python plottest.py c
(the c
plot I had to run three times until figure became different than at b
run)
and it led to following plots, exactly the same script created those three plots
sometimes the alpha
parameter is ignored (leading to lack of transparency), sometimes edgecolor
parameter is ignored (leading to lack of black edges on the outer bars).
I find it hard to implement a reliable script if each time I run it, it leads to different plot. This is not a Jupyter notebook, it is just a regular Python script. I tried to remove __pycache__
directory with no effect, parameters are still randomly ignored.
I think I am doing something wrong, there is something I don't understand in the way Matplotlib is drawing those axes leading to this behaviour. Maybe someone more experienced could comment on that.
My operating system is
$ sw_vers
ProductName: Mac OS X
ProductVersion: 10.14.5
BuildVersion: 18F132
My Python version
$ python -V
Python 3.5.3
My Matplotlib version
$ pip show matplotlib
Name: matplotlib
Version: 3.0.3
Summary: Python plotting package
Home-page: http://matplotlib.org
Author: John D. Hunter, Michael Droettboom
Author-email: [email protected]
License: PSF
Location: /Users/marek/.pyenv/versions/3.5.3/lib/python3.5/site-packages
Requires: kiwisolver, numpy, python-dateutil, pyparsing, cycler
Required-by: seaborn, scikit-image, chemview, chemlab
@00 reproduced this problem and noticed it doesn't persist for newer versions of Python and Matplotlib. I made an update to
$ python -V
Python 3.7.4
and
$ pip show matplotlib
Name: matplotlib
Version: 3.1.2
Summary: Python plotting package
Home-page: https://matplotlib.org
Author: John D. Hunter, Michael Droettboom
Author-email: [email protected]
License: PSF
Location: /Users/marek/.pyenv/versions/3.7.4/lib/python3.7/site-packages
Requires: cycler, python-dateutil, kiwisolver, pyparsing, numpy
Required-by:
Now no matter how many times I run the script outcome is identical and thus behaviour is predictible. Thanks for help!