def testLibs(self): p = pygg.ggplot('diamonds', pygg.aes(x='carat', y='price')) p += pygg.geom_point() tmpfile = tempfile.NamedTemporaryFile(suffix='.pdf').name pygg.ggsave(tmpfile, p, data=None, libs=['grid'], quiet=True) self.assertTrue(os.path.exists(tmpfile)) self.assertTrue(os.path.getsize(tmpfile) > 0)
def testBadGGPlotFails(self): p = pygg.ggplot('diamonds', pygg.aes(x='MISSING')) + pygg.geom_point() with self.assertRaises(ValueError): tmpfile = tempfile.NamedTemporaryFile(suffix=".png").name pygg.ggsave(tmpfile, p, data=None, quiet=True)
def check_ggsave(self, plotobj, data, ext='.pdf'): tmpfile = tempfile.NamedTemporaryFile(suffix=ext).name pygg.ggsave(tmpfile, plotobj, data=data, quiet=True) self.assertTrue(os.path.exists(tmpfile)) self.assertTrue(os.path.getsize(tmpfile) > 0)
def check_ggsave(self, plotobj, data=None, ext='.pdf'): tmpfile = tempfile.NamedTemporaryFile(suffix=ext).name pygg.ggsave(tmpfile, plotobj, data=data, quiet=True) self.assertTrue(os.path.exists(tmpfile)) self.assertTrue(os.path.getsize(tmpfile) > 0)