1
- """
2
- Base class with plot generating commands.
1
+ """Base class with plot generating commands.
2
+
3
3
Does not define any special non-GMT methods (savefig, show, etc).
4
4
"""
5
5
import contextlib
19
19
20
20
21
21
class BasePlotting :
22
- """
23
- Base class for Figure and Subplot.
22
+ """Base class for Figure and Subplot.
24
23
25
24
Defines the plot generating methods and a hook for subclasses to insert
26
25
special arguments (the _preprocess method).
27
26
"""
28
27
29
28
def _preprocess (self , ** kwargs ): # pylint: disable=no-self-use
30
- """
31
- Make any changes to kwargs or required actions before plotting.
29
+ """Make any changes to kwargs or required actions before plotting.
32
30
33
31
This method is run before all plotting commands and can be used to
34
32
insert special arguments into the kwargs or make any actions that are
@@ -50,7 +48,6 @@ def _preprocess(self, **kwargs): # pylint: disable=no-self-use
50
48
>>> base = BasePlotting()
51
49
>>> base._preprocess(resolution="low")
52
50
{'resolution': 'low'}
53
-
54
51
"""
55
52
return kwargs
56
53
@@ -75,8 +72,7 @@ def _preprocess(self, **kwargs): # pylint: disable=no-self-use
75
72
)
76
73
@kwargs_to_strings (R = "sequence" , p = "sequence" )
77
74
def coast (self , ** kwargs ):
78
- """
79
- Plot continents, shorelines, rivers, and borders on maps
75
+ """Plot continents, shorelines, rivers, and borders on maps.
80
76
81
77
Plots grayshaded, colored, or textured land-masses [or water-masses] on
82
78
maps and [optionally] draws coastlines, rivers, and political
@@ -135,7 +131,6 @@ def coast(self, **kwargs):
135
131
{XY}
136
132
{p}
137
133
{t}
138
-
139
134
"""
140
135
kwargs = self ._preprocess (** kwargs )
141
136
with Session () as lib :
@@ -158,8 +153,7 @@ def coast(self, **kwargs):
158
153
)
159
154
@kwargs_to_strings (R = "sequence" , G = "sequence" , p = "sequence" )
160
155
def colorbar (self , ** kwargs ):
161
- """
162
- Plot a gray or color scale-bar on maps.
156
+ """Plot a gray or color scale-bar on maps.
163
157
164
158
Both horizontal and vertical scales are supported. For CPTs with
165
159
gradational colors (i.e., the lower and upper boundary of an interval
@@ -219,7 +213,6 @@ def colorbar(self, **kwargs):
219
213
{XY}
220
214
{p}
221
215
{t}
222
-
223
216
"""
224
217
kwargs = self ._preprocess (** kwargs )
225
218
with Session () as lib :
@@ -246,8 +239,7 @@ def colorbar(self, **kwargs):
246
239
)
247
240
@kwargs_to_strings (R = "sequence" , L = "sequence" , A = "sequence_plus" , p = "sequence" )
248
241
def grdcontour (self , grid , ** kwargs ):
249
- """
250
- Convert grids or images to contours and plot them on maps
242
+ """Convert grids or images to contours and plot them on maps.
251
243
252
244
Takes a grid file name or an xarray.DataArray object as input.
253
245
@@ -341,8 +333,7 @@ def grdcontour(self, grid, **kwargs):
341
333
)
342
334
@kwargs_to_strings (R = "sequence" , p = "sequence" )
343
335
def grdimage (self , grid , ** kwargs ):
344
- """
345
- Project and plot grids or images.
336
+ """Project and plot grids or images.
346
337
347
338
Reads a 2-D grid file and produces a gray-shaded (or colored) map by
348
339
building a rectangular image and assigning pixels a gray-shade (or
@@ -458,7 +449,6 @@ def grdimage(self, grid, **kwargs):
458
449
{p}
459
450
{t}
460
451
{x}
461
-
462
452
"""
463
453
kwargs = self ._preprocess (** kwargs )
464
454
kind = data_kind (grid , None , None )
@@ -495,8 +485,7 @@ def grdimage(self, grid, **kwargs):
495
485
)
496
486
@kwargs_to_strings (R = "sequence" , p = "sequence" )
497
487
def grdview (self , grid , ** kwargs ):
498
- """
499
- Create 3-D perspective image or surface mesh from a grid.
488
+ """Create 3-D perspective image or surface mesh from a grid.
500
489
501
490
Reads a 2-D grid file and produces a 3-D perspective plot by drawing a
502
491
mesh, painting a colored/gray-shaded surface made up of polygons, or by
@@ -567,7 +556,6 @@ def grdview(self, grid, **kwargs):
567
556
{XY}
568
557
{p}
569
558
{t}
570
-
571
559
"""
572
560
kwargs = self ._preprocess (** kwargs )
573
561
kind = data_kind (grid , None , None )
@@ -614,8 +602,7 @@ def grdview(self, grid, **kwargs):
614
602
)
615
603
@kwargs_to_strings (R = "sequence" , i = "sequence_comma" , p = "sequence" )
616
604
def plot (self , x = None , y = None , data = None , sizes = None , direction = None , ** kwargs ):
617
- """
618
- Plot lines, polygons, and symbols on maps.
605
+ """Plot lines, polygons, and symbols on maps.
619
606
620
607
Used to be psxy.
621
608
@@ -740,8 +727,7 @@ def plot(self, x=None, y=None, data=None, sizes=None, direction=None, **kwargs):
740
727
)
741
728
@kwargs_to_strings (R = "sequence" , i = "sequence_comma" , p = "sequence" )
742
729
def contour (self , x = None , y = None , z = None , data = None , ** kwargs ):
743
- """
744
- Contour table data by direct triangulation.
730
+ """Contour table data by direct triangulation.
745
731
746
732
Takes a matrix, (x,y,z) pairs, or a file name as input and plots lines,
747
733
polygons, or symbols at those locations on a map.
@@ -797,7 +783,6 @@ def contour(self, x=None, y=None, z=None, data=None, **kwargs):
797
783
{XY}
798
784
{p}
799
785
{t}
800
-
801
786
"""
802
787
kwargs = self ._preprocess (** kwargs )
803
788
@@ -834,8 +819,7 @@ def contour(self, x=None, y=None, z=None, data=None, **kwargs):
834
819
)
835
820
@kwargs_to_strings (R = "sequence" , p = "sequence" )
836
821
def basemap (self , ** kwargs ):
837
- """
838
- Produce a basemap for the figure.
822
+ """Produce a basemap for the figure.
839
823
840
824
Several map projections are available, and the user may specify
841
825
separate tick-mark intervals for boundary annotation, ticking, and
@@ -867,7 +851,6 @@ def basemap(self, **kwargs):
867
851
{XY}
868
852
{p}
869
853
{t}
870
-
871
854
"""
872
855
kwargs = self ._preprocess (** kwargs )
873
856
if not ("B" in kwargs or "L" in kwargs or "T" in kwargs ):
@@ -889,8 +872,7 @@ def basemap(self, **kwargs):
889
872
)
890
873
@kwargs_to_strings (R = "sequence" , p = "sequence" )
891
874
def logo (self , ** kwargs ):
892
- """
893
- Place the GMT graphics logo on a map.
875
+ """Place the GMT graphics logo on a map.
894
876
895
877
By default, the GMT logo is 2 inches wide and 1 inch high and
896
878
will be positioned relative to the current plot origin.
@@ -915,7 +897,6 @@ def logo(self, **kwargs):
915
897
{XY}
916
898
{p}
917
899
{t}
918
-
919
900
"""
920
901
kwargs = self ._preprocess (** kwargs )
921
902
if "D" not in kwargs :
@@ -937,8 +918,7 @@ def logo(self, **kwargs):
937
918
)
938
919
@kwargs_to_strings (R = "sequence" , p = "sequence" )
939
920
def image (self , imagefile , ** kwargs ):
940
- """
941
- Place images or EPS files on maps.
921
+ """Place images or EPS files on maps.
942
922
943
923
Reads an Encapsulated PostScript file or a raster image file and plots
944
924
it on a map.
@@ -990,8 +970,7 @@ def image(self, imagefile, **kwargs):
990
970
)
991
971
@kwargs_to_strings (R = "sequence" , p = "sequence" )
992
972
def legend (self , spec = None , position = "JTR+jTR+o0.2c" , box = "+gwhite+p1p" , ** kwargs ):
993
- """
994
- Plot legends on maps.
973
+ """Plot legends on maps.
995
974
996
975
Makes legends that can be overlaid on maps. Reads specific
997
976
legend-related information from an input file, or automatically creates
@@ -1078,8 +1057,7 @@ def text(
1078
1057
justify = None ,
1079
1058
** kwargs ,
1080
1059
):
1081
- """
1082
- Plot or typeset text strings of variable size, font type, and
1060
+ """Plot or typeset text strings of variable size, font type, and
1083
1061
orientation.
1084
1062
1085
1063
Must provide at least one of the following combinations as input:
@@ -1239,8 +1217,7 @@ def meca(
1239
1217
plot_latitude = None ,
1240
1218
** kwargs ,
1241
1219
):
1242
- """
1243
- Plot focal mechanisms.
1220
+ """Plot focal mechanisms.
1244
1221
1245
1222
Full option list at :gmt-docs:`supplements/seis/meca.html`
1246
1223
@@ -1342,8 +1319,8 @@ def set_pointer(data_pointers, spec):
1342
1319
1343
1320
def update_pointers (data_pointers ):
1344
1321
"""Updates variables based on the location of data, as the
1345
- following data can be passed as parameters or it can be
1346
- contained in `spec`."""
1322
+ following data can be passed as parameters or it can be contained
1323
+ in `spec`."""
1347
1324
# update all pointers
1348
1325
longitude = data_pointers ["longitude" ]
1349
1326
latitude = data_pointers ["latitude" ]
0 commit comments