def test_theme_xkcd(self): p = self.g + labs(title='Theme Xkcd') + theme_xkcd() if os.environ.get('TRAVIS'): # Travis does not have the fonts, we still check # to catch any other errors assert p + _theme != 'theme_gray' else: assert p + _theme == 'theme_xkcd'
def test_theme_xkcd(self): p = self.g + labs(title='Theme Xkcd') + theme_xkcd() if os.environ.get('TRAVIS'): # Travis does not have the fonts, we still check # to catch any other errors assert p + _theme != 'theme_gray' else: assert p + _theme == 'theme_xkcd'
def plot_pixel_values(im): plotr = pd.DataFrame( {'values': im.flatten()}, index=range(len(im.flatten())) ) return ( p9.ggplot() + p9.geom_histogram(data=plotr, mapping=p9.aes('values')) + p9.theme_xkcd() + p9.labels.xlab('Pixel values') )
def test_theme_xkcd(self): p = ( self.g + labs(title='Theme Xkcd') + theme_xkcd() # High likely hood of Comic Sans being available + theme(text=element_text(family=['Comic Sans MS']))) if os.environ.get('TRAVIS'): # Travis does not have the fonts, we still check # to catch any other errors assert p + _theme != 'theme_gray' else: assert p + _theme == 'theme_xkcd'
def test_dpi_theme_xkcd(self): fn1 = next(filename_gen) fn2 = next(filename_gen) df = pd.DataFrame({'x': range(4), 'y': range(4), 'b': list('aabb')}) p = (ggplot(df) + geom_point(aes('x', 'y')) + facet_wrap('b') + theme_xkcd()) p.save(fn1, verbose=False) assert_exist_and_clean(fn1, "Saving with theme_xkcd and dpi (1)") p.save(fn2, dpi=72, verbose=False) assert_exist_and_clean(fn2, "Saving with theme_xkcd and dpi (2)")
from plotnine import (ggplot, aes, geom_point, facet_wrap, stat_smooth, theme_xkcd) from plotnine.data import mtcars kwargs = dict(width=6, height=4) p1 = (ggplot(mtcars, aes('wt', 'mpg')) + geom_point()) p1.save('readme-image-1.png', **kwargs) p2 = p1 + aes(color='factor(gear)') p2.save('readme-image-2.png', **kwargs) p3 = p2 + stat_smooth(method='lm') p3.save('readme-image-3.png', **kwargs) p4 = p3 + facet_wrap('~gear') p4.save('readme-image-4.png', **kwargs) p5 = p4 + theme_xkcd() p5.save('readme-image-5.png', **kwargs)
from plotnine import (ggplot, aes, geom_point, facet_wrap, stat_smooth, theme_xkcd) from plotnine.data import mtcars kwargs = dict(width=6, height=4) p1 = (ggplot(mtcars, aes('wt', 'mpg')) + geom_point()) p1.save('readme-image-1.png', **kwargs) p2 = p1 + aes(color='factor(gear)') p2.save('readme-image-2.png', **kwargs) p3 = p2 + stat_smooth(method='lm') p3.save('readme-image-3.png', **kwargs) p4 = p3 + facet_wrap('~gear') p4.save('readme-image-4.png', **kwargs) p5 = p4 + theme_xkcd() p5.save('readme-image-5.png', **kwargs)