def test_regular_graphs(self): """generate regular graph alignment""" p = Plot(1, 1) self.assertEqual(len(p), 1*1) p = Plot(3, 4, hgap=[0.01, 0.0, 0.02], vgap=[0.02, 0.0], width_ratios="3:2:1:4", heigh_ratios="1:3:2") self.assertEqual(len(p), 3*4)
def test_subplots(self): """test subplots generation""" p, _ = Plot.subplots() self.assertEqual(len(p), 1) p, _ = Plot.subplots(3) self.assertEqual(len(p), 3) p, _ = Plot.subplots(32) self.assertEqual(len(p), 6)
def test_write(self): """writing to agr""" p = Plot(1, 1) p.plot([0, 1, 2], [3, 2, 1]) self.assertEqual(len(p), 1) p.tight_graph() tf = tempfile.NamedTemporaryFile() with open(tf.name, 'w') as h: p.write(h) tf.close()
def test_change_limits(self): """test limits manipulation of all graphs""" p = Plot(2, 2) p.set_xlim(xmin=1.0, xmax=2.0) p.set_ylim(ymin=3.0, ymax=4.0) for g in p.get(): self.assertListEqual(g._world.world_location, [1.0, 3.0, 2.0, 4.0])
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """demonstration of xy plot""" import numpy as np from pygraceplot.graceplot import Plot p, ax = Plot.subplots(1, 1, description="sin(x) drawn by pygraceplot") x = np.linspace(-np.pi, np.pi, 100) y = np.sin(x) ax.plot(x, y, symbol="none", color="blue", label="sin(x)") p.tight_graph() ax.set_legend(loc="upper left", charsize=2.0) p.savefig("sin.eps")
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """Bar plot for effective cluster interaction""" import numpy as np from pygraceplot.graceplot import Plot # data generation x_two_body = np.arange(1, 24, 1) x_three_body = np.arange(24, 34, 1) y_two_body = np.random.randint(-2, 4, size=len(x_two_body)) y_three_body = np.random.randint(-2, 4, size=len(x_three_body)) # plot p, ax = Plot.subplots(1, 1, description="ECI drawn by pygraceplot", background=False) ax.set_view(xmin=0.3235, xmax=1.1, ymin=0.25, ymax=0.85) ax.plot(x_two_body, y_two_body, ls="none", label="two-body", color="red", datatype="bar") ax.plot(x_three_body, y_three_body, ls="none", label="three-body", color="green", datatype="bar") ax.axhline(0.0)
def test_add_graph(self): """graph addition""" p = Plot(2, 2) p.add_graph() self.assertEqual(len(p), 2*2+1)
def test_set_default(self): """set default properties""" p = Plot(1, 1) p.set_default(font=2) self.assertEqual(2, p._default.font)
def test_init_properties(self): """default properties""" p = Plot(1, 1, description="Hello World") self.assertEqual("Hello World", p.description)