def test_multiple_plot(self): """test plotting xy data""" g = Graph(index=1) x = [0.0, 1.0, 2.0] y = [[1.0, 2.0, 3.0], [2.0, 3.0, 4.0], [3.0, 4.0, 5.0]] g.plot(x, y, symbol="o", color="red") self.assertEqual(len(y), len(g))
def test_set_legend(self): """test legend setup""" g = Graph(index=0) g.plot([0,], [0,], label="origin") g.set_legend(switch="off", color="red") horis = ["left", "center", "right"] verts = ["upper", "middle", "lower", "bottom"] for hori, vert in product(horis, verts): g.set_legend(loc="{} {}".format(vert, hori))
def test_single_plot(self): """test plotting xy data""" g = Graph(index=1) x = [0.0, 1.0, 2.0] y = [1.0, 2.0, 3.0] g.plot(x, y, label="y=x+1", symbol="o", color="red") self.assertEqual(g[0]._symbol.type, Symbol.get("o")) # both symbol and line are colored self.assertEqual(g[0]._symbol.color, Color.get("red")) self.assertEqual(g[0]._line.color, Color.get("red"))
def test_extremes(self): """test x/ymin/max of graphs""" g = Graph(index=1) g.plot([1,], [2,]) g.plot([-1,], [3,]) g.plot([2.3,], [-1.2,]) self.assertEqual(g.xmin(), -1) self.assertEqual(g.xmax(), 2.3) self.assertEqual(g.min(), -1.2) self.assertEqual(g.max(), 3)