1- """
2- Base class with plot generating commands.
1+ """Base class with plot generating commands.
2+
33Does not define any special non-GMT methods (savefig, show, etc).
44"""
55import contextlib
1919
2020
2121class BasePlotting :
22- """
23- Base class for Figure and Subplot.
22+ """Base class for Figure and Subplot.
2423
2524 Defines the plot generating methods and a hook for subclasses to insert
2625 special arguments (the _preprocess method).
2726 """
2827
2928 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.
3230
3331 This method is run before all plotting commands and can be used to
3432 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
5048 >>> base = BasePlotting()
5149 >>> base._preprocess(resolution="low")
5250 {'resolution': 'low'}
53-
5451 """
5552 return kwargs
5653
@@ -75,8 +72,7 @@ def _preprocess(self, **kwargs): # pylint: disable=no-self-use
7572 )
7673 @kwargs_to_strings (R = "sequence" , p = "sequence" )
7774 def coast (self , ** kwargs ):
78- """
79- Plot continents, shorelines, rivers, and borders on maps
75+ """Plot continents, shorelines, rivers, and borders on maps.
8076
8177 Plots grayshaded, colored, or textured land-masses [or water-masses] on
8278 maps and [optionally] draws coastlines, rivers, and political
@@ -135,7 +131,6 @@ def coast(self, **kwargs):
135131 {XY}
136132 {p}
137133 {t}
138-
139134 """
140135 kwargs = self ._preprocess (** kwargs )
141136 with Session () as lib :
@@ -158,8 +153,7 @@ def coast(self, **kwargs):
158153 )
159154 @kwargs_to_strings (R = "sequence" , G = "sequence" , p = "sequence" )
160155 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.
163157
164158 Both horizontal and vertical scales are supported. For CPTs with
165159 gradational colors (i.e., the lower and upper boundary of an interval
@@ -219,7 +213,6 @@ def colorbar(self, **kwargs):
219213 {XY}
220214 {p}
221215 {t}
222-
223216 """
224217 kwargs = self ._preprocess (** kwargs )
225218 with Session () as lib :
@@ -246,8 +239,7 @@ def colorbar(self, **kwargs):
246239 )
247240 @kwargs_to_strings (R = "sequence" , L = "sequence" , A = "sequence_plus" , p = "sequence" )
248241 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.
251243
252244 Takes a grid file name or an xarray.DataArray object as input.
253245
@@ -341,8 +333,7 @@ def grdcontour(self, grid, **kwargs):
341333 )
342334 @kwargs_to_strings (R = "sequence" , p = "sequence" )
343335 def grdimage (self , grid , ** kwargs ):
344- """
345- Project and plot grids or images.
336+ """Project and plot grids or images.
346337
347338 Reads a 2-D grid file and produces a gray-shaded (or colored) map by
348339 building a rectangular image and assigning pixels a gray-shade (or
@@ -458,7 +449,6 @@ def grdimage(self, grid, **kwargs):
458449 {p}
459450 {t}
460451 {x}
461-
462452 """
463453 kwargs = self ._preprocess (** kwargs )
464454 kind = data_kind (grid , None , None )
@@ -495,8 +485,7 @@ def grdimage(self, grid, **kwargs):
495485 )
496486 @kwargs_to_strings (R = "sequence" , p = "sequence" )
497487 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.
500489
501490 Reads a 2-D grid file and produces a 3-D perspective plot by drawing a
502491 mesh, painting a colored/gray-shaded surface made up of polygons, or by
@@ -567,7 +556,6 @@ def grdview(self, grid, **kwargs):
567556 {XY}
568557 {p}
569558 {t}
570-
571559 """
572560 kwargs = self ._preprocess (** kwargs )
573561 kind = data_kind (grid , None , None )
@@ -614,8 +602,7 @@ def grdview(self, grid, **kwargs):
614602 )
615603 @kwargs_to_strings (R = "sequence" , i = "sequence_comma" , p = "sequence" )
616604 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.
619606
620607 Used to be psxy.
621608
@@ -740,8 +727,7 @@ def plot(self, x=None, y=None, data=None, sizes=None, direction=None, **kwargs):
740727 )
741728 @kwargs_to_strings (R = "sequence" , i = "sequence_comma" , p = "sequence" )
742729 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.
745731
746732 Takes a matrix, (x,y,z) pairs, or a file name as input and plots lines,
747733 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):
797783 {XY}
798784 {p}
799785 {t}
800-
801786 """
802787 kwargs = self ._preprocess (** kwargs )
803788
@@ -834,8 +819,7 @@ def contour(self, x=None, y=None, z=None, data=None, **kwargs):
834819 )
835820 @kwargs_to_strings (R = "sequence" , p = "sequence" )
836821 def basemap (self , ** kwargs ):
837- """
838- Produce a basemap for the figure.
822+ """Produce a basemap for the figure.
839823
840824 Several map projections are available, and the user may specify
841825 separate tick-mark intervals for boundary annotation, ticking, and
@@ -867,7 +851,6 @@ def basemap(self, **kwargs):
867851 {XY}
868852 {p}
869853 {t}
870-
871854 """
872855 kwargs = self ._preprocess (** kwargs )
873856 if not ("B" in kwargs or "L" in kwargs or "T" in kwargs ):
@@ -889,8 +872,7 @@ def basemap(self, **kwargs):
889872 )
890873 @kwargs_to_strings (R = "sequence" , p = "sequence" )
891874 def logo (self , ** kwargs ):
892- """
893- Place the GMT graphics logo on a map.
875+ """Place the GMT graphics logo on a map.
894876
895877 By default, the GMT logo is 2 inches wide and 1 inch high and
896878 will be positioned relative to the current plot origin.
@@ -915,7 +897,6 @@ def logo(self, **kwargs):
915897 {XY}
916898 {p}
917899 {t}
918-
919900 """
920901 kwargs = self ._preprocess (** kwargs )
921902 if "D" not in kwargs :
@@ -937,8 +918,7 @@ def logo(self, **kwargs):
937918 )
938919 @kwargs_to_strings (R = "sequence" , p = "sequence" )
939920 def image (self , imagefile , ** kwargs ):
940- """
941- Place images or EPS files on maps.
921+ """Place images or EPS files on maps.
942922
943923 Reads an Encapsulated PostScript file or a raster image file and plots
944924 it on a map.
@@ -990,8 +970,7 @@ def image(self, imagefile, **kwargs):
990970 )
991971 @kwargs_to_strings (R = "sequence" , p = "sequence" )
992972 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.
995974
996975 Makes legends that can be overlaid on maps. Reads specific
997976 legend-related information from an input file, or automatically creates
@@ -1078,8 +1057,7 @@ def text(
10781057 justify = None ,
10791058 ** kwargs ,
10801059 ):
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
10831061 orientation.
10841062
10851063 Must provide at least one of the following combinations as input:
@@ -1239,8 +1217,7 @@ def meca(
12391217 plot_latitude = None ,
12401218 ** kwargs ,
12411219 ):
1242- """
1243- Plot focal mechanisms.
1220+ """Plot focal mechanisms.
12441221
12451222 Full option list at :gmt-docs:`supplements/seis/meca.html`
12461223
@@ -1342,8 +1319,8 @@ def set_pointer(data_pointers, spec):
13421319
13431320 def update_pointers (data_pointers ):
13441321 """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`."""
13471324 # update all pointers
13481325 longitude = data_pointers ["longitude" ]
13491326 latitude = data_pointers ["latitude" ]
0 commit comments