Reputation: 131
Below, you can see two barplots I've superimposed in order to better see the contrast. Both barplots were generated using identical code (different data, but this is unimportant) in two simultaneously opened Jupyter Notebooks. The code for both calls 'C3' as the color, but as you can clearly see, this displays differently in both notebooks. This is the case with both the inline and the plt.savefig versions of the images. I have also tried other colors such as 'C0' and get similar slight differences.
Any ideas what might be causing this and how I might remedy it? Thanking you all in advance.
Upvotes: 0
Views: 398
Reputation: 2154
Per the color documentation the CN syntax is used to index into the current color cycler. Since RGB codes work and CN doesn't, it leads me to the conclusion that somehow the different notebooks are using different color cycles. Try the following snippet in each notebook and see if it gives you a different answer:
import matplotlib as mpl
print(mpl.rcParams["axes.prop_cycle"])
I think it's likely that somewhere in one of the notebooks there's been a call to set_prop_cycle() that has somehow changed the cycler that is being used. Also check out this post for more info on selecting the colors via the cycler.
The short answer would be to avoid the 'CN' notation.
Upvotes: 1