From ef9ecaf4623405db895fdbd64a2a3aa440492f8a Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sun, 5 Mar 2023 12:23:30 +0100 Subject: [PATCH 01/12] Add seperator lines --- examples/gallery/embellishments/colorbar.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/examples/gallery/embellishments/colorbar.py b/examples/gallery/embellishments/colorbar.py index 25844a6d97b..a5a0260bbd4 100644 --- a/examples/gallery/embellishments/colorbar.py +++ b/examples/gallery/embellishments/colorbar.py @@ -26,10 +26,12 @@ fig = pygmt.Figure() fig.basemap(region=[0, 3, 6, 9], projection="x3c", frame=["af", "WSne+tColorbars"]) +# ============ # Create a colorbar designed for seismic tomography - roma # Colorbar is placed at bottom center (BC) by default if no position is given fig.colorbar(cmap="roma", frame=["x+lVelocity", "y+lm/s"]) +# ============ # Create a colorbar showing the scientific rainbow - batlow fig.colorbar( cmap="batlow", @@ -41,6 +43,7 @@ scale=100, ) +# ============ # Create a colorbar suitable for surface topography - oleron fig.colorbar( cmap="oleron", From 35d8add2c44aad3f5f95033d8d3ffb0c82f9b0bf Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sun, 5 Mar 2023 12:25:56 +0100 Subject: [PATCH 02/12] Add code for colorbar suitable for categorical data --- examples/gallery/embellishments/colorbar.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/examples/gallery/embellishments/colorbar.py b/examples/gallery/embellishments/colorbar.py index a5a0260bbd4..650e7d9922b 100644 --- a/examples/gallery/embellishments/colorbar.py +++ b/examples/gallery/embellishments/colorbar.py @@ -58,4 +58,25 @@ scale=10, ) +# ============ +# Create a colorbar suitable for categorical data - hawaii +# Set up the colormap +pygmt.makecpt( + cmap="hawaii", + series=[0, 3, 1], + # comma-spearted string later used as annotations of the colorbar + color_model="+cclass A,class B,class C,class D", +) +# Plot the colorbar +fig.colorbar( + cmap=True, # use colormap set up above + # Colorbar position justified inside map frame (j) at Bottom Left (BL), + # offset (+o) by 0.5 cm horizontally and 0.8 cm vertically from anchor + # point, and plotted horizontally (+h) + position="jBL+o0.5c/0.8c+h", + box=True, + # Separate colorbar into equal-sized rectangles + equalsize=0.5, +) + fig.show() From f54ee8e77628d2d85b112bfa9609b2f0de5e31cf Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sun, 5 Mar 2023 12:39:50 +0100 Subject: [PATCH 03/12] Fix typos (own) --- examples/gallery/embellishments/colorbar.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/gallery/embellishments/colorbar.py b/examples/gallery/embellishments/colorbar.py index 650e7d9922b..046c975e6dc 100644 --- a/examples/gallery/embellishments/colorbar.py +++ b/examples/gallery/embellishments/colorbar.py @@ -64,12 +64,12 @@ pygmt.makecpt( cmap="hawaii", series=[0, 3, 1], - # comma-spearted string later used as annotations of the colorbar + # Comma-separated string for the annotations of the colorbar color_model="+cclass A,class B,class C,class D", ) # Plot the colorbar fig.colorbar( - cmap=True, # use colormap set up above + cmap=True, # Use colormap set up above # Colorbar position justified inside map frame (j) at Bottom Left (BL), # offset (+o) by 0.5 cm horizontally and 0.8 cm vertically from anchor # point, and plotted horizontally (+h) From 1ce0870a2a95061b5e7cdb89c6b608dc7fd66554 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sun, 5 Mar 2023 13:34:03 +0100 Subject: [PATCH 04/12] Add blank line --- examples/gallery/embellishments/colorbar.py | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/gallery/embellishments/colorbar.py b/examples/gallery/embellishments/colorbar.py index 046c975e6dc..acb0f77e09a 100644 --- a/examples/gallery/embellishments/colorbar.py +++ b/examples/gallery/embellishments/colorbar.py @@ -21,6 +21,7 @@ Note that the anchor point defaults to the bottom left (**BL**). Append ``+h`` to ``position`` to get a horizontal colorbar instead of a vertical one. """ + import pygmt fig = pygmt.Figure() From a19d21c03ad28e306b405d4a1b7fafbbe4fc6347 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sun, 5 Mar 2023 19:54:34 +0100 Subject: [PATCH 05/12] Improve formulation --- examples/gallery/embellishments/colorbar.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/gallery/embellishments/colorbar.py b/examples/gallery/embellishments/colorbar.py index acb0f77e09a..5ba7ba7f837 100644 --- a/examples/gallery/embellishments/colorbar.py +++ b/examples/gallery/embellishments/colorbar.py @@ -76,7 +76,7 @@ # point, and plotted horizontally (+h) position="jBL+o0.5c/0.8c+h", box=True, - # Separate colorbar into equal-sized rectangles + # Divide colorbar into equal-sized rectangles equalsize=0.5, ) From f0f6e67d0294bf84f40dde2e800a758c89d76de8 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sun, 5 Mar 2023 19:58:02 +0100 Subject: [PATCH 06/12] Change 'map' to 'figure' --- examples/gallery/embellishments/colorbar.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/gallery/embellishments/colorbar.py b/examples/gallery/embellishments/colorbar.py index 5ba7ba7f837..f196794752c 100644 --- a/examples/gallery/embellishments/colorbar.py +++ b/examples/gallery/embellishments/colorbar.py @@ -8,7 +8,7 @@ can be found at :gmt-docs:`cookbook/cpts.html`. You can set the ``position`` of the colorbar using the following options: -- **j/J**: justified inside/outside the map frame using any 2-character +- **j/J**: justified inside/outside the figure frame using any 2-character combination of vertical (**T**\ op, **M**\ iddle, **B**\ ottom) and horizontal (**L**\ eft, **C**\ enter, **R**\ ight) alignment codes, e.g. ``position="jTR"`` for top right. @@ -48,7 +48,7 @@ # Create a colorbar suitable for surface topography - oleron fig.colorbar( cmap="oleron", - # Colorbar position justified outside map frame (J) at Middle Right (MR), + # Colorbar position justified outside figure frame (J) at Middle Right (MR), # offset (+o) by 1 cm horizontally and 0 cm vertically from anchor point, # with a length/width (+w) of 7 cm by 0.5 cm and a box for NaN values (+n) position="JMR+o1c/0c+w7c/0.5c+n+mc", @@ -71,7 +71,7 @@ # Plot the colorbar fig.colorbar( cmap=True, # Use colormap set up above - # Colorbar position justified inside map frame (j) at Bottom Left (BL), + # Colorbar position justified inside figure frame (j) at Bottom Left (BL), # offset (+o) by 0.5 cm horizontally and 0.8 cm vertically from anchor # point, and plotted horizontally (+h) position="jBL+o0.5c/0.8c+h", From 1429ade7988ea55b5705b319505f2a9f44f74d42 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sun, 5 Mar 2023 20:08:44 +0100 Subject: [PATCH 07/12] Fix line length --- examples/gallery/embellishments/colorbar.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/examples/gallery/embellishments/colorbar.py b/examples/gallery/embellishments/colorbar.py index f196794752c..c4a5f69943e 100644 --- a/examples/gallery/embellishments/colorbar.py +++ b/examples/gallery/embellishments/colorbar.py @@ -48,9 +48,10 @@ # Create a colorbar suitable for surface topography - oleron fig.colorbar( cmap="oleron", - # Colorbar position justified outside figure frame (J) at Middle Right (MR), - # offset (+o) by 1 cm horizontally and 0 cm vertically from anchor point, - # with a length/width (+w) of 7 cm by 0.5 cm and a box for NaN values (+n) + # Colorbar position justified outside figure frame (J) at Middle Right + # (MR), offset (+o) by 1 cm horizontally and 0 cm vertically from anchor + # point, with a length/width (+w) of 7 cm by 0.5 cm and a box for NaN + # values (+n) position="JMR+o1c/0c+w7c/0.5c+n+mc", # Note that the label 'Elevation' is moved to the opposite side and plotted # vertically as a column of text using '+mc' in the position parameter From 9f455ffa497fe2e89c0d4dae388d6c9856d2bac8 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Thu, 9 Mar 2023 16:20:33 +0100 Subject: [PATCH 08/12] Improve docs --- examples/gallery/embellishments/colorbar.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/examples/gallery/embellishments/colorbar.py b/examples/gallery/embellishments/colorbar.py index c4a5f69943e..856921d7bf8 100644 --- a/examples/gallery/embellishments/colorbar.py +++ b/examples/gallery/embellishments/colorbar.py @@ -8,10 +8,10 @@ can be found at :gmt-docs:`cookbook/cpts.html`. You can set the ``position`` of the colorbar using the following options: -- **j/J**: justified inside/outside the figure frame using any 2-character +- **j/J**: placed inside/outside the figure frame using a 2-character combination of vertical (**T**\ op, **M**\ iddle, **B**\ ottom) and horizontal (**L**\ eft, **C**\ enter, **R**\ ight) alignment codes, e.g. - ``position="jTR"`` for top right. + ``position="jTR"`` for Top Right. - **g**: using map coordinates, e.g. ``position="g170/-45"`` for longitude 170E, latitude 45S. - **x**: using paper coordinates, e.g. ``position="x5c/7c"`` for 5 cm, 7 cm @@ -48,10 +48,9 @@ # Create a colorbar suitable for surface topography - oleron fig.colorbar( cmap="oleron", - # Colorbar position justified outside figure frame (J) at Middle Right - # (MR), offset (+o) by 1 cm horizontally and 0 cm vertically from anchor - # point, with a length/width (+w) of 7 cm by 0.5 cm and a box for NaN - # values (+n) + # Colorbar placed outside figure frame (J) at Middle Right (MR), + # offset (+o) by 1 cm horizontally and 0 cm vertically from anchor point, + # with a length/width (+w) of 7 cm by 0.5 cm and a box for NaN values (+n) position="JMR+o1c/0c+w7c/0.5c+n+mc", # Note that the label 'Elevation' is moved to the opposite side and plotted # vertically as a column of text using '+mc' in the position parameter @@ -72,9 +71,9 @@ # Plot the colorbar fig.colorbar( cmap=True, # Use colormap set up above - # Colorbar position justified inside figure frame (j) at Bottom Left (BL), - # offset (+o) by 0.5 cm horizontally and 0.8 cm vertically from anchor - # point, and plotted horizontally (+h) + # Colorbar placed inside figure frame (j) at Bottom Left (BL), + # offset (+o) by 0.5 cm horizontally and 0.8 cm vertically from anchor point, + # and plotted horizontally (+h) position="jBL+o0.5c/0.8c+h", box=True, # Divide colorbar into equal-sized rectangles From 5ebcdb28f83739bf048d3604013b4d17b66f0f49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Thu, 9 Mar 2023 16:24:34 +0100 Subject: [PATCH 09/12] Simplify colorbar annotations (code review) Co-authored-by: Michael Grund <23025878+michaelgrund@users.noreply.github.com> --- examples/gallery/embellishments/colorbar.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/gallery/embellishments/colorbar.py b/examples/gallery/embellishments/colorbar.py index 856921d7bf8..8bbc02b03ef 100644 --- a/examples/gallery/embellishments/colorbar.py +++ b/examples/gallery/embellishments/colorbar.py @@ -66,7 +66,7 @@ cmap="hawaii", series=[0, 3, 1], # Comma-separated string for the annotations of the colorbar - color_model="+cclass A,class B,class C,class D", + color_model="+cA,B,C,D", ) # Plot the colorbar fig.colorbar( From e409be56f3b4f0ff68ad12a115045fcc9e6c1e1a Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Thu, 9 Mar 2023 16:27:13 +0100 Subject: [PATCH 10/12] Fix line length --- examples/gallery/embellishments/colorbar.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/gallery/embellishments/colorbar.py b/examples/gallery/embellishments/colorbar.py index 8bbc02b03ef..bdaca813c06 100644 --- a/examples/gallery/embellishments/colorbar.py +++ b/examples/gallery/embellishments/colorbar.py @@ -72,8 +72,8 @@ fig.colorbar( cmap=True, # Use colormap set up above # Colorbar placed inside figure frame (j) at Bottom Left (BL), - # offset (+o) by 0.5 cm horizontally and 0.8 cm vertically from anchor point, - # and plotted horizontally (+h) + # offset (+o) by 0.5 cm horizontally and 0.8 cm vertically from anchor + # point, and plotted horizontally (+h) position="jBL+o0.5c/0.8c+h", box=True, # Divide colorbar into equal-sized rectangles From 11002609c12dcb66a7ce225711f5fb313deea377 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Thu, 9 Mar 2023 17:42:27 +0100 Subject: [PATCH 11/12] Revert change (code review) --- examples/gallery/embellishments/colorbar.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/gallery/embellishments/colorbar.py b/examples/gallery/embellishments/colorbar.py index bdaca813c06..fd203234b83 100644 --- a/examples/gallery/embellishments/colorbar.py +++ b/examples/gallery/embellishments/colorbar.py @@ -8,7 +8,7 @@ can be found at :gmt-docs:`cookbook/cpts.html`. You can set the ``position`` of the colorbar using the following options: -- **j/J**: placed inside/outside the figure frame using a 2-character +- **j/J**: placed inside/outside the figure frame using any 2-character combination of vertical (**T**\ op, **M**\ iddle, **B**\ ottom) and horizontal (**L**\ eft, **C**\ enter, **R**\ ight) alignment codes, e.g. ``position="jTR"`` for Top Right. From 29a7bb76eed7636ee74d126f54327be04d0040f1 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Thu, 9 Mar 2023 17:52:29 +0100 Subject: [PATCH 12/12] Change 'figure' to 'map' (code review) --- examples/gallery/embellishments/colorbar.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/gallery/embellishments/colorbar.py b/examples/gallery/embellishments/colorbar.py index fd203234b83..ebb7893a14d 100644 --- a/examples/gallery/embellishments/colorbar.py +++ b/examples/gallery/embellishments/colorbar.py @@ -8,7 +8,7 @@ can be found at :gmt-docs:`cookbook/cpts.html`. You can set the ``position`` of the colorbar using the following options: -- **j/J**: placed inside/outside the figure frame using any 2-character +- **j/J**: placed inside/outside the map frame using any 2-character combination of vertical (**T**\ op, **M**\ iddle, **B**\ ottom) and horizontal (**L**\ eft, **C**\ enter, **R**\ ight) alignment codes, e.g. ``position="jTR"`` for Top Right. @@ -48,7 +48,7 @@ # Create a colorbar suitable for surface topography - oleron fig.colorbar( cmap="oleron", - # Colorbar placed outside figure frame (J) at Middle Right (MR), + # Colorbar placed outside map frame (J) at Middle Right (MR), # offset (+o) by 1 cm horizontally and 0 cm vertically from anchor point, # with a length/width (+w) of 7 cm by 0.5 cm and a box for NaN values (+n) position="JMR+o1c/0c+w7c/0.5c+n+mc", @@ -71,7 +71,7 @@ # Plot the colorbar fig.colorbar( cmap=True, # Use colormap set up above - # Colorbar placed inside figure frame (j) at Bottom Left (BL), + # Colorbar placed inside map frame (j) at Bottom Left (BL), # offset (+o) by 0.5 cm horizontally and 0.8 cm vertically from anchor # point, and plotted horizontally (+h) position="jBL+o0.5c/0.8c+h",