<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div>Hi,</div><div><br></div><div>I am trying to change the edgecolor of some hexbin patches in a hexbin plot. Fiddling around with it to understand how this could work, I encountered a behaviour I cannot understand. I initially opened an issue at seaborn here <a href="https://github.com/mwaskom/seaborn/issues/1734">https://github.com/mwaskom/seaborn/issues/1734</a> . I get the same behaviour with pure matplotlib and am now asking here for help.<br><br>Calling get_facecolors() on the PolyCollection returned by plt.hexbin gives different results depending on the jupyter notebook cell within which the call is made.</div><div><br></div><div>Here's my example (assuming the code is run in a notebook, using Python 3.6.8, NumPy 1.16.2, Matplotlib 3.0.3, Jupyter 4.4.0)</div><div><br></div><div>Cell 1:</div><div>-------</div><div>import matplotlib<br>import matplotlib.pyplot as plt<br>import numpy as np</div><div>-------<br></div><div><br></div><div>Cell 2:</div><div>-------</div><div>x = np.array([1,1,1,1.5,1.5,2])<br>y = np.array([1,1,1,1,1,1])</div><div>-------</div><div><br></div><div>Cell 3:</div><div>-------</div><div>polycollection = plt.hexbin(x, y, C=np.ones(x.shape), reduce_C_function=np.sum, extent=[1, 2, 0.5, 1.5], gridsize=3, linewidths=1, edgecolors='face')<br>print(polycollection.get_facecolors())<br></div><div>-------</div><div>This plots three hexbins with different counts and different colours. Here, get_facecolors() returns a (1,4) array, namely,</div><div>[[0.12156863 0.46666667 0.70588235 1.        ]]</div><div><br></div><div>Cell 4:</div><div>-------</div><div>print(polycollection.get_facecolors())<br></div><div>-------</div><div>When calling get_facecolors() again in the next cell, a (3,4) array is returned, namely,</div><div>[[0.993248 0.906157 0.143936 1.      ]<br> [0.127568 0.566949 0.550556 1.      ]<br> [0.267004 0.004874 0.329415 1.      ]]</div><div><br></div><div><br></div><div>The second array seems to be the correct one I think (there are different colors for each of the three hexbins). What is happening here? I am very confused!</div><div><br></div><div>Thanks,</div><div>Niklas<br></div><div><br></div></div></div></div></div></div></div></div></div></div></div>