Issue 1:
So, I was reading the online documentation of MPL on colormaps, and noticed that there is an error in it.

In the section of "Creating listed colormaps", it mentions that the dynamic range of a colormap can be reduced by using:

viridisBig = cm.get_cmap('viridis', 512)
newcmp = ListedColormap(viridisBig(np.linspace(0.25, 0.75, 256)))
plot_examples([viridis, newcmp])

It also specifically mentions that this must be done in order to make sure that the new colormap does not have repeated values.

However, as viridis is a ListedColormap and ListedColormap objects do not allow for interpolation between values, both viridisBig and newcmp will have repeated values, despite the documentation specifically mentioning they do not.

This could be fixed by either changing the tutorial into:

viridisRGB = viridis(np.linspace(0, 1, viridis.N))
viridisBig = LinearSegmentedColormap.from_list('viridisBig', viridisRGB, 512)
newcmp = ListedColormap(viridisBig(np.linspace(0.25, 0.75, 256)))
plot_examples([viridis, newcmp])

as LinearSegmentedColormap objects do allow for interpolation when creating them, or obviously by making ListedColormap objects be able to perform interpolation.

I have however noticed that the interpolation messes up sometimes, especially at the ends of the colormap.

It might therefore be better to simply take the required part of the colormap when reducing the dynamic range, with something like:

newcmp = ListedColormap(viridis(np.linspace(0.25, 0.75, viridis.N*(0.75-0.25))))
plot_examples([viridis, newcmp])

This obviously also reduces the resolution of the colormap, so it is not a good solution, but works well enough on colormaps with 256 segments and a not too big reduction in dynamic range.

Issue 2:
Bug report

Bug summary

I am updating a line plot. There is an event trigger that starts this updating. If the trigger came from the figure that contains the plot, everything is fine. However, if the trigger came from another figure, then weird results happen: the line that's been updated appears to leave its trace uncleared.

Code for reproduction

import matplotlib.pyplot as plt
import numpy as np

def onclick(event):

for ii in np.linspace(0., np.pi, 100):
y1 = y * np.sin(ii)
line1.set_ydata(y1)
ax.draw_artist(line1)
line2.set_ydata(-y1)
ax2.draw_artist(line2)
ax2.set_ylim(y1.min(), y1.max())
fig.canvas.update()
plt.pause(0.1)

x = np.linspace(0., 2*np.pi, 100)
y = np.sin(x)

fig = plt.figure()
ax = fig.add_subplot(1, 2, 1)
line1 = ax.plot(x, y)[0]

ax2 = fig.add_subplot(1, 2, 2)
line2 = ax2.plot(x, y)[0]

fig2 = plt.figure()

cid = fig2.canvas.mpl_connect('button_press_event', onclick)
# cid = fig.canvas.mpl_connect('button_press_event', onclick)

plt.show()

Actual outcome

Expected outcome

Not the many curves saw in the above figure, just one curve being updated in each cycle. In the code snippet, if use

cid = fig.canvas.mpl_connect('button_press_event', onclick)

then it works as intended.

Also note, if you resize the plot, or save it as figure, then all the residue curves will be gone.

Matplotlib version

Operating system: windows

Matplotlib version: 2.0.0

Matplotlib backend (print(matplotlib.get_backend())): Qt4Agg

Python version: 2.7

Jupyter version (if applicable):

Other libraries: