ec5e8863a6352da673b55cb971529f38278cf64e,examples/images_contours_and_fields/contour_image.py,,,#,20

Before Change


plt.imshow(Z, origin="lower", extent=extent, cmap=cmap, norm=norm)
v = plt.axis()
plt.contour(Z, levels, colors="k", origin="lower", extent=extent)
plt.axis(v)
plt.title("Image, origin "lower"")

plt.subplot(2, 2, 4)

After Change


norm = cm.colors.Normalize(vmax=abs(Z).max(), vmin=-abs(Z).max())
cmap = cm.PRGn

fig, _axs = plt.subplots(nrows=2, ncols=2)
fig.subplots_adjust(hspace=0.3)
axs = _axs.flatten()

cset1 = axs[0].contourf(X, Y, Z, levels, norm=norm,
                     cmap=cm.get_cmap(cmap, len(levels) - 1))
// It is not necessary, but for the colormap, we need only the
// number of levels minus 1.  To avoid discretization error, use
// either this number or a large number such as the default (256).

// If we want lines as well as filled regions, we need to call
// contour separately; don"t try to change the edgecolor or edgewidth
// of the polygons in the collections returned by contourf.
// Use levels output from previous call to guarantee they are the same.

cset2 = axs[0].contour(X, Y, Z, cset1.levels, colors="k")

// We don"t really need dashed contour lines to indicate negative
// regions, so let"s turn them off.

for c in cset2.collections:
    c.set_linestyle("solid")

// It is easier here to make a separate call to contour than
// to set up an array of colors and linewidths.
// We are making a thick green line as a zero contour.
// Specify the zero level as a tuple with only 0 in it.

cset3 = axs[0].contour(X, Y, Z, (0,), colors="g", linewidths=2)
axs[0].set_title("Filled contours")
fig.colorbar(cset1, ax=axs[0])


axs[1].imshow(Z, extent=extent, cmap=cmap, norm=norm)
axs[1].contour(Z, levels, colors="k", origin="upper", extent=extent)
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 5

Instances


Project Name: matplotlib/matplotlib
Commit Name: ec5e8863a6352da673b55cb971529f38278cf64e
Time: 2018-03-26
Author: pmhobson@gmail.com
File Name: examples/images_contours_and_fields/contour_image.py
Class Name:
Method Name:


Project Name: matplotlib/matplotlib
Commit Name: 27c2dc10bb9f83026db6378c151d8108fc044af8
Time: 2018-06-27
Author: jklymak@gmail.com
File Name: examples/images_contours_and_fields/contour_image.py
Class Name:
Method Name:


Project Name: matplotlib/matplotlib
Commit Name: ec5e8863a6352da673b55cb971529f38278cf64e
Time: 2018-03-26
Author: pmhobson@gmail.com
File Name: examples/images_contours_and_fields/contour_image.py
Class Name:
Method Name:


Project Name: librosa/librosa
Commit Name: 24d6f5e42d775949e191122091826eefa7bf1246
Time: 2020-06-27
Author: bmcfee@users.noreply.github.com
File Name: docs/examples/plot_viterbi.py
Class Name:
Method Name: