-
Notifications
You must be signed in to change notification settings - Fork 245
Move plotting functions to separate modules #808
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
willschlitzer
merged 37 commits into
GenericMappingTools:master
from
willschlitzer:move-plotting-functions
Feb 7, 2021
Merged
Changes from 29 commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
54ac6de
Move logo function to logo.py
willschlitzer 7c90b77
Remove unused imports in logo.py
willschlitzer 906edd1
Move coast function to coast.py
willschlitzer 63d32b4
Run make format
willschlitzer 0e67300
Move colorbar to colorbar.py
willschlitzer 8a43456
Move grdcontour to grdcontour.py
willschlitzer 5e2e98a
Remove unused import to grdcontour.py
willschlitzer 3e2f32f
Fix doc string for grdcontour.py
willschlitzer 291cef1
Move text function to text.py
willschlitzer e4d20c8
Move legend function to legend.py
willschlitzer fee00b7
Style checks
willschlitzer e409710
Move image function to image.py
willschlitzer 955b894
Removed unused import
willschlitzer eed45d5
Move basemap function to basemap.py
willschlitzer 3521be8
Move contour function to contour.py
willschlitzer 137a03a
Move plot3d function to plot3d.py
willschlitzer 13f0346
Move plot function to plot.py
willschlitzer c5f41ad
Move grdview function to grdview.py
willschlitzer f682831
Move grdimage function to grdimage.py
willschlitzer 55f81f4
Style fix
willschlitzer a3a3e88
Style fix
willschlitzer 2b58016
Remove unused imports from base_plotting.py
willschlitzer b0fc669
Update doc string
willschlitzer 955f548
Merge branch 'master' into move-plotting-functions
willschlitzer cb4a193
Merge branch 'master' into move-plotting-functions
willschlitzer 6e9633a
[format-command] fixes
actions-bot 8f05c42
Merge branch 'master' into move-plotting-functions
weiji14 127b428
Simplify import of plotting modules from src
weiji14 d5f0fc7
Pylint disable protected-access on self._preprocess
weiji14 e1fc158
Merge branch 'master' into move-plotting-functions
willschlitzer ed7ef88
Apply suggestions from code review
willschlitzer 5ac2e07
Delete base_plotting.py and move function imports to figure.py
willschlitzer 175c9ba
Run make format
willschlitzer ddebe30
Merge branch 'master' into move-plotting-functions
willschlitzer bed53e7
Update pygmt/src/text.py
willschlitzer 698b3d1
Add explanation for why the function is named "text_"
willschlitzer 8973d83
Fix style issue
willschlitzer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| """ | ||
| basemap - Plot base maps and frames for the figure. | ||
| """ | ||
|
willschlitzer marked this conversation as resolved.
|
||
|
|
||
| from pygmt.clib import Session | ||
| from pygmt.exceptions import GMTInvalidInput | ||
| from pygmt.helpers import ( | ||
| args_in_kwargs, | ||
| build_arg_string, | ||
| fmt_docstring, | ||
| kwargs_to_strings, | ||
| use_alias, | ||
| ) | ||
|
|
||
|
|
||
| @fmt_docstring | ||
| @use_alias( | ||
| R="region", | ||
| J="projection", | ||
| Jz="zscale", | ||
| JZ="zsize", | ||
| B="frame", | ||
| L="map_scale", | ||
| Td="rose", | ||
| Tm="compass", | ||
| U="timestamp", | ||
| V="verbose", | ||
| X="xshift", | ||
| Y="yshift", | ||
| p="perspective", | ||
| t="transparency", | ||
| ) | ||
| @kwargs_to_strings(R="sequence", p="sequence") | ||
| def basemap(self, **kwargs): | ||
| """ | ||
| Plot base maps and frames for the figure. | ||
|
|
||
| Creates a basic or fancy basemap with axes, fill, and titles. Several | ||
| map projections are available, and the user may specify separate | ||
| tick-mark intervals for boundary annotation, ticking, and [optionally] | ||
| gridlines. A simple map scale or directional rose may also be plotted. | ||
|
|
||
| At least one of the options *frame*, *map_scale*, *rose* or *compass* | ||
| must be specified. | ||
|
|
||
| Full option list at :gmt-docs:`basemap.html` | ||
|
|
||
| {aliases} | ||
|
|
||
| Parameters | ||
| ---------- | ||
| {J} | ||
| zscale/zsize : float or str | ||
| Set z-axis scaling or z-axis size. | ||
| {R} | ||
| {B} | ||
| map_scale : str | ||
| ``'[g|j|J|n|x]refpoint'`` | ||
| Draws a simple map scale centered on the reference point specified. | ||
| rose : str | ||
| Draws a map directional rose on the map at the location defined by | ||
| the reference and anchor points. | ||
| compass : str | ||
| Draws a map magnetic rose on the map at the location defined by the | ||
| reference and anchor points | ||
| {U} | ||
| {V} | ||
| {XY} | ||
| {p} | ||
| {t} | ||
| """ | ||
| kwargs = self._preprocess(**kwargs) # pylint: disable=protected-access | ||
| if not args_in_kwargs(args=["B", "L", "Td", "Tm"], kwargs=kwargs): | ||
| raise GMTInvalidInput( | ||
| "At least one of frame, map_scale, compass, or rose must be specified." | ||
| ) | ||
| with Session() as lib: | ||
| lib.call_module("basemap", build_arg_string(kwargs)) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,196 @@ | ||
| """ | ||
| coast - Plot land and water. | ||
| """ | ||
|
|
||
| from pygmt.clib import Session | ||
| from pygmt.exceptions import GMTInvalidInput | ||
| from pygmt.helpers import ( | ||
| args_in_kwargs, | ||
| build_arg_string, | ||
| fmt_docstring, | ||
| kwargs_to_strings, | ||
| use_alias, | ||
| ) | ||
|
|
||
|
|
||
| @fmt_docstring | ||
| @use_alias( | ||
| R="region", | ||
| J="projection", | ||
| A="area_thresh", | ||
| C="lakes", | ||
| B="frame", | ||
| D="resolution", | ||
| E="dcw", | ||
| I="rivers", | ||
| L="map_scale", | ||
| N="borders", | ||
| W="shorelines", | ||
| G="land", | ||
| S="water", | ||
| U="timestamp", | ||
| V="verbose", | ||
| X="xshift", | ||
| Y="yshift", | ||
| p="perspective", | ||
| t="transparency", | ||
| ) | ||
| @kwargs_to_strings(R="sequence", p="sequence") | ||
| def coast(self, **kwargs): | ||
| r""" | ||
| Plot continents, shorelines, rivers, and borders on maps | ||
|
|
||
| Plots grayshaded, colored, or textured land-masses [or water-masses] on | ||
| maps and [optionally] draws coastlines, rivers, and political | ||
| boundaries. Alternatively, it can (1) issue clip paths that will | ||
| contain all land or all water areas, or (2) dump the data to an ASCII | ||
| table. The data files come in 5 different resolutions: (**f**)ull, | ||
| (**h**)igh, (**i**)ntermediate, (**l**)ow, and (**c**)rude. The full | ||
| resolution files amount to more than 55 Mb of data and provide great | ||
| detail; for maps of larger geographical extent it is more economical to | ||
| use one of the other resolutions. If the user selects to paint the | ||
| land-areas and does not specify fill of water-areas then the latter | ||
| will be transparent (i.e., earlier graphics drawn in those areas will | ||
| not be overwritten). Likewise, if the water-areas are painted and no | ||
| land fill is set then the land-areas will be transparent. | ||
|
|
||
| A map projection must be supplied. | ||
|
|
||
| Full option list at :gmt-docs:`coast.html` | ||
|
|
||
| {aliases} | ||
|
|
||
| Parameters | ||
| ---------- | ||
| {J} | ||
| {R} | ||
| area_thresh : int, float, or str | ||
| *min_area*\ [/*min_level*/*max_level*][**+ag**\|\ **i**\ | ||
| \|\ **s**\|\ **S**][**+r**\|\ **l**][**+p**\ | ||
| *percent*]. | ||
| Features with an area smaller than min_area in km^2 or of | ||
| hierarchical level that is lower than min_level or higher than | ||
| max_level will not be plotted. | ||
| {B} | ||
| lakes : str or list | ||
| *fill*\ [**+l**\|\ **+r**]. | ||
| Set the shade, color, or pattern for lakes and river-lakes. The | ||
| default is the fill chosen for wet areas set by the ``water`` | ||
| argument. Optionally, specify separate fills by appending | ||
| **+l** for lakes or **+r** for river-lakes, and passing multiple | ||
| strings in a list. | ||
| resolution : str | ||
| **f**\|\ **h**\|\ **i**\|\ **l**\|\ **c**. | ||
| Selects the resolution of the data set to: (**f**\ )ull, | ||
| (**h**\ )igh, (**i**\ )ntermediate, (**l**\ )ow, | ||
| and (**c**\ )rude. | ||
| land : str | ||
| Select filling or clipping of “dry” areas. | ||
| rivers : int or str or list | ||
| *river*\ [/*pen*]. | ||
| Draw rivers. Specify the type of rivers and [optionally] append | ||
| pen attributes [Default pen: width = default, color = black, | ||
| style = solid]. | ||
|
|
||
| Choose from the list of river types below; pass a list to | ||
| ``rivers`` to use multiple arguments. | ||
|
|
||
| 0 = Double-lined rivers (river-lakes) | ||
|
|
||
| 1 = Permanent major rivers | ||
|
|
||
| 2 = Additional major rivers | ||
|
|
||
| 3 = Additional rivers | ||
|
|
||
| 4 = Minor rivers | ||
|
|
||
| 5 = Intermittent rivers - major | ||
|
|
||
| 6 = Intermittent rivers - additional | ||
|
|
||
| 7 = Intermittent rivers - minor | ||
|
|
||
| 8 = Major canals | ||
|
|
||
| 9 = Minor canals | ||
|
|
||
| 10 = Irrigation canals | ||
|
|
||
| You can also choose from several preconfigured river groups: | ||
|
|
||
| a = All rivers and canals (0-10) | ||
|
|
||
| A = All rivers and canals except river-lakes (1-10) | ||
|
|
||
| r = All permanent rivers (0-4) | ||
|
|
||
| R = All permanent rivers except river-lakes (1-4) | ||
|
|
||
| i = All intermittent rivers (5-7) | ||
|
|
||
| c = All canals (8-10) | ||
| map_scale : str | ||
| [**g**\|\ **j**\|\ **J**\|\ **n**\|\ **x**]\ *refpoint*. | ||
| Draws a simple map scale centered on the reference point specified. | ||
| borders : int or str or list | ||
| *border*\ [/*pen*]. | ||
| Draw political boundaries. Specify the type of boundary and | ||
| [optionally] append pen attributes [Default pen: width = default, | ||
| color = black, style = solid]. | ||
|
|
||
| Choose from the list of boundaries below. Pass a list to | ||
| ``borders`` to use multiple arguments. | ||
|
|
||
| 1 = National boundaries | ||
|
|
||
| 2 = State boundaries within the Americas | ||
|
|
||
| 3 = Marine boundaries | ||
|
|
||
| a = All boundaries (1-3) | ||
| water : str | ||
| Select filling or clipping of “wet” areas. | ||
| {U} | ||
| shorelines : int or str or list | ||
| [*level*\ /]\ *pen*. | ||
| Draw shorelines [Default is no shorelines]. Append pen attributes | ||
| [Defaults: width = default, color = black, style = solid] which | ||
| apply to all four levels. To set the pen for a single level, | ||
| pass a string with *level*\ /*pen*\ , where level is | ||
| 1-4 and represent coastline, lakeshore, island-in-lake shore, and | ||
| lake-in-island-in-lake shore. Pass a list of *level*\ /*pen* | ||
| strings to ``shorelines`` to set multiple levels. When specific | ||
| level pens are set, those not listed will not be drawn. | ||
| dcw : str or list | ||
| *code1,code2,…*\ [**+l**\|\ **L**\ ][**+g**\ *fill*\ ] | ||
| [**+p**\ *pen*\ ][**+z**]. | ||
| Select painting or dumping country polygons from the | ||
| `Digital Chart of the World | ||
| <https://en.wikipedia.org/wiki/Digital_Chart_of_the_World>`__. | ||
| Append one or more comma-separated countries using the 2-character | ||
| `ISO 3166-1 alpha-2 convention | ||
| <https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2>`__. | ||
| To select a state of a country (if available), append | ||
| .\ *state*, (e.g, US.TX for Texas). To specify a whole continent, | ||
| prepend **=** to any of the continent codes (e.g. =EU for Europe). | ||
| Append **+p**\ *pen* to draw polygon outlines | ||
| (default is no outline) and **+g**\ *fill* to fill them | ||
| (default is no fill). Append **+l**\|\ **+L** to *=continent* to | ||
| only list countries in that continent; repeat if more than one | ||
| continent is requested. Append **+z** to place the country code in | ||
| the segment headers via **-Z**\ *code* settings.To apply different | ||
| settings to different countries, pass a list of string arguments. | ||
| {XY} | ||
| {p} | ||
| {t} | ||
| {V} | ||
| """ | ||
| kwargs = self._preprocess(**kwargs) # pylint: disable=protected-access | ||
| if not args_in_kwargs(args=["C", "G", "S", "I", "N", "Q", "W"], kwargs=kwargs): | ||
| raise GMTInvalidInput( | ||
| """At least one of the following arguments must be specified: | ||
| lakes, land, water, rivers, borders, Q, or shorelines""" | ||
| ) | ||
| with Session() as lib: | ||
| lib.call_module("coast", build_arg_string(kwargs)) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.