3
3
"""
4
4
import pytest
5
5
from pygmt import Figure
6
- from pygmt .helpers .testing import check_figures_equal
7
-
8
-
9
- @pytest .mark .mpl_image_compare
10
- def test_colorbar_using_paper_coordinates ():
11
- """
12
- Create colorbar positioned at 0cm,0cm with length 1cm and width 0.5cm.
13
- """
14
- fig = Figure ()
15
- fig .colorbar (cmap = "rainbow" , position = "x0c/0c+w1c/0.5c" )
16
- return fig
17
-
18
-
19
- @pytest .mark .mpl_image_compare
20
- def test_colorbar_using_paper_coordinates_horizontal ():
21
- """
22
- Create colorbar positioned at 0cm,0cm with length 2cm oriented
23
- horizontally.
24
- """
25
- fig = Figure ()
26
- fig .colorbar (cmap = "rainbow" , position = "x0c/0c+w2c+h" )
27
- return fig
28
-
29
-
30
- @pytest .mark .mpl_image_compare
31
- def test_colorbar_positioned_using_map_coordinates ():
32
- """
33
- Create colorbar positioned at longitude,latitude 3,6 with length 2cm.
34
- """
35
- fig = Figure ()
36
- fig .basemap (region = [2 , 4 , 6 , 8 ], projection = "t0/2c" , frame = True )
37
- fig .colorbar (cmap = "rainbow" , position = "g3/6+w2c" )
38
- return fig
39
-
40
-
41
- @check_figures_equal ()
42
- def test_colorbar_positioned_using_justification_code ():
43
- """
44
- Create colorbar at Top Center inside the map frame with length 2cm.
45
- """
46
- fig_ref , fig_test = Figure (), Figure ()
47
- # Use single-character arguments for the reference image
48
- fig_ref .basemap (R = "2/4/6/8" , J = "t0/2c" , B = "" )
49
- fig_ref .colorbar (C = "rainbow" , D = "jTC+w2c" )
50
-
51
- fig_test .basemap (region = [2 , 4 , 6 , 8 ], projection = "t0/2c" , frame = True )
52
- fig_test .colorbar (cmap = "rainbow" , position = "jTC+w2c" )
53
- return fig_ref , fig_test
54
-
55
-
56
- @pytest .mark .mpl_image_compare
57
- def test_colorbar_positioned_using_normalized_coords ():
58
- """
59
- Create colorbar at normalized coordinates 0.75,0.25 with length 2cm.
60
- """
61
- fig = Figure ()
62
- fig .basemap (region = [2 , 4 , 6 , 8 ], projection = "t0/2c" , frame = True )
63
- fig .colorbar (cmap = "rainbow" , position = "n0.75/0.25+w2c" )
64
- return fig
65
6
66
7
67
8
@pytest .mark .mpl_image_compare
@@ -74,16 +15,6 @@ def test_colorbar_box():
74
15
return fig
75
16
76
17
77
- @pytest .mark .mpl_image_compare
78
- def test_colorbar_box_with_pen ():
79
- """
80
- Create colorbar with box that has a different colored pen.
81
- """
82
- fig = Figure ()
83
- fig .colorbar (cmap = "rainbow" , box = "+porange" , position = "x0c/0c+w1c/0.5c" )
84
- return fig
85
-
86
-
87
18
@pytest .mark .mpl_image_compare
88
19
def test_colorbar_box_with_fill ():
89
20
"""
@@ -94,48 +25,6 @@ def test_colorbar_box_with_fill():
94
25
return fig
95
26
96
27
97
- @pytest .mark .mpl_image_compare
98
- def test_colorbar_box_with_clearance ():
99
- """
100
- Create colorbar with box that has an x-clearance of 0.8cm and y-clearance
101
- of 0.4cm.
102
- """
103
- fig = Figure ()
104
- fig .colorbar (cmap = "rainbow" , box = "+c0.8c/0.4c+porange" , position = "x0c/0c+w1c/0.5c" )
105
- return fig
106
-
107
-
108
- @pytest .mark .mpl_image_compare
109
- def test_colorbar_box_with_secondary_border ():
110
- """
111
- Create colorbar with box that has a secondary, inner border in addition to
112
- the main primary, outer border.
113
- """
114
- fig = Figure ()
115
- fig .colorbar (cmap = "rainbow" , box = "+porange+imagenta" , position = "x0c/0c+w1c/0.5c" )
116
- return fig
117
-
118
-
119
- @pytest .mark .mpl_image_compare
120
- def test_colorbar_box_with_rounded_corners ():
121
- """
122
- Create colorbar with box that has rounded corners.
123
- """
124
- fig = Figure ()
125
- fig .colorbar (cmap = "rainbow" , box = "+porange+r" , position = "x0c/0c+w1c/0.5c" )
126
- return fig
127
-
128
-
129
- @pytest .mark .mpl_image_compare
130
- def test_colorbar_box_with_offset_background ():
131
- """
132
- Create colorbar with box and an offset background shaded region.
133
- """
134
- fig = Figure ()
135
- fig .colorbar (cmap = "rainbow" , box = "+s5p/-5p" , position = "x0c/0c+w1c/0.5c" )
136
- return fig
137
-
138
-
139
28
@pytest .mark .mpl_image_compare
140
29
def test_colorbar_truncated_to_zlow_zhigh ():
141
30
"""
@@ -156,61 +45,23 @@ def test_colorbar_scaled_z_values():
156
45
return fig
157
46
158
47
159
- @check_figures_equal ()
48
+ @pytest . mark . mpl_image_compare
160
49
def test_colorbar_shading_boolean ():
161
50
"""
162
51
Create colorbar and set shading with a Boolean value.
163
52
"""
164
- fig_ref , fig_test = Figure (), Figure ()
165
- # Use single-character arguments for the reference image
166
- fig_ref .basemap (R = "0/10/0/10" , J = "X15c" , B = "a" )
167
- fig_ref .colorbar (C = "geo" , I = "" )
168
-
169
- fig_test .basemap (region = [0 , 10 , 0 , 10 ], projection = "X15c" , frame = "a" )
170
- fig_test .colorbar (cmap = "geo" , shading = True )
171
- return fig_ref , fig_test
172
-
173
-
174
- @check_figures_equal ()
175
- def test_colorbar_shading_float ():
176
- """
177
- Create colorbar and set shading with a single float variable.
178
- """
179
- fig_ref , fig_test = Figure (), Figure ()
180
- # Use single-character arguments for the reference image
181
- fig_ref .basemap (R = "0/10/0/10" , J = "X15c" , B = "a" )
182
- fig_ref .colorbar (C = "geo" , I = 0.5 )
183
-
184
- fig_test .basemap (region = [0 , 10 , 0 , 10 ], projection = "X15c" , frame = "a" )
185
- fig_test .colorbar (cmap = "geo" , shading = 0.5 )
186
- return fig_ref , fig_test
187
-
188
-
189
- @check_figures_equal ()
190
- def test_colorbar_shading_string ():
191
- """
192
- Create colorbar and set shading by passing the low/high values as a string.
193
- """
194
- fig_ref , fig_test = Figure (), Figure ()
195
- # Use single-character arguments for the reference image
196
- fig_ref .basemap (R = "0/10/0/10" , J = "X15c" , B = "a" )
197
- fig_ref .colorbar (C = "geo" , I = "-0.7/0.2" )
198
-
199
- fig_test .basemap (region = [0 , 10 , 0 , 10 ], projection = "X15c" , frame = "a" )
200
- fig_test .colorbar (cmap = "geo" , shading = "-0.7/0.2" )
201
- return fig_ref , fig_test
53
+ fig = Figure ()
54
+ fig .basemap (region = [0 , 10 , 0 , 10 ], projection = "X15c" , frame = "a" )
55
+ fig .colorbar (cmap = "geo" , shading = True , frame = True )
56
+ return fig
202
57
203
58
204
- @check_figures_equal ()
59
+ @pytest . mark . mpl_image_compare
205
60
def test_colorbar_shading_list ():
206
61
"""
207
62
Create colorbar and set shading by passing the high/low values as a list.
208
63
"""
209
- fig_ref , fig_test = Figure (), Figure ()
210
- # Use single-character arguments for the reference image
211
- fig_ref .basemap (R = "0/10/0/10" , J = "X15c" , B = "a" )
212
- fig_ref .colorbar (C = "geo" , I = "-0.7/0.2" )
213
-
214
- fig_test .basemap (region = [0 , 10 , 0 , 10 ], projection = "X15c" , frame = "a" )
215
- fig_test .colorbar (cmap = "geo" , shading = [- 0.7 , 0.2 ])
216
- return fig_ref , fig_test
64
+ fig = Figure ()
65
+ fig .basemap (region = [0 , 10 , 0 , 10 ], projection = "X15c" , frame = "a" )
66
+ fig .colorbar (cmap = "geo" , shading = [- 0.7 , 0.2 ], frame = True )
67
+ return fig
0 commit comments