예제 #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)