Skip to content

Commit bbbcf83

Browse files
author
Meghan Jones
authored
Add toggle-buttons showing source scripts to cookbook (#4942)
1 parent 6cca7c1 commit bbbcf83

13 files changed

+385
-1
lines changed

doc/rst/_extensions/sphinx_togglebutton/_static/togglebutton.css_t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ button.toggle-button {
6464
content: "{{ togglebutton_hint }}";
6565
position: absolute;
6666
font-size: .8em;
67-
left: -6.5em;
67+
left: -13.5em;
6868
bottom: .4em;
6969
}
7070
}

doc/rst/conf.py.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ smartquotes_action = 'qe'
2121
highlight_language = 'bash'
2222
pygments_style = 'sphinx'
2323
autosectionlabel_prefix_document = True
24+
togglebutton_hint = "Click to show example script"
2425

2526
# Disable sphinx_panels extension for manpage build
2627
if tags.has("nosphinxpanels"):

doc/rst/source/cookbook/colorspace.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,11 @@ terribly wrong when you do the interpolation in the other system.
234234
palette should be interpolated in HSV, since only hue should change between magenta (300) and red (0).
235235
Diamonds indicate which colors are defined in the palettes; they are fixed, the rest is interpolated.
236236

237+
.. toggle::
238+
239+
Here is the source script for the figure above:
240+
241+
.. literalinclude:: /_verbatim/GMT_color_interpolate.txt
237242

238243
Artificial illumination
239244
-----------------------
@@ -255,6 +260,12 @@ Artificial illumination
255260
vectors and normalizes the intensities to yield suitable shading; see :doc:`/grdgradient`
256261
for more details.
257262

263+
.. toggle::
264+
265+
Here is the source script for the figure above:
266+
267+
.. literalinclude:: /_verbatim/GMT_slope2intensity.txt
268+
258269
GMT uses the HSV system to achieve artificial illumination of colored
259270
images (e.g., **-I** option in :doc:`/grdimage`) by changing the saturation
260271
*s* and value *v* coordinates of the color. As explained above, when the *intensity* is zero
@@ -292,6 +303,12 @@ obvious in RGB.
292303
coordinates are given by (:term:`COLOR_HSV_MIN_S`, :term:`COLOR_HSV_MIN_V`) [1, 0.3]
293304
and (:term:`COLOR_HSV_MAX_S`, :term:`COLOR_HSV_MAX_V`) [0.1, 1].
294305

306+
.. toggle::
307+
308+
Here is the source script for the figure above:
309+
310+
.. literalinclude:: /_verbatim/GMT_color_hsv.txt
311+
295312
Thinking in RGB or HSV
296313
----------------------
297314

@@ -341,6 +358,12 @@ achieved using *c/m/y/k* quadruplets.
341358
and painted with a specific black ink instead, leading to under-color
342359
removal of the remaining three pigments.
343360

361+
.. toggle::
362+
363+
Here is the source script for the figure above:
364+
365+
.. literalinclude:: /_verbatim/GMT_cmyk.txt
366+
344367
Obviously, there is no unique way to go from the 3-dimensional RGB
345368
system to the 4-dimensional CMYK system. So, again, there is a lot of
346369
hand waving applied in the transformation. Strikingly, CMYK actually

doc/rst/source/cookbook/cpts.rst

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ Default ranges, if available, are indicated on the top-right of the scales.
2828

2929
The standard 44 CPTs supported by GMT.
3030

31+
.. toggle::
32+
33+
Here is the source script for the figure above:
34+
35+
.. literalinclude:: /_verbatim/GMT_App_M_1a.txt
36+
3137
.. _CPT_files_b:
3238

3339
.. figure:: /_images/GMT_App_M_1b.*
@@ -36,6 +42,12 @@ Default ranges, if available, are indicated on the top-right of the scales.
3642

3743
The 30 scientific color maps by Fabio Crameri supported by GMT.
3844

45+
.. toggle::
46+
47+
Here is the source script for the figure above:
48+
49+
.. literalinclude:: /_verbatim/GMT_App_M_1b.txt
50+
3951
.. _CPT_files_c:
4052

4153
.. figure:: /_images/GMT_App_M_1c.*
@@ -45,6 +57,11 @@ Default ranges, if available, are indicated on the top-right of the scales.
4557
The 18 categorical CPTs (those ending in "S" are the categorical
4658
scientific color maps by Fabio Crameri) supported by GMT.
4759

60+
.. toggle::
61+
62+
Here is the source script for the figure above:
63+
64+
.. literalinclude:: /_verbatim/GMT_App_M_1c.txt
4865

4966
.. _CPT_files_d:
5067

@@ -56,6 +73,12 @@ Default ranges, if available, are indicated on the top-right of the scales.
5673
**Note**: Any GMT CPT can be made cyclic by running :doc:`/makecpt`
5774
with the **-Ww** option (wrapped = cyclic).
5875

76+
.. toggle::
77+
78+
Here is the source script for the figure above:
79+
80+
.. literalinclude:: /_verbatim/GMT_App_M_1d.txt
81+
5982
For additional color tables, visit
6083
`cpt-city <http://soliton.vm.bytemark.co.uk/pub/cpt-city/>`_ and
6184
`Scientific Colour-Maps <http://www.fabiocrameri.ch/colourmaps.php>`_.
@@ -83,3 +106,10 @@ and how to switch the color bar around (by using a negative length).
83106
.. figure:: /_images/GMT_App_M_2.*
84107
:width: 600 px
85108
:align: center
109+
110+
111+
.. toggle::
112+
113+
Here is the source script for the figure above:
114+
115+
.. literalinclude:: /_verbatim/GMT_App_M_2.txt

doc/rst/source/cookbook/custom-symbols.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ Several custom symbol definitions comes included with GMT (see Figure :ref:`Cust
3434
Be aware that some symbols may have a hardwired fill or no-fill component,
3535
while others duplicate what is already available as standard built-in symbols.
3636

37+
.. toggle::
38+
39+
Here is the source script for the figure above:
40+
41+
.. literalinclude:: /_verbatim/GMT_App_N_1.txt
3742

3843
You may find it convenient to examine some of these and use them as a
3944
starting point for your own design; they can be found in GMT's

doc/rst/source/cookbook/data-filtering.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ diametrical cross-section through the filter weights
3838

3939
Impulse responses for GMT filters.
4040

41+
.. toggle::
42+
43+
Here is the source script for the figure above:
44+
45+
.. literalinclude:: /_verbatim/GMT_App_J_1.txt
4146

4247
Although the impulse responses look the same in 1-D and 2-D, this is not
4348
true of the transfer functions; in 1-D the transfer function is the
@@ -64,6 +69,11 @@ they require more work (doubling the width to achieve the same cut-off wavelengt
6469

6570
Transfer functions for 1-D GMT filters.
6671

72+
.. toggle::
73+
74+
Here is the source script for the figure above:
75+
76+
.. literalinclude:: /_verbatim/GMT_App_J_2.txt
6777

6878
One of the nice things about the gaussian filter is that its transfer
6979
functions are the same in 1-D and 2-D. Another nice property is that it
@@ -83,6 +93,12 @@ the wavelength at which the transfer function equals 0.5 is about 5.34
8393

8494
Transfer functions for 2-D (radial) GMT filters.
8595

96+
.. toggle::
97+
98+
Here is the source script for the figure above:
99+
100+
.. literalinclude:: /_verbatim/GMT_App_J_3.txt
101+
86102
Footnote
87103
--------
88104

0 commit comments

Comments
 (0)