Пример #1
0
def test_geom_from_stat():
    stat = stat_identity(geom='point')
    assert isinstance(geom.from_stat(stat), geom_point)

    stat = stat_identity(geom='geom_point')
    assert isinstance(geom.from_stat(stat), geom_point)

    stat = stat_identity(geom=geom_point())
    assert isinstance(geom.from_stat(stat), geom_point)

    stat = stat_identity(geom=geom_point)
    assert isinstance(geom.from_stat(stat), geom_point)
Пример #2
0
def test_inplace_add():
    p = _p = ggplot(df)

    p += aes('x', 'y')
    assert p is _p

    p += geom_point()
    assert p is _p

    p += stat_identity()
    assert p is _p

    p += scale_x_continuous()
    assert p is _p

    with pytest.warns(PlotnineWarning):
        # Warning for; replacing existing scale added above
        p += xlim(0, 10)
        assert p is _p

    p += lims(y=(0, 10))
    assert p is _p

    p += labs(x='x')
    assert p is _p

    p += coord_trans()
    assert p is _p

    p += facet_null()
    assert p is _p

    p += annotate('point', 5, 5, color='red', size=5)
    assert p is _p

    p += guides()
    assert p is _p

    p += theme_gray()
    assert p is _p

    th = _th = theme_gray()
    th += theme(aspect_ratio=1)
    assert th is _th