Пример #1
0
 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))
Пример #2
0
 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"))
Пример #3
0
 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))
Пример #4
0
 def test_graph_properties(self):
     """test graph properties"""
     g = Graph(index=0)
     g.set_title(title="Hello world!")
     self.assertEqual(g.title, "Hello world!")
     g.title = "Hello again"
     self.assertEqual(g.title, "Hello again")
     g.set_subtitle(subtitle="Hello world!")
     self.assertEqual(g.subtitle, "Hello world!")
     g.subtitle = "Hello again"
     self.assertEqual(g.subtitle, "Hello again")
Пример #5
0
 def test_change_view(self):
     """test if view changing is working"""
     g = Graph(index=1)
     g.set_view(0.0, 0.0, 1.0, 0.5)
     self.assertListEqual(g._view.view_location, [0.0, 0.0, 1.0, 0.5])
Пример #6
0
 def test_set(self):
     """set graph attributes"""
     g = Graph(index=0)
     g.set(hidden=False)
Пример #7
0
 def test_drawing(self):
     """test draing objects"""
     g = Graph(index=1)
     g.axvline(0.0)
     # percentage
     g.axvline(0.5, loctype="view", ymin="10", ymax="80")
     g.axhline(0.0)
     # percentage
     g.axhline(0.5, loctype="view", xmin="10", xmax="80")
     g.text("some annotation", [0.5, 0.5], loctype="view")
     self.assertListEqual(g._objects[-1].string_location, [0.5, 0.5])
     g.circle([0.5, 0.5], 0.1, 0.1)
     g.export()
Пример #8
0
 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)