Repository navigation
Description
Request 1: imshow should have separate rcParams for removing ticks and grid.
The image key should take additional parameters, so that x and y ticks are not present by default, and the grid is not overlaid by default if axes.grid is True. For example image.axis: False would be ideal. To me, it quite reasonable to want axes.grid: True as the default for numerical plots as well a separate default for imshow since they have very different use cases.
Here is an example:
import matplotlib
matplotlib.rcdefaults()
matplotlib.use('qt4agg') # or whatever
matplotlib.rcParams['axes.grid'] = True
matplotlib.rcParams['axes.axisbelow'] = True
matplotlib.rcParams['grid.linestyle'] = '--'
matplotlib.rcParams['grid.color'] = 'red'
matplotlib.rcParams['grid.linewidth'] = 2.0
import matplotlib.pyplot as plt
from numpy import zeros,cos,linspace
x = linspace(0,6.28,100)
fig = plt.figure(figsize=(12,6))
ax1 = fig.add_subplot(121)
ax1.plot(x,cos(x+2*cos(2*x)),lw=3)
ax1.set_title('Ticks and grid are a nice\ndefault for numerical plots.')
ax2 = fig.add_subplot(122)
ax2.imshow(zeros((100,100)), cmap=plt.cm.gray)
ax2.set_title('Ticks and grid are not a nice\ndefault for image plots.')
plt.show()
Request 2: Fix inconsistent rcParams behavior with regard to plots that add patches.
Some plots that use patches follow the axes.prop_cycle, while others do not. For example hist obeys both axes.prop_cycle and patch.edgecolor, but ignores patch.facecolor (even if axes.prop_cycle is not set); however, violinplot ignores everything except patch.edgecolor, which is not apparent due to the default alpha setting for violinplot (why is this default??). Here is an example:
import matplotlib
from cycler import cycler
matplotlib.rcdefaults()
matplotlib.use('qt4agg')
matplotlib.rcParams['axes.prop_cycle'] = cycler('color', ['pink','purple','salmon'])
matplotlib.rcParams['patch.facecolor'] = 'pink'
matplotlib.rcParams['patch.edgecolor'] = 'blue'
import matplotlib.pyplot as plt
from numpy.random import randn
fig = plt.figure(figsize=(12,6))
X = randn(100)
ax = fig.add_subplot(121)
for i in range(3):
ax.hist(X+2*i)
ax = fig.add_subplot(122)
for i in range(3):
ax.violinplot(X+2*i)
plt.show()


Activity
tacaswell commentedon Dec 4, 2015
request 1 is a bit tricky, what should it do in the case where you have lines and images? I suggest using the style context manager to control this based on the context you are plotting.
Request 2 is definitely on our radar for the upcoming 2.0 release.
notmatthancock commentedon Dec 4, 2015
Here's my opinion:
I think the default behavior for combinations of lines and images would be more-or-less arbitrary. For example, it could just take the default
axes.gridbehavior if the grid for plotted images followed theaxes.axisbelowrule (which it doesn't seem to follow currently).More importantly, I think the convenience of an
image.axisdefault would outweigh any inconvenience of combination image+lines not behaving as expected.efiring commentedon Dec 4, 2015
I really worry about rcParams getting ever more complicated and convoluted. I do not support request #1.
tacaswell commentedon Jan 25, 2016
request 2 will be addressed in 2.0 (see #5674 ) however we will not make rcparams conditional on the type of artists being added to the axes.