Example #1
0
def test_theme_options_should_be_merged():
    spec = gg.ggplot() + _geom('foo') + theme(axis_tooltip='blank') + theme(legend_position='bottom')
    expected_theme = {
        'axis_tooltip': 'blank',
        'legend_position': 'bottom'
    }
    assert expected_theme == spec.as_dict()['theme']
Example #2
0
def test_element_values_merged():
    spec = (gg.ggplot() + _geom('foo') +
            theme(panel_background=element_rect(color='a', fill='b')) +
            theme(panel_background=element_rect(color='c', size=1)))

    rect = spec.props()['theme']['panel_background']
    assert isinstance(rect, dict)
    assert 'c' == rect['color']
    assert 'b' == rect['fill']
    assert 1 == rect['size']
Example #3
0
def test_global_theme():
    gg.LetsPlot.set_theme(theme(axis_tooltip=element_blank()))

    spec = gg.ggplot() + _geom('foo')

    assert spec.as_dict()['theme']['axis_tooltip']['blank']
    assert isinstance(spec.props()['theme']['axis_tooltip'], dict)
Example #4
0
def test_element_blank_in_theme_option():
    spec = gg.ggplot() + _geom('foo') + theme(axis_tooltip=element_blank())
    assert 'blank' == spec.as_dict()['theme']['axis_tooltip']['name']
    assert isinstance(spec.props()['theme']['axis_tooltip'], FeatureSpec)
Example #5
0
def test_None_theme_option_not_override_the_previous():
    spec = gg.ggplot() + _geom('foo') + theme(legend_position='bottom') + theme(legend_position=None)
    assert 'bottom' == spec.as_dict()['theme']['legend_position']
Example #6
0
def test_override_theme_None_option_with_value():
    spec = gg.ggplot() + _geom('foo') + theme(legend_position=None) + theme(legend_position='bottom')
    assert 'bottom' == spec.as_dict()['theme']['legend_position']
Example #7
0
def test_override_theme_option():
    spec = gg.ggplot() + _geom('foo') + theme(legend_position='bottom') + theme(legend_position='none')
    assert 'none' == spec.as_dict()['theme']['legend_position']
Example #8
0
def test_overriding_global_theme_with_named():
    gg.LetsPlot.set_theme(theme(legend_position='top'))

    spec = gg.ggplot() + _geom('foo') + theme_classic()

    assert 'legend_position' not in spec.as_dict()['theme']
Example #9
0
def test_global_theme_overriding():
    gg.LetsPlot.set_theme(theme(legend_position='bottom'))

    spec = gg.ggplot() + _geom('foo') + theme(legend_position='top')

    assert 'top' == spec.as_dict()['theme']['legend_position']
Example #10
0
def test_named_theme_is_modified_by_theme():
    spec = gg.ggplot() + _geom('foo') + theme_classic() + theme(
        legend_position='bottom')
    assert 'bottom' == spec.as_dict()['theme']['legend_position']
Example #11
0
def test_named_theme_overrides_all():
    spec = gg.ggplot() + _geom('foo') + theme(
        legend_position='bottom') + theme_classic()
    assert 'legend_position' not in spec.as_dict()['theme']