def test_defaults(self): fig = plt.figure() data = [([self.xa1, self.ya1], [self.xa2, self.ya2]), ([self.xb1, self.yb1],)] plot_data_in_grid(fig, data, self.gs) assert_equal(len(fig.get_axes()), 2) ax1 = fig.get_axes()[0] line_a1 = ax1.get_lines()[0] line_a2 = ax1.get_lines()[1] ax2 = fig.get_axes()[1] line_b1 = ax2.get_lines()[0] line_b2 = ax2.get_lines()[1] assert_allclose(line_a1.get_xydata(), np.array([[1, 3], [2, 4]])) assert_allclose(line_a2.get_xydata(), np.array([[4, 5], [5, 6]])) assert_allclose(line_b1.get_xydata(), np.array([[6, 7], [7, 8]])) assert_allclose(line_b2.get_xydata(), np.array([[6, 9], [7, 4]])) assert_equal(ax1.get_subplotspec().get_geometry(), (3,3,0, None)) assert_equal(ax2.get_subplotspec().get_geometry(), (3,3,1, None))
def test_defaults(self): fig = plt.figure() data = [([self.xa1, self.ya1], [self.xa2, self.ya2]), ([self.xb1, self.yb1],)] plot_data_in_grid(fig, data, self.gs) assert_equal(len(fig.get_axes()), 2) ax1 = fig.get_axes()[0] line_a1 = ax1.get_lines()[0] line_a2 = ax1.get_lines()[1] ax2 = fig.get_axes()[1] line_b1 = ax2.get_lines()[0] line_b2 = ax2.get_lines()[1] assert_allclose(line_a1.get_xydata(), np.array([[1, 3], [2, 4]])) assert_allclose(line_a2.get_xydata(), np.array([[4, 5], [5, 6]])) assert_allclose(line_b1.get_xydata(), np.array([[6, 7], [7, 8]])) assert_allclose(line_b2.get_xydata(), np.array([[6, 9], [7, 4]])) assert_equal(ax1.get_subplotspec().get_geometry(), (3,3,0, 0)) assert_equal(ax2.get_subplotspec().get_geometry(), (3,3,1, 1))
def test_plot_args_marker(self): fig = plt.figure() data = [([self.xa1, self.ya1,{'marker': 's'}], [self.xa2, self.ya2]), ([self.xb1, self.yb1],)] plot_data_in_grid(fig, data, self.gs) assert_equal(len(fig.get_axes()), 2) ax1 = fig.get_axes()[0] line1 = ax1.get_lines()[0] assert_equal(line1.get_marker(), 's')
def test_gs_index_span(self): fig = plt.figure() data = [([self.xa1, self.ya1], [self.xa2, self.ya2]), ([self.xb1, self.yb1],)] gs_index=[slice(5, 9), 2] plot_data_in_grid(fig, data, self.gs, gs_index) ax1 = fig.get_axes()[0] ax2 = fig.get_axes()[1] assert_equal(ax1.get_subplotspec().get_geometry(), (3, 3, 5, 8)) assert_equal(ax2.get_subplotspec().get_geometry(), (3,3, 2, None))
def test_gs_index_span(self): fig = plt.figure() data = [([self.xa1, self.ya1], [self.xa2, self.ya2]), ([self.xb1, self.yb1], )] gs_index = [slice(5, 9), 2] plot_data_in_grid(fig, data, self.gs, gs_index) ax1 = fig.get_axes()[0] ax2 = fig.get_axes()[1] assert_equal(ax1.get_subplotspec().get_geometry(), (3, 3, 5, 8)) assert_equal(ax2.get_subplotspec().get_geometry(), (3, 3, 2, None))
def test_gs_index(self): fig = plt.figure() data = [([self.xa1, self.ya1], [self.xa2, self.ya2]), ([self.xb1, self.yb1],)] gs_index=[3,0] plot_data_in_grid(fig, data, self.gs, gs_index) ax1 = fig.get_axes()[0] ax2 = fig.get_axes()[1] #get_geometry give (nrows, ncols, start_index, end_index) # end_index is None if the gs doesn't span any positions. assert_equal(ax1.get_subplotspec().get_geometry(), (3,3,3, None)) assert_equal(ax2.get_subplotspec().get_geometry(), (3,3,0, None))
def test_gs_index(self): fig = plt.figure() data = [([self.xa1, self.ya1], [self.xa2, self.ya2]), ([self.xb1, self.yb1], )] gs_index = [3, 0] plot_data_in_grid(fig, data, self.gs, gs_index) ax1 = fig.get_axes()[0] ax2 = fig.get_axes()[1] #get_geometry give (nrows, ncols, start_index, end_index) # end_index is None if the gs doesn't span any positions. assert_equal(ax1.get_subplotspec().get_geometry(), (3, 3, 3, None)) assert_equal(ax2.get_subplotspec().get_geometry(), (3, 3, 0, None))
def test_plot_args_scatter(self): fig = plt.figure() data = [([self.xa1, self.ya1,{'plot_type': 'scatter'}], [self.xa2, self.ya2]), ([self.xb1, self.yb1],)] plot_data_in_grid(fig, data, self.gs) assert_equal(len(fig.get_axes()), 2) ax1 = fig.get_axes()[0] ax2 = fig.get_axes()[1] #I don't know how to explicitly test for scatter so... assert_equal(len(ax1.get_lines()), 1) assert_equal(len(ax2.get_lines()), 2)