forked from has2k1/plotnine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_scale_labelling.py
60 lines (46 loc) · 1.3 KB
/
test_scale_labelling.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import pandas as pd
from plotnine import (
aes,
element_text,
facet_grid,
geom_point,
ggplot,
labs,
theme,
)
from plotnine.data import mtcars
_theme = theme(subplots_adjust={'right': 0.80})
_theme_captions = theme(subplots_adjust={'bottom': 0.30})
c1 = "This is a sample caption"
c2 = """\
Lorem Ipsum is simply dummy text of the printing and typesetting industry.
Lorem Ipsum has been the industry's standard dummy text ever since the 1500s,
when an unknown printer took a galley of type and scrambled it to make
a type specimen book."""
df = pd.DataFrame({
'x': [1, 2],
'y': [3, 4],
'cat': ['a', 'b']
})
def test_labelling_with_colour():
p = (ggplot(df, aes('x', 'y', color='cat'))
+ geom_point()
+ labs(colour='Colour Title')
)
assert p + _theme == 'labelling_with_colour'
def test_caption_simple():
p = (ggplot(mtcars, aes('wt', 'mpg'))
+ geom_point()
+ labs(caption=c1)
)
assert p == 'caption_simple'
def test_caption_complex():
p = (ggplot(mtcars, aes('wt', 'mpg'))
+ geom_point()
+ labs(caption=c2)
+ facet_grid('am ~ vs')
+ theme(
plot_caption=element_text(x=0.125, ha='left', size=12)
)
)
assert p == 'caption_complex'