|
1 | 1 | from nose.tools import assert_equal
|
2 | 2 | from nose.tools import assert_raises
|
| 3 | +import datetime |
3 | 4 |
|
4 | 5 | import numpy as np
|
5 | 6 | from numpy import ma
|
@@ -663,6 +664,59 @@ def test_pcolormesh():
|
663 | 664 | ax = fig.add_subplot(133)
|
664 | 665 | ax.pcolormesh(Qx,Qz,Z, shading="gouraud")
|
665 | 666 |
|
| 667 | + |
| 668 | +@image_comparison(baseline_images=['pcolormesh_datetime_axis'], |
| 669 | + extensions=['png'], remove_text=False) |
| 670 | +def test_pcolormesh_datetime_axis(): |
| 671 | + fig = plt.figure() |
| 672 | + fig.subplots_adjust(hspace=0.4, top=0.98, bottom=.15) |
| 673 | + base = datetime.datetime(2013, 1, 1) |
| 674 | + x = np.array([base + datetime.timedelta(days=d) for d in range(21)]) |
| 675 | + y = np.arange(21) |
| 676 | + z1, z2 = np.meshgrid(np.arange(20), np.arange(20)) |
| 677 | + z = z1 * z2 |
| 678 | + plt.subplot(221) |
| 679 | + plt.pcolormesh(x[:-1], y[:-1], z) |
| 680 | + plt.subplot(222) |
| 681 | + plt.pcolormesh(x, y, z) |
| 682 | + x = np.repeat(x[np.newaxis], 21, axis=0) |
| 683 | + y = np.repeat(y[:, np.newaxis], 21, axis=1) |
| 684 | + plt.subplot(223) |
| 685 | + plt.pcolormesh(x[:-1, :-1], y[:-1, :-1], z) |
| 686 | + plt.subplot(224) |
| 687 | + plt.pcolormesh(x, y, z) |
| 688 | + for ax in fig.get_axes(): |
| 689 | + for label in ax.get_xticklabels(): |
| 690 | + label.set_ha('right') |
| 691 | + label.set_rotation(30) |
| 692 | + |
| 693 | + |
| 694 | +@image_comparison(baseline_images=['pcolor_datetime_axis'], |
| 695 | + extensions=['png'], remove_text=False) |
| 696 | +def test_pcolor_datetime_axis(): |
| 697 | + fig = plt.figure() |
| 698 | + fig.subplots_adjust(hspace=0.4, top=0.98, bottom=.15) |
| 699 | + base = datetime.datetime(2013, 1, 1) |
| 700 | + x = np.array([base + datetime.timedelta(days=d) for d in range(21)]) |
| 701 | + y = np.arange(21) |
| 702 | + z1, z2 = np.meshgrid(np.arange(20), np.arange(20)) |
| 703 | + z = z1 * z2 |
| 704 | + plt.subplot(221) |
| 705 | + plt.pcolor(x[:-1], y[:-1], z) |
| 706 | + plt.subplot(222) |
| 707 | + plt.pcolor(x, y, z) |
| 708 | + x = np.repeat(x[np.newaxis], 21, axis=0) |
| 709 | + y = np.repeat(y[:, np.newaxis], 21, axis=1) |
| 710 | + plt.subplot(223) |
| 711 | + plt.pcolor(x[:-1, :-1], y[:-1, :-1], z) |
| 712 | + plt.subplot(224) |
| 713 | + plt.pcolor(x, y, z) |
| 714 | + for ax in fig.get_axes(): |
| 715 | + for label in ax.get_xticklabels(): |
| 716 | + label.set_ha('right') |
| 717 | + label.set_rotation(30) |
| 718 | + |
| 719 | + |
666 | 720 | def test_pcolorargs():
|
667 | 721 | n = 12
|
668 | 722 | x = np.linspace(-1.5, 1.5, n)
|
|
0 commit comments