**4.20 Puysegur Trench**

PsT (Fig. 4.21.1, B: middle plot) has asymmetric V-form with steep gradient on the E slopes and more gentle slope on the W. Hjort Trench has a classic symmetric shape form with comparative gradients on both W and E slopes (Fig. 4.21.1, C, lower plot). The results of the comparison of the median values (red line on Fig. 4.21.1 for all the three sub-plots) of three trenches show that selected segment of the HT has shallower depths with maximal not exceeding - 2,500 m (Fig. 4.21.1, A), while PsT is reaching up to -6,000 m (Fig. 4.21.1, B).

<figure><img src="image_207.png" /><figcaption>Map 4.20.1: Puysegur and Hjort trenches, Macquarie Island Arc: Digitizing cross-section profiles</figcaption></figure>

The surrounding relief of the Hjort Trench presents the most uneven terrain comparing to the other trenches with the deepest values >6,000 m (Fig. 4.21.1, C). The neighboring terrain has a gentle slope on the oceanward side for HT and a steep slope on the E flank for PsT, surrounded by complex submarine relief along the Macquarie Arc (Fig. 2.20.1). PsT (Fig. 4.20.1, A) has a bimodal type of data distribution with two peaks. The first peak has three notable bins range -4,200 to -4,400 m (373 samples detected, data frequency 18%), range -4,000 to -4,200 (182 samples, data frequency 9,6%) and -4,400 m to -4,600
m (216 samples, data frequency 11,5%). The second peak covers depths from -2,200 to -3,000 m with the data frequency below 7,5%. The peak corresponds to the Macquarie Arc bordering the trench slope.

<figure><img src="image_208.png" /><figcaption>**Figure 4.20.1:** Comparative analysis on data distribution by Hikurangi, Puysegur and Hjort trenches</figcaption></figure>

Hjort Trench (Fig. 4.20.1, C) has a classic bell-shape form with a clear peak of data at depths -3,200 to -3,400 m. (364 samples, 30% of data frequency). The abrupt decrease in sample values off both flanks corresponds to the steep slope of the trench W off Hjort Plateau. Spreading fabrics are eastwards off PsT, with minor ridges (Fig. 2.19.2). This geomorphology is particularly well expressed along Macquarie Arc, between 51,5° and 54° with ridges formed due to the sedimentation processes. The ridges resembling elongated seamounts are on the NW side off PsT interspersed with minor troughs (Fig. 2.19.2). The average depth of the seafloor deepens abruptly (Fig. 4.21.1, A) from -5,400 (216 samples) to the -6,200 m (9 samples). Data distribution has a clear bimodal way for PsT with peaks at ranges -4,200 to -4,400 (373 samples) and at -3,200 to -3,000 m (140 samples). The histogram for Hjort Trench has a classic bell-shape form with one peak in data distribution at range -3,300 to -3,500 m (364 samples), Fig. 4.21.1, C.
**4.21 Hikurangi Trench**

HT proved to have more trough-like shape form in its cross-section, while PsT and Hjort trenches have classic V-form.

<figure><img src="image_209.png" /><figcaption>Map 4.21.1: Hikurangi Trench, North Island, New Zealand: Digitizing cross-section profiles</figcaption></figure>

Whilst it serves as a terrain variable in this study to examine the geomorphic landform, variation of the geomorphic slopes were compared for the trenches and following findings noted: HT has a trough-like flat wide bottom, steeper gradient slope on the North Island flank (Fig. 4.21.1, A) [387]. The statistical histograms for the transecting profiles of the Hikurangi, Puysegur and Hjort trenches are visualized on Fig. 4.20.1. The evaluation of the descriptive statistics on bathymetry in three trenches and interpolation approaches shows following results. The shape of the histogram varies by all the three trenches reflecting their geomorphology.

Data distribution for the HT (Fig. 4.20.1, B) demonstrates almost equal pattern for depths -600 m to
-2,600 m with samples <60 for each bin (most data are detected at ca. 30-40 samples for a bin, not exceeding 4%). One can clearly see a rising increase of data with depths below 500, that is a slope of the North Island (frequency from 5% to 12%) [387]. Geomorphic curvature and distribution of the seamounts near the Puysegur, Hjort and HTes reflect the interplay between the complex tectonic processes occurring at a subducting tectonic plates and variations in the tension between the spreading ridges and the transform faults [403]. In the northwest region off PsT, GEBCO swath bathymetric data (Figures 3.3.8 and 2.19.2) enable to see rather complex submarine relief: linearly expressed ridge geomorphology, a series of small elongated seamounts, minor troughs and flat areas of the seabed.

<figure><img src="image_210.png" /><figcaption>**Figure 4.21.1:** Geomorphic cross-sections by Hikurangi, Puysegur and Hjort trenches</figcaption></figure>

Data distribution for HT (Fig. 4.21.1, B), the bathymetry has more equalized patterns at the depths -2,500 to -600 m. Notable peak have data located on the shallow areas (shallower than -500 m) where maximal values are detected for the range -400 to -300 m (258 samples) [387]. Generally, a strong correlation of the trench axes with borders of the three lithospheric tectonic plates (Antarctic Plate, Pacific Plate and Info-Australian Plate) can be noted, which underpins strong correlation of the trench
geomorphology with direction of the tectonic slab lineaments, as plate movements, geologic lineaments and extend of the fracture zones in the final end lead to the formation of the trench axis through the plates motions. Local geologic settings, linear extension of the tectonic slabs, complex tectonic processes and sedimentation of the HT, PsT and Hjort trenches might explain variations in their geomorphic structure and shape of the submarine landforms.

Comparative analysis of the geophysical settings among the three oceanic trenches revealed their structural characteristics and adjacent oceanic crust of the southern Antarctic region. Visualized gravity and geologic settings add new information to the interpretation of the data covering active convergent margins and in particular, a zone of Macquarie Triple Junction in Southwest Pacific Ocean, Antarctic. HT presented unique characteristics of the seafloor as trough-shaped form. By recognizing geomorphic shape and geologic settings at the seafloor, distinctly different from Puysegur and Hjort Trenches, a gradual decrease of depths along the slope of the North Island was observed. Targeted seafloor mapping in cross-sections highlighted active seafloor processes that created unique geomorphic for the three trenches.

Comparative analysis of the submarine geomorphology of the HT (HkT), PsT and Hjort Trench (HT), located off New Zealand coasts, SW Pacific Ocean shows following findings. PsT stretching from the South Island to the Macquarie Triple Junction, Macquarie Fault Zone. HkT continues PsT southwards from the Macquarie Island and characterized by frontal subduction erosion, numerous seamounts, extensional upper plate. HjT is characterized by an oblique subduction zone [387]. Unique tectonic setting of this region consist in two subduction zones: northern (Hikurangi margin) and southern (Puysegur margin), connected by oblique continental collision along the Alpine Fault of South Island. This cause variations in the submarine geomorphic structure of the trenches. PsT/HjT subduction is highly oblique (dextral) and directed southwards. Hikurangi subduction is directed northwestwards. South Island is caught in between by the 'subduction scissor'.

Comparative histogram equalization of topographic grids (equalized, normalized, quadratic) was done by module grdhisteq. Automated cross-sectioning was done using grdtrack module. HjT has a classic symmetric shape form with comparative gradients on both W and E slopes, trough-like flat wide bottom, steeper gradient slope on the North Island flank. PsT has an asymmetric V-form with steep gradient on the eastern slopes and more gentle slope on the west. The comparison of the medians of the trenches show that selected segment of the HkT has shallower depths with maximal <- 2,500 m, whilst PsT is reaching up to -6,000 m. The deepest values >6,000 m for HjT with the steepest slope gradient comparing to Hikurangi and Puysegur trenches.

Neighboring terrain has a gentle slope on the oceanward side for HkT, and a steep slope on the eastern flank for PsT. Data distribution for the HkT demonstrates almost equal pattern for the depths from -600 m to -2,600 m with samples <60 for each sample bin. PsT has a bimodal type of data distribution with two peaks. The 1st peak has 3 notable bins range -4,200 to -4,400 m (373 samples, frequency 18%), range -4,000 to -4,200. The 2nd peak covers depths -2,200 to -3,000 m, frequency < 7,5%. The peak corresponds to the Macquarie Arc bordering trench slope. A phenomenon of the tectonic plates subduction explains the asymmetry of the trenches. Geomorphic shape and structure of HkT, PsT and HjT are affected by geologic processes and factors and vary, as demonstrated on the presented modeled profiles.

<figure><img src="image_211.png" /></figure>
# Chapter 5

## Discussion

### 5.1 Novelty

PRECISE modelling of the deep ocean trenches has not been proposed in the existing literature. Some attempts are given [601]; [748] to aim mostly at the environmental ocean monitoring. Modelling trenches still remains a challenging task in marine geology. In view of this, advanced methods of data analysis, modelling and precise computing by combinations of GMT, R and Python for processing geological datasets as numerical arrays are novel approaches demonstrated in this dissertation. Hence, there are both theoretical and practical innovations of the research presented in this dissertation.

* Theoretical novelty lies in the classification, systematic mapping and comparative spatial analysis, geomorphological transect modelling of the 20 deep-sea trenches of the Pacific Ocean that does not exist in the available literature. Multi-source data analysis was applied for submarine geomorphology, to study variations in the types of the submarine landforms. A combination of the geophysical visualization, geological analysis and GMT-based mapping of the 20 deep-sea trenches along the Pacific Ocean margins does not present in the existing works so far.

* Practical novelty consists in the developed and tested methodology of the cross-disciplinary approach that includes a sequence of the GMT and IT tools (programming languages Python, R, Matlab, AWK) for data processing and complex statistical analysis based on the embedded mathematical algorithms.

* Technical novelty consists in the presented novel methodology of modelling geomorphology of the trenches. Developed and presented in this dissertation, the algorithms are based on GMT. It considers three principal variables: length of the transect segment, distance between the samples and density of sampling. Variables were selected for script, shaped current cross-section shapes of the landforms and defined curvatures of the modeled transects. Visualized graphs are based on numerical model through systematic digitizing of the profiles for each trench.

It should be stressed that a GMT shell scripting based mapping was applied for geospatial modelling and cartographic mapping, instead of the traditional GIS (e.g. Idrisi GIS [435], [473]; ENVI GIS [436], [479]; ILWIS GIS [445], [474], [481], [483]; eCognition [475]; OBIA technique of image processing [446]; ArcGIS [437], [326], [438], [439]; Erdas Imagie [482]). R and Python statistical libraries were used instead of Excel software often used in marine research [440], [380]. Tested, presented and explained functionality of a variety of GMT modules enabled to perform automated digitizing of the orthogonal profiles crossing 20 trenches in the perpendicular direction. Through modelling, landform shapes and steepness were visualized, compared and statistically analyzed as a basis for classification.
## 5.2 Actuality

MODELLING deep-sea trench is one of the most complicated issues in the marine geology: in contrast with the terrestrial ones, submarine regions still remain the least accessible areas on the Earth. Hence, oceanic trenches can only be studied by computer based modelling, RS methods, advanced mapping and sophisticated algorithms of data analysis. Therefore, using special tools of advanced spatial analysis, processing and modeling using advanced cartographic solutions enables to get closer insight into the deepest regions of the ocean visualizing areas with the most difficult access [78].

Understanding geomorphology, structure and shape of the submarine landforms in deep-sea trenches is crucial to modelling their geophysical and geological phenomena as the deepest places on the Earth. Numerical analysis of such complex structures based on the advanced data analysis and shell scripting significantly increases the precision and speed of data processing, as well as results reliability. It helps to improve investigations of the marine geology and submarine geomorphology of the oceans, as current understanding of tectonic, geological and oceanographic patterns and processes is largely based on the correct modelling. ML algorithms and automatization improves the precision and quality of mapping. GMT, largely used in this thesis, provides advanced cartographic solutions enabling to model, analyze, map, visualize and calculate the phenomena of the submarine geology.

Therefore, the actuality of the presented dissertation consist in the classification of the 20 deep-sea trenches, systematic mapping and geomorphological transect modelling. General conceptual idea of the presented dissertation can be extrapolated to other objects of ocean topography. Current dissertation contributed both towards marine geological studies and towards technical demonstration of the advanced data analysis by GMT shell scripting and programming languages Python and R.

Big data taken from the cruise observations and measurements in in-situ conditions are common in marine geology. Datasets derived from the R/V cruises have specifically large volumes of sampling. Together with their variety and different types (lithology and rocks of the seafloor, geological structure, tectonics, etc.) it arises a question of their effective processing. Algorithms of data processing by GMT, reshaping tables in AWK, and statistical analysis supported by R and Python enable to operate with big data volumes, generate data frames for the reprocessing and modelling. Without ML algorithms, geospatial analysis cannot be accurate and may lead to shortcomings and cause errors. ML is therefore indispensable for such remotely located areas as modelling abyssal depths.

The speed of data processing is another point of concern in marine geology that can be managed effectively by the advanced solutions of data analysis. Sophisticated algorithms of the data analysis and specialized techniques embedded in libraries of Python and R enable to extract the insights in the complexity of the marine geological factors affecting the structure of the submarine seafloor. Given these reasons, the advantages of using programming in the marine geological research opens clear and distinct perspectives.

High precision cartography, machine learning techniques, flexibility of shell scripting and compatibility with Unix programs ensure high standards of GMT and its suitability for geospatial modelling. Main tasks demonstrated in this dissertation include developed methodology base don technical GMT scripting for data analysis. These included ML, digitizing cross-section profiles, visualizing and analysis of the datasets, 3D-mesh modelling, contour plotting, statistical analysis. Modelling geomorphological slope of the deep-sea trenches is important in relation to several reasons:

1. Slope gradient is relevant as a geomorphological concept, since it impacts the stability of the geologic sediments and grain size.

2. Geomorphic slopes accelerate ocean deep currents related to the food supply chain and exposure for the deep-sea fauna species.
3. Slopes and specific landforms of the trench geomorphology induce erosion, movement, fall and replacements of sediments depending on their size.

4. Geomorphic characteristics of slopes influence submarine landforms of the trenches.

5. Geomorphology of the trench presents crucial characteristics for benthic habitat: stability of sediments depends on the slope steepness affects the ability of the deep-sea fauna species to dwell.

Specific focus of this dissertation is laid on its multi-disciplinary scope that performs systematic mapping, modelling and classification of 20 trenches base don the combines cartographic methods of geospatial and statistical data modelling. Methodologically, the steps included data visualization, modelling cross-section profiles, geospatial analysis, mapping, statistical analysis of the submarine landforms of the 20 trenches. The initial datasets were extracted from the USGS public sources and embedded layers in the GMT (e.g. coastlines). Particular aim was to classify and analyze variations in submarine geomorphology in 20 trenches. A variety of the GMT modules [743] adjusted for modelling grids, plotting vector layers, computing statistical graphs and perform aesthetically fine cartographic solutions proved to be a perfect tool. The importance of the developing and technical improving of the innovative methods in cartographic data processing is indisputable since visualization and precise modelling are key approaches in geological data analysis. Automatization has been significantly increased over the past years. However, using programming and scripting in cartography still remains lower comparing to the use of the traditional GIS.

Current techniques for GIS modelling of the marine geology of trenches mostly identify and handle relations and processes among tectonic slabs, depths and seismicity [612] or tectonic slub subduction and migration. Existing studies do not detail much variations among geomorphological classes of the trenches, but focus on geological modelling. From this perspective, such insufficiency is the result of limited access to the trenches, systematic limits to the techniques and constraint in usage of the advanced GIS. GMT based marine geological modelling and visualization of the big datasets increases significantly, broadens the perspectives of the marine research to the multi-disciplinary level.

Technical scripts used for advanced statistical analysis are presented in full in the Appendix A for future replication and reproducible analysis in other trenches of the World Ocean: e.g. Makran Trench [397], Puerto Rico Trench and Cayman Trough [391], Cascadia Trench [389], and other oceans: Sunda Trench [385], Bay of Bengal and Andaman Sea of the northern Indian Ocean [386], Java and Sumatra segments [379] of the Indonesian Archipelago in the Indian Ocean [382], South Sandwich Trench, Atlantic Ocean [403], Antarctic and the Southern Ocean, e.g. Ross Sea [378], Weddell Sea [375] or Scotia Sea [377].

Technical application of GMT demonstrated effectiveness and functionality for data analysis, precise and accurate high-quality cartographic mapping, shell scripting workflow for geodata processing. Proposed techniques and methodology of the GMT shell scripting presented in a stepwise workflow provided effective framework for further geological mapping and can be applied for similar research. The GMT proved to be a powerful scripting cartographic toolset for geological, geophysical and topographic mapping, geomorphic modelling and descriptive statistical analysis of the data retrieved from the automatic digitizing. Methodology of the presented dissertation laid a strong focus on the technical routines of the cartographic workflow, mapping and modelling based on the GMT shell scripting that enabled to identify bathymetric cross section profiles of the hadal trenches that show similarity by their complex parameters, so that they could be grouped into patters. Visualized maps demonstrated excellent possibilities of the GMT for geological mapping, geodetic and geophysical modelling.

In view of the above said, the actuality of the presented dissertation fully based on the sequential combination of the advanced data analysis (R, Python, AWK and Octave/Matlab programming, GMT and LATEX visualization, QGIS data processing) is clear. Classification, comparative analysis, systematic
mapping and geomorphic modelling of the oceanic trenches of the Pacific Ocean has a great scientific
and practical interest. The 1st relates to the testing theory of plate tectonics related to the actual geo-
morphological forms of the trenches. The 2nd is caused by the estimation of the time and place of where
earthquakes may arise. A correlation with distribution of the volcanic igneous areas, and economic needs
for mineral resources are other goals for studies deep trenches.
**5.3 Reflections on submarine geomorphology**

THE asymmetry of the deep-sea trenches is explained by the phenomenon of the tectonic plates subduction. Subduction of one lithospheric plate to the Earth's mantle while another plate is being deformed induces a formation of the oceanic trench which eventually forms through filling the space in between the plates. Necessarily, the complexity and variety of the bathymetric shapes in various trenches arises. The geomorphology of the oceanic trenches is influenced by a set of geologic processes and factors affecting their shape form, gradient steepness depths, and structure. Of these, tectonic plates movements and slab geometry are crucial controlling factors. This can be seen by comparison of the visualized geophysical setting and geomorphology of the trench seafloor. Other factors affecting trench structure and playing essential role in their morphology include age and convergence rate of the plates, intermediate slab dip, width of the sinking plate, sediment thickness of the basement, bathymetric factors, such as depth at basement, means, median and minimal values, closeness of the igneous volcanic areas causing possible earthquakes, and geographic location across the tectonic continental plates.

As a result, the bathymetry of the trench seafloor reflects processes of the plate tectonics: movement, deformation and bending which is associated with mantle convection at the global scale. Complex distribution of various geological factors on the adjacent abyssal plains of the ocean contributes to the formation of the geomorphic features of the ocean bottom in the trenches. Therefore, studying combination of these factors is a prerequisite for the correct understanding of the complex processes that take place in the abyssal environment of the hadal trench.

Variations in the seafloor geomorphology are caused by the uneven distribution of the elevations on the Earth with distinctly irregular hypsography. The majority of the depths is occupied by the deep basins (ca. 4-6.5 km) while relatively few areas are covered by shallow zones. Tectonic plate boundaries are the hotspot areas where the most of the largest earthquakes take place and oceanic slabs descend beneath the continental lithosphere causing trench migration [775]. The largest earthquakes sometimes accompanied by strong tsunami waves mostly occur in the shallow part of the subduction zones [769].

The geomorphology of the oceanic trenches in general reflects fluvial riverine geometry, albeit a general approximation. Setting aside the complexity of the river structure that includes the mainstreams, branches and other features [637]; [695]; [710], the overall approach of the riverine geomorphology may be adopted to the studies of the deep-sea trenches to a certain extent, in scope of the computer modeling and numerical analysis. The submarine trenches are important spaces within the ocean seafloor [126]. They may be approximated to the tributary river flows as channels for the flow of turbidity currents across the seafloor. Fine-grained sediments, e.g. clay and silt, are deposited from the turbidity currents channeled from the continental margins along submarine canyons down into deep ocean trenches.

Seafloor is constantly experiencing deformations under the effects of plate tectonic processes. Various factors affect formation, functioning and sustainability of the deep-sea trenches as one of the unique places of the oceans [601], [593]. Among them, tectonics plates movement, subduction of the underlying slab into the deep mantle, seismic activities in the study area, e.g. submarine earthquakes [673]. Other factors include geological phenomena identifying characteristics of the submarine geomorphology of the trench, previously [713], [759], [560].

There is a broad interest to the geologic structure and tectonic evolution of oceanic trenches supported by numerous studies ([578], [355]; [581], [244]), however those studies are mostly focused on the geophysical settings of the trenches. 20 deep-sea trenches dissecting the margins of the Pacific Ocean have been the target of the presented dissertation which investigated spatial variability of their submarine geomorphology aimed at classification. Effective data processing helped to gain more insights into the seafloor geomorphology. The sketch on the impacts of the trench geomorphology was analyzed, summarizing various factors: tectonics, geological structure, sediments, bathymetry, lithology, etc. Dissertation classifies variations in trench geomorphology.
## 5.4 Perspectives of the IT tools for geology

Presented dissertation demonstrated a multi-disciplinary approach combining effective processing of the complex data sets by programming, shell scripting and statistical algorithms. Sequential use of Python, AWK, R and Octave/Matlab is effective for geological data processing. Study of the seafloor is possible not only by QGIS, but using R: network analysis, factors analysis, plotting, diagrams, cluster analysis by various methods (k-means, dendrograms, silhouettes), triple correlation by ternaries [416]. IT based methodology is focused on technical approaches in the analysis of trench geomorphology used as a background for classification. Classification received by application of the technical methods with geomorphic analysis are presented.

Tested functionality of GMT modules proved it to be a highly effective cartographic toolset for geological data analysis enabling precise mapping, automated sampling of the orthogonal transects. GMT based modelling helped to visualize and compare shape of the submarine landforms, steepness gradient of the trenches which were used as a basis for classification. Presented GMT based approach provided a cost-effective solution to the seafloor mapping of the deep-sea trenches. Benefits of the GMT based seafloor mapping to a broad spectrum of visualization of seafloor, and convergence toward a standard suite of high quality raster/vector datasets (e.g. GEBCO, SRTM15), maps and plots were demonstrated in this thesis. GMT aimed to advance cartographic visualization and modelling at high standards, perform quality mapping. This can be effectively used for analysis of submarine landforms, providing knowledge base to detail bathymetry. Besides geological applications, GMT can be successfully used in agricultural mapping [369], geomorphological mapping [371], climate and environmental studies [372].

Comparing R and Python, both languages have significant functionality for marine geological data analysis. However, Python, being a high-level language, demonstrated more straightforward approach for the statistical analysis. Python is an interpreted language that enables programs to be written compactly and readably splitting them into reusable modules [640] that process and model big datasets. Encapsulation, inheritance and polymorphism of Python are the main advantages while working with big data in marine geology and processing large tables. Simple and vectorized syntax structures and semantics of Python enable to write code concisely and effectively resulting in fewer hard-to-find bugs comparing to the codes written on C++, which minimizes the chance of conflicts in a code. Using NumPy for processing tables in .csv format and arrays facilitate advanced mathematical operations on large numbers of data. R implies more power in data visualization.

Programming scripts are presented in this dissertation. Effective data visualization provided by libraries enabled better targeting of the distinct areas in the trench that include specific geomorphic features. Functionality of R and Python and their statistical libraries is highly effective for the statistical analysis in marine geology. Data analysis demonstrated effectiveness of the selected methods. Advanced data processing enabled to analyze variations in geomorphology in the trenches, visualize correlation with geological settings. Combined effects of geological and lithological factors that affect geomorphology of the trenches were visualized by statistical methods.

Using advanced IT tools, such as LATEX and GitHub as repository for projects and scripts is highly useful for geodata processing [468] and can be used to perform information analysis, organizing and structuring data, standardization and classification for data analysis in large volumes [447], [469], [439], [441]. Technical shell GMT scripts, full codes of R, Octave, LATEX and Python and statistical workflow outlined in this thesis are presented in the Appendix for replication, to enable their repeatability and reuse in further works. The dissertation contributed towards development of quantitative and statistical methods in marine geology, in particular aimed at the objective analysis of the ocean trench geomorphology, systematic mapping and classification of the submarine landforms.
# Chapter 6

## Conclusion

This dissertation offers an overview of geomorphological classification performed using advanced data analysis, GMT based modelling and mapping. The research aimed at analyzing variations in 20 deep-sea trenches of the Pacific Ocean. It presents a multidisciplinary approach combining cartographic modelling and statistical data analysis. The results enabled to present classification of the trenches based on their geomorphic properties, variations in slopes, analysis of steepness gradients and bathymetry.

Data analysis in geosciences supported by advanced methods is important novel method aimed to increase precision of the computations and operating with big data in marine geology. However, performing data analysis of the marine geological datasets raises a challenge. Existing solutions mostly apply tradition methods of the GIS. In contrast, this dissertation demonstrated a programming languages used in marine geology. Combination of the advanced methods with spatial analysis by GIS plugins and GMT scripting enables to process marine geological datasets in a quick and easy way.

GMT based data analysis enabled to map remotely located areas such as deep-sea trench, to visualize and analyze geophysical and geological settings. Other approaches to perform spatial data analysis in marine geology include pure statistical data modelling using programming languages, such as Python and R, and statistical analysis. However, the advantages of the GMT consists in the possibility to perform both cartographic mapping and statistical analysis using the same program. Various types of data processing can be performed in GMT environment: data analysis, modelling, mapping and statistical analysis and visualization. Besides, the GMT ML approach enables repeatability of the techniques for each of the studied 20 trenches of the Pacific Ocean. Therefore, the GMT scripting toolset was selected as a main tool for data modelling and cartographic mapping by GMT documentation [739], [742].

Methodology is supported by GMT for cartographic visualization, plotting and modelling. Mapping includes visualized local settings of the trenches for spatial analysis, based on a sequential use of GMT modules. The GMT approach represents a cost-effective approach to visualize seafloor. This approach delivers a knowledge base upon which more detailed studies on links between geology, tectonics, geophysics and bathymetry can be identified. Overlapping in GMT enables to map various layers (tectonic plates, earthquakes, faults) and depth sample points. QGIS plugins facilitate reading coordinates, reprojecting coordinates, layouts visualization, attribute data conversion into csv tables.

Technically, experimental approach of the cartographic modelling with numerical statistical analysis by GMT modules was used to analyze geological and geophysical data sets. Visualization of the series of thematic maps (geology, bathymetry, geoid, gravimetry, 3D modelling, 2D profiles trends modelling, digitized cross-section profiles) demonstrated powerful functionality of the GMT and proved to be effective cartographic instrument for data analysis. Increasing diversity of the spatially distributed data on Earth observation together with application of the advanced cartographic methods and shell scripting greatly enhance the potential of the geospatial modeling.
Application of the cartographic modelling towards marine geological data enables to perform clas-
sification based on the detected spatial differences in the submarine geomorphology. Modelling spatial
variations in trench geomorphology facilitates studies of the plate tectonics. Modelling seafloor shape is
one of the fundamental issues in modern marine geology. Proper techniques of mapping and modelling
trenches advance seafloor studies but they are still developing [729], [741]. Mapping submarine land-
forms has certain limitations in progress due to the remote location of the trenches. Therefore, modelling
seafloor by means of ML algorithms and shell scripting is an effective tool for such a task.

High-resolution data sets were visualized for bathymetric, geological and geophysical mapping of the 20 trenches. Orthogonal cross-sections of the profiles were automatically digitized and processed by GMT in the selected segments of the trenches. Geomorphological classification was based on modelling. Descriptive statistical data analysis was performed for quantitative comparative analysis of the geomorphic forms of 20 trenches. Trenches were modeled in an automated regime by GMT using high-resolution bathymetric datasets (GEBCO, ETOPO1 and SRTM). Using developed methodology of the advanced data analysis, geomorphological modelling, mapping and classification are performed for 20 trenches.

From this point of view, this work presented a GMT based methodology for visualization, modelling, interpretation and classification of the submarine geomorphology of the trenches demonstrating new approaches to the mapping. In contrast to the classic cartographic approaches with GUI, e.g. ArcGIS ESRI based [324], [325]; [698], [489], [484], in geodata visualization and mapping [190]; [660]; [485]; [342]; [699]; [324], [327], [447] or other examples of the geospatial modelling applied for geodetic approximations, 3D modelling [715], [27], [291], GMT is notable for shell scripting algorithms as a core concept. Traditional handmade digitizing is a tedious routine prone to errors. On the contrary, GMT based automatization of the cartographic techniques significantly improves modelling quality and precision. Technically, the results show the effectiveness of scripting in modelling submarine geomorphology. The results of the data analysis show distinct unevenness in the geomorphic structure of the trenches.

Although existing maps enable to visualize seafloor with certain resolution and accuracy, there is still a lack of detailed maps of deep-sea trenches, their models and visualization focused on geomorphic form and shape. Integrating GMT based mapping with geological, gravity and bathymetric datasets presented accurate, high-resolution geomorphic maps and cross-section bathymetric models. Approaches to the geological data analysis are diverse: techniques of ternary diagrams visualizing correlation between variables [619], [422], geophysical methods, e.g. DC-resistivity and SASW [120], civil engineering [365], measurements of soil and lime properties, e.g. compression soil tests, indirect tensile tests, triaxial tests [501], various approaches to the data analysis, plotting and visualization, e.g. factor analysis [95], [432], correlograms [433], scatterplot matrices [430], regression analysis [424], data processing by TeX [366]. In contrast with existing works, current thesis present statistical analysis made by Python and R.

High-resolution datasets and raster grids were used for classification of the submarine geomorphology, performed using detailed information on bathymetry and topography of the 20 deep-sea trenches of the Pacific Ocean [367]. The dissertation focused on the geomorphic assessment of variations in their shapes. The research contributes to the improvement of the technical methods of the geomorphic modelling. The review of the statistical methods presented in current thesis can be applied methodologically for comparing and benchmarking different research schemes on other trenches. Furthermore it can be used for analysis of the submarine earthquake connections with ocean trench formation and tectonic slab movement or controlling impact factors during geospatial analysis.

To conclude, methodology of the presented dissertation includes programing languages, statistical analysis, mathematical algorithms for data processing and visualizing, GMT for geomorphic modelling, GIS for digitizing bathymetric profiles and spatial analysis.
**6.1 Global Summary**

THIS thesis presented application of the advanced scripting and programming application to classification, modelling and mapping variations in the submarine geomorphology of the 20 oceanic trenches of the Pacific Ocean. It described methodology for using selected statistical libraries aimed at geomorphic visualization and analysis of the ocean seafloor. The innovative idea of this thesis consisted in integrated use of GMT, Octave, QGIS R and Python programming languages and statistical analysis towards marine geological studies. Technically, the thesis was performed using advanced methods of data analysis: R, Python, GMT, Octave and AWK. Statistical analysis includes a range of the described algorithms through numerous statistical libraries used for data analysis. Nowadays, ocean modelling and conservation becomes one of the most vibrant, paramount endeavors of the marine geology. Application of advanced data modelling towards geomorphic studies revealed variations in their geomorphic forms and structure, and highlighted factors affecting abyssal morphology.

Methodologically, the dissertation contributed towards technical application of the GMT based methods for bathymetric modelling and mapping for deeper understanding of the differences in geomorphology and geophysical settings of the oceanic trenches located along the margins of the Pacific Ocean. It is aimed to produce a set of the cross-section profiles for 20 deep-sea trenches varying in geomorphology. The developed techniques can be utilized at similar works for detailed seafloor mapping. The classification and comparison of the submarine geomorphology and differences among trenches are presented. The thesis elaborated and answered question of how the structure of trench can be classified, measured, compared and analyzed by means of advanced data analysis.

Main objective of the presented dissertation was to perform geomorphological classification based on comparative analysis and map variations in the submarine landform structure of the 20 deep-sea trenches of the Pacific Ocean [368]. To this aim, an objective method combining various approaches was performed including GMT shell script based mapping, statistical analysis, GIS visualization and graphical plotting. Profile transect modelling was exemplified using sampling on the segments of the AOI in topography of the trenches. Mapping deep-sea trenches needs support of reliable, detailed and accurate seafloor maps.

Functional GMT-based framework for cartographic mapping and modelling of the ASCII datasets enabled to quantify variability in the bathymetry of spatially distributed transects of the trenches. The results revealed unevenness in the geomorphology among 20 trenches. Factors affecting their structure are discussed and reviewed. These include local settings, sediment thickness, slope steepness, depths, location. Distinct correlation between the geological factors affect geomorphology of the trenches. Full scripts of GMT, AWK, R, Python and GNU Octave programming languages are presented for repeatability in the Appendix section.

The dissertation presented successful application of the variety of scripting libraries of GMT in marine geology which resulted in high-quality precise mapping, fine cartographic instruments, flexibility of scripting and coding, compatibility with UNIX utilities. Using such advantages of the GMT for geological data modelling and mapping definitely facilitates data processing, enables high-precision analysis and mapping data frames. Application of the GMT towards geological data analysis and visualization is highly effective and promising comparing to the traditionally used GIS. Classifying and modelling submarine geomorphology revealed a consistent pattern of their structural and morphological features. These include deep abyssal valleys, steep slopes, bounded by a submarine deep basin moraines at the outer limits of the trenches. Submarine ridges are explained as a series of small moraines, stacked behind a larger moraines.

Supported by sound literature review, this dissertation identified and classified variabilities among the geomorphology of major 20 trenches of the Pacific Ocean. High accuracy of the performed statistical data analysis and cartography has been supported by chosen advanced algorithms of the ML data processing
and high-resolution data: raster grids, ASCII, vector QGIS layers and attribute tables.
## 6.2 Recommendations

As a recommendation for further research focused on ocean trenches, traditional methods of seafloor studies should include a combination of both GIS and statistical analysis such as R and Python, or Octave. Studies of spacial data series should be accompanied by graphics, facetted plots to facilitate comparison of the data by groups. This is especially useful while processing multi-dimensional geological data. Since there are variations in trench geomorphology, as well as correlations among factors affecting their formation and geomorphology, mathematical algorithms and objective analyses based approaches of data analysis should be explicitly used. A contemporary perspective of GMT, R and Python based methods of geological data for modelling trench geomorphology is demonstrated in this thesis.

Programming scripts provided in the Appendix are recommended as a template for similar studies. Application of the statistical tools provided by functionality of R and Python offer optimal prospects for understanding bathymetry and geomorphology of the oceanic trenches. Differences in variation of geomorphological forms can be detected by application of various methods and algorithms, as different approaches can highlight correlations. It is recommended to apply and test various statistical algorithms of data analysis.

Cross-disciplinary quantitative approach for geomorphological analysis is recommended for future studies. Using R and Python for marine geoscience research does not only make geological modelling simpler and less error-prone. It also facilitates complex simulations involving multi-dimensional modelling with varying parameters. It is also recommended to apply developed and presented methods for other deep-sea trenches. Processing multi-source data by the ML methods enables to speed up our understanding of the submarine geomorphology of the ocean seafloor. A combination of the advanced tools for spatial data processing, such as R, Python, AWK and Octave/MATLAB programming, GMT enables to perform integration of such complex heterogeneous data from a variety of sources for the in-depth analysis.

Application of the programming languages (R, Python, Octave and AWK) is strongly recommended in geoscience research as an addition to the traditional GIS methods. From all available statistical methods it is necessary to select the most suitable to the modelling type: data ranking, data distribution (e.g. box plots or violin plots, linear regression or isotonic regression), correlation matrix or correlogram ellipses, etc. Correct chosen algorithms of the statistical modelling helps to best visualize and analyze the data set. Visualizing the full range of the geomorphology across the trench should be done using various methods: by the deepest values (i.e. each profiles can have only one dot point), or by showing the full line of profile (i.e. the profile shows the cross section in its length), in circular or bar plot or dot plot types, as presented in this dissertation

Finally, as a last recommendation, more detailed marine geological datasets could be included for data analysis. These include data from the cruises: currents, sediment texture, water circulation at various depths. Geological interpretations can be used to extrapolate geomorphic type of the transects along the trench. Using GMT shell scripting for cartographic modelling increases automatization of the mapping routine. Therefore, GMT is strongly recommended for geological data analysis and classification. Presented techniques and methodology of GMT shown effective framework for geological mapping. Environmental factors may be studied additionally by existing methods of the environmental management, ecological monitoring and data analysis [476], [448], [449], [450], [451], [452], [453]. Thorough multi-dimensional data processing in marine geology should include following data: tectonic (continental margin plates), geological (geologic structure), lithological (sedimentation) and oceanological (direction of the deep currents).
6.3 Outlook and future developments

A
S demonstrated in this thesis, active use of the programming languages in geoscience research is effective to advance studies of the bathymetry. Development in statistical methods such as R and Python enables to treat multi-source types of the marine geological data. Studies of such complex objects as oceanic trenches, have specific points that distinguish them from the terrestrial areas. 1st, seafloor rocks are studied mainly by RS methods. Samples include cores obtained from drilling or platforms, collected by dredging. 2nd, thorough understanding of the basics of geophysics, geography, geomorphology, oceanography, cartography, informatics and principles of data interpretation are prerequisites for marine geology [374]. Hence, a variety of methods of the advanced data analysis is necessary to study deep-sea trenches.

Rigorous and quantitative quantitative data analysis performed by R and Python and supported by GIS is effective for investigation of such large-scale geologic structures as trenches. If surface of the whole trench is modeled, the extra- or interpolation of the depths by profiles increase random errors due to the complex nature of the real situation of physical environment. It can be either the effects of the external factors on the geomorphic structure (tectonic slab movement that affects the shape of the trench segment) or mathematical approaches of the algorithm of approximation. In the most difficult segments (e.g., areas of triple junctions), it is possible to take more dense profiles digitizing. However, in this case it would be reasonable to large scale this particular area as enlarged fragment.

Nowadays, ocean modelling and conservation become one of the most vibrant, paramount endeavors
in marine geology [623]. Understanding structure of the trenches helps to improve investigation of the
marine geology. Particular problem in the analysis of the ocean seafloor lies in the complexity of the
processes involved in trench formation. Therefore, submarine geomorphic modelling should encompass
not only submarine landforms, but its links with tectonics, seismicity, earthquakes repeatability and
magnitude, oceanological parameters (current direction and strength), lithology (origin and properties of
the underlying rocks).

Future work should consider applying other GMT modules and their combination to develop complex approaches of the cartographic-geophysical investigations: earthquake intensity modelling, mapping volcanic arcs. Application of GRASS GIS is recommended for GIS data processing [393], [388], [398], [381]. Combination and overlapping of various geospatial data aimed to examine and quantify landforms in connection with local settings by existing methods of spatial analysis enables to get information on geological, tectonic and environmental thematic mapping apply spatial analysis at various scales. Other recommendation could include integration of GMT with programming and advanced statistical packages.

Future works may include satellite image processing for coastal and shelf areas by available methods of image analysis: Google Earth [472], Landsat TM/ETM+ and MSS imagery [480], [477], [454], [466], [478], [455], [456], [457], [458], [395], [394]. Applying various software, e.g. ILWIS GIS [471], [459], [464], eCognition for OBIA [460], [467], Quantum GIS [399], [461], [462], [465], ENVI GIS, ArcGIS [487]; [463], [486], Erdas Imagine, SAGA GIS [395], [384], [390] are useful for spatial analysis.

Future applications should include analysis of the interplay between the elements of the submarine ecosystem, predicting changes in its structure, reconstruct origin and evolution of the trench dynamics, interpret slab motions [664]; [588]; [564]; [242], tectonic and sedimentary processes in the marginal seas [198], [199], [200]. Given non available tools of the ML and operating with big data in marine geology, studies should apply more complicated numerical data analysis and visualization. Maps produced and demonstrated in this thesis can be used as a template for seafloor mapping and modelling at regional and local scales.

<figure><img src="image_212.png" /></figure>
Author's Publications

<footnote n="1">¹P. Lemenkova, “SAGA GIS for Computing Multispectral Vegetation Indices by Landsat TM for Mapping Vegetation Greenness”, Contemporary Agriculture **70**, 67–75 (2021), URL: https://sciendo.com/article/10.2478/contagri-2021-0011.</footnote>

<footnote n="2">²P. Lemenkova, “Topography of the Aleutian Trench south-east off Bowers Ridge, Bering Sea, in the context of the geological development of North Pacific Ocean”, Baltica **34**, 27–46 (2021), URL: https://gamtostyrimai.lt/en/publications/listingCategory/category.1020.</footnote>

<footnote n="3">³P. Lemenkova, “Scripting Languages for Geomorphological Modelling and Topographic Visualization of Serbia”, Zbornik Matice srpske za prirodne nauke **140**, 113–125 (2021), URL: http://doiserbia.nb.rs/journal.aspx?issn=0352-4906.</footnote>

<footnote n="4">⁴P. Lemenkova, “Mapping environmental and climate variations by GMT: a case of Zambia, Central Africa”, Zemljite i biljka **70**, 117–136 (2021), URL: http://www.sdpz.rs/index.php/sr-yu/casopis-zemljiste-i-biljka.</footnote>

<footnote n="5">⁵P. Lemenkova, “Accurate and rapid big spatial data processing by scripting cartographic algorithms: advanced seafloor mapping of the deep-sea trenches along the margins of the Pacific Ocean”, in *Bringing Land, Ocean, Atmosphere and Ionosphere Data to the Community for Hazard Alerts* (May 24, 2021), URL: https://agu.confex.com/agu/21workshop2/meetingapp.cgi/Home/0, SLIDESHARE.</footnote>

<footnote n="6">⁶P. Lemenkova, “Morphostructure features of the deep-sea trenches in the Pacific Ocean: the problem of their origin”, Russian, in *Seminar of the laboratory of regional geophysics and natural disasters*, in Russian (May 24, 2021), SLIDESHARE.</footnote>

<footnote n="7">⁷P. Lemenkova, “The visualization of geophysical and geomorphologic data from the area of Weddell Sea by the Generic Mapping Tools”, Studia Quaternaria **38**, 19–32 (2021), URL: https://www.czasopisma.pan.pl/sq.</footnote>

<footnote n="8">⁸P. Lemenkova, “Cartographic Processing of the Multi-Source Geospatial Datasets by GMT for Mapping Variability in Geologic Setting and Bathymetry of the Pacific Ocean”, Mercator **20**, 1–18 (2021), URL: http://www.mercator.ufc.br/mercator/article/view/e20013.</footnote>

<footnote n="9">⁹P. Lemenkova, “Exploring structured scripting cartographic technique of GMT for ocean seafloor modeling: A case of the East Indian Ocean”, Maritime Technology and Research **3**, 162–184 (2021), URL: https://so04.tci-thaijo.org/index.php/MTR/article/view/248158.</footnote>

<footnote n="10">¹⁰P. Lemenkova, “Geodynamic setting of Scotia Sea and its effects on geomorphology of South Sandwich Trench, Southern Ocean”, Polish Polar Research **42**, 1–23 (2021), URL: https://journals.pan.pl/ppr/136510.</footnote>

<footnote n="11">¹¹P. Lemenkova, “Data-driven insights into correlation among geophysical setting, topography and seafloor sediments in the Ross Sea, Antarctic”, Caderno de Geografia **31**, 1–20 (2021).</footnote>

<footnote n="12">¹²P. Lemenkova, “Java and Sumatra Segments of the Sunda Trench: Geomorphology and Geophysical Settings Analysed and Visualized by GMT”, Glasnik Srpskog Geografskog Drustva **100**, 1–23 (2020).</footnote>

<footnote n="13">¹³P. Lemenkova, “Using R packages ’tmap’, ’raster’ and ’ggmap’ for cartographic visualization: An example of dem-based terrain modelling of Italy, Apennine Peninsula”, Zbornik radova - Geografski fakultet Univerziteta u Beogradu **68**, 99–116 (2020).</footnote>

<footnote n="14">¹⁴P. Lemenkova, “GRASS GIS for classification of Landsat TM images by maximum likelihood discriminant analysis: Tokyo area, Japan”, Geodetski glasnik **51**, 5–25 (2020).</footnote>
¹⁵P. Lemenkova, "Insights on the Indian Ocean tectonics and geophysics supported by GMT", *Risks and Catastrophes Journal* **27**, 67–83 (2020).

¹⁶P. Lemenkova, "Sediment thickness in the Bay of Bengal and Andaman Sea compared with topography and geophysical settings by GMT", *Ovidius University Annals Series: Civil Engineering* **22**, 13–22 (2020).

¹⁷P. Lemenkova, "Scripting cartographic methods of GMT for mapping the New Britain and San Cristóbal trenches, Solomon Sea, Papua New Guinea", *Revista da Casa da Geografia de Sobral* **22**, 122–142 (2020).

¹⁸P. Lemenkova, "Analysis of the difference in depths and variation in slope steepness of the Sunda Trench, Indonesia, east Indian Ocean", *Revista de Geomorfologie* **22**, 21–41 (2020).

¹⁹P. Lemenkova, "Sentinel-2 for High Resolution Mapping of Slope-Based Vegetation Indices Using Machine Learning by SAGA GIS", *Transylvanian Review of Systematical and Ecological Research* **22**, 17–34 (2020).

²⁰P. Lemenkova, "GRASS GIS for topographic and geophysical mapping of the Peru-Chile Trench", *Forum geografic* **19**, 143–157 (2020), URL: http://forumgeografic.ro/2021/2704/.

²¹P. Lemenkova, "GEBCO and ETOPO1 gridded datasets for GMT based cartographic mapping of Hikurangi, Puysegur and Hjort Trenches, New Zealand", *Acta Universitatis Lodziensis. Folia Geographica Physica* **19**, 7–18 (2020).

²²P. Lemenkova, "GRASS GIS Modules for Topographic and Geophysical Analysis of the ETOPO1 DEM and Raster Data: North Fiji Basin, Pacific Ocean", *Geographia Napocensis* **14**, 27–38 (2020).

²³P. Lemenkova, "Applying Automatic Mapping Processing by GMT to Bathymetric and Geophysical Data: Cascadia Subduction Zone, Pacific Ocean", *Journal of Environmental Geography* **13**, 15–26 (2020).

²⁴P. Lemenkova, "Object Based Image Segmentation Algorithm of SAGA GIS for Detecting Urban Spaces in Yaoundé, Cameroon", *Central European Journal of Geography and Sustainable Development* **2**, 38–51 (2020).

²⁵P. Lemenkova, "Geomorphology of the Puerto Rico Trench and Cayman Trough in the Context of the Geological Evolution of the Caribbean Sea", *Annales Universitatis Mariae Curie-Sklodowska, sectio B Geographia, Geologia, Mineralogia et Petrographia* **75**, 115–141 (2020).

²⁶P. Lemenkova, "Using GMT for 2D and 3D Modeling of the Ryukyu Trench Topography, Pacific Ocean", *Miscellanea Geographica* **25**, 1–13 (2020).

²⁷P. Lemenkova, "NOAA Marine Geophysical Data and a GEBCO Grid for the Topographical Analysis of Japanese Archipelago by Means of GRASS GIS and GDAL Library", *Geomatics and Environmental Engineering* **14**, 25–45 (2020).

²⁸P. Lemenkova, "Hyperspectral Vegetation Indices Calculated by Qgis Using Landsat Tm Image: a Case Study of Northern Iceland", *Advanced Research in Life Sciences* **4**, 70–78 (2020).

²⁹P. Lemenkova, "SAGA GIS for information extraction on presence and conditions of vegetation of northern coast of Iceland based on the Landsat TM", *Acta Biologica Marisiensis* **3**, 10–21 (2020).

³⁰P. Lemenkova, "The geomorphology of the Makran Trench in the context of the geological and geophysical settings of the Arabian Sea", *Geology, Geophysics and Environment* **46**, 205–222 (2020).

³¹P. Lemenkova, "GEBCO Gridded Bathymetric Datasets for Mapping Japan Trench Geomorphology by Means of GMT Scripting Toolset", *Geodesy and Cartography* **46**, 98–112 (2020).

³²P. Lemenkova, "Fractal surfaces of synthetical DEM generated by GRASS GIS module r.surf.fractal from ETOPO1 raster grid", *Journal of Geodesy and Geoinformation* **7**, 86–102 (2020).

³³P. Lemenkova, "Python libraries matplotlib, seaborn and pandas for visualization geospatial datasets generated by QGIS", *Analele tiinifice ale Universitii "Alexandru Ioan Cuza" din Iai - seria Geografie* **64**, 13–32 (2020).

³⁴P. Lemenkova, "Integration of geospatial data for mapping variation of sediment thickness in the North Sea", *Scientific Annals of the Danube Delta Institute* **25**, 129–138 (2020).

³⁵P. Lemenkova, "Mapping Beaufort Sea Topography and Geophysical Settings Using High-Resolution Geospatial Data and GMT", *Geografické informácie* **24**, 4–18 (2020).

³⁶P. Lemenkova, "R Libraries {dendextend} and {magrittr} and Clustering Package scipy.cluster of Python For Modelling Diagrams of Dendrogram Trees", *Carpathian Journal of Electronic and Computer Engineering* **13**, 5–12 (2020).
<sup>37</sup>P. Lemenkova, “Seafloor Mapping of the Atlantic Ocean by GMT: Visualizing Mid-Atlantic Ridge Spreading, Sediment Distribution and Tectonic Development”, *Acta Geobalcanica* **6**, 145–157 (2020).

<sup>38</sup>P. Lemenkova, “Mapping South China Sea Region by GMT for Marine Geological Analysis and Visualization”, *Analele Universitii din Oradea, Seria Geografie* **30**, 107–121 (2020).

<sup>39</sup>P. Lemenkova, “Variations in the bathymetry and bottom morphology of the Izu-Bonin Trench modelled by GMT”, *Bulletin of Geography. Physical Geography Series* **18**, 41–60 (2020).

<sup>40</sup>P. Lemenkova, “Cartographic Interpretation of the Seafloor Geomorphology Using GMT: a Case Study of the Manila Trench, South China Sea”, *Aksaray University Journal of Science and Engineering* **4**, 1–18 (2020).

<sup>41</sup>P. Lemenkova, “GMT Based Comparative Geomorphological Analysis of the Vityaz and Vanuatu Trenches, Fiji Basin”, *Geodetski List* **74**, 19–39 (2020).

<sup>42</sup>P. Lemenkova, “Visualization of the geophysical settings in the Philippine Sea margins by means of GMT and ISC data”, *Central European Journal of Geography and Sustainable Development* **2**, 5–15 (2020).

<sup>43</sup>P. Lemenkova, “GMT-based geological mapping and assessment of the bathymetric variations of the Kuril-Kamchatka Trench, Pacific Ocean”, *Natural and Engineering Sciences* **5**, 1–17 (2020).

<sup>44</sup>P. Lemenkova, “AWK and GNU Octave Programming Languages Integrated with Generic Mapping Tools for Geomorphological Analysis”, *GeoScience Engineering* **65**, 1–22 (2019).

<sup>45</sup>P. Lemenkova, “Geomorphological modelling and mapping of the Peru-Chile Trench by GMT”, *Polish Cartographic Review* **51**, 181–194 (2019).

<sup>46</sup>P. Lemenkova, “Automatic Data Processing for Visualising Yap and Palau Trenches by Generic Mapping Tools”, *Cartographic Letters* **27**, 72–89 (2019).

<sup>47</sup>P. Lemenkova, “Geophysical Modelling of the Middle America Trench using GMT”, *Annals of Valahia University of Targoviste. Geographical Series* **19**, 73–94 (2019).

<sup>48</sup>P. Lemenkova, “Geospatial Analysis by Python and R: Geomorphology of the Philippine Trench, Pacific Ocean”, *Electronic Letters on Science and Engineering* **15**, 81–94 (2019).

<sup>49</sup>P. Lemenkova, “Calculating slope gradient variations in the submarine landforms by R and Python statistical libraries”, *MANAS Journal of Engineering* **7**, 99–113 (2019).

<sup>50</sup>P. Lemenkova, “Plotting Ternary Diagrams by R Library ggtern for Geological Modelling”, *Eastern Anatolian Journal of Science* **5**, 16–25 (2019).

<sup>51</sup>P. Lemenkova, “Deep-Sea Trenches of the Pacific Ocean: a Comparative Analysis of the Submarine Geomorphology by Data Modeling Using GMT, QGIS, Python and R. Mid-Term PhD Thesis Presentation: Current Research Progress”, in *Seminar Mid-Term PhD Thesis Presentation* (Nov. 2019).

<sup>52</sup>P. Lemenkova, “Topographic surface modelling using raster grid datasets by GMT: example of the Kuril-Kamchatka Trench, Pacific Ocean”, *Reports on Geodesy and Geoinformatics* **108**, 9–22 (2019).

<sup>53</sup>P. Lemenkova, “Generic Mapping Tools and Matplotlib Package of Python for Geospatial Data Analysis in Marine Geology”, *International Journal of Environment and Geoinformatics* **6**, 225–237 (2019).

<sup>54</sup>P. Lemenkova, “GMT Based Comparative Analysis and Geomorphological Mapping of the Kermadec and Tonga Trenches, Southwest Pacific Ocean”, *Geographia Technica* **14**, 39–48 (2019).

<sup>55</sup>P. Lemenkova, “Computing and Plotting Correlograms by Python and R Libraries for Correlation Analysis of the Environmental Data in Marine Geomorphology”, *Jeomorfolojik Aratrmalar Dergisi / Journal of Geomorphological Researches* **3**, 1–16 (2019).

<sup>56</sup>P. Lemenkova, “Statistical Analysis of the Mariana Trench Geomorphology Using R Programming Language”, *Geodesy and Cartography* **45**, 57–84 (2019).

<sup>57</sup>P. Lemenkova, “K-means Clustering in R Libraries {cluster} and {factoextra} for Grouping Oceanographic Data”, *International Journal of Informatics and Applied Mathematics* **2**, 1–26 (2019).

<sup>58</sup>P. Lemenkova, “Testing Linear Regressions by StatsModel Library of Python for Oceanological Data Interpretation”, *Aquatic Sciences and Engineering* **34**, 51–60 (2019).
<figure><img src="image_213.png" /></figure>

<footnote n="59">⁵⁹P. Lemenkova, "Numerical Data Modelling and Classification in Marine Geology by the SPSS Statistics", *International Journal of Engineering Technologies* **5**, 90–99 (2019).</footnote>

<footnote n="60">⁶⁰P. Lemenkova, "Regression Models by Gretl and R Statistical Packages for Data Analysis in Marine Geology", *International Journal of Environmental Trends* **3**, 39–59 (2019).</footnote>

<footnote n="61">⁶¹P. Lemenkova, "Geostatistical Analysis of the Data Sets on the Mariana Trench, Pacific Ocean", in *Seminar presentation* (Apr. 2019).</footnote>

<footnote n="62">⁶²P. Lemenkova, "Processing oceanographic data by Python libraries NumPy, SciPy and Pandas", *Aquatic Research* **2**, 73–91 (2019).</footnote>

<footnote n="63">⁶³P. Lemenkova, "An Empirical Study of R Applications for Data Analysis in Marine Geology", *Marine Science and Technology Bulletin* **8**, 1–9 (2019).</footnote>

<footnote n="64">⁶⁴P. Lemenkova, "Scatterplot Matrices of the Geomorphic Structure of the Mariana Trench at Four Tectonic Plates (Pacific, Philippine, Mariana and Caroline): a Geostatistical Analysis by R", in *Problems of tectonics of continents and oceans, Proceedings of the 51st Tectonics Meeting, Vol. 1*, edited by K. E. Degtyarev (Institute of Geology RAS, Jan. 2019), pp. 347–352.</footnote>

<footnote n="65">⁶⁵P. Lemenkova, "Factor Analysis by R Programming to Assess Variability Among Environmental Determinants of the Mariana Trench", *Turkish Journal of Maritime and Marine Sciences* **4**, 146–155 (2018).</footnote>

<footnote n="66">⁶⁶P. Lemenkova, "R scripting libraries for comparative analysis of the correlation methods to identify factors affecting Mariana Trench formation", *Journal of Marine Technology and Environment* **2**, 35–42 (2018).</footnote>

<footnote n="67">⁶⁷P. Lemenkova, "Hierarchical Cluster Analysis by R language for Pattern Recognition in the Bathymetric Data Frame: a Case Study of the Mariana Trench, Pacific Ocean", in *Virtual simulation, prototyping and industrial design, Proceedings 5th Int’l Conference Issue 5, Vol. 2*, edited by M. N. Krasnyansky (Nov. 2018), pp. 147–152, ISBN: 978-5-8265-1997-4.</footnote>
# Appendices
# Appendix A

## Programming codes

### A.1 Octave/Matlab language

#### A.1.1 Octave/Matlab script for cartographic visualization of the bathymetric profiles

```matlab
1 # Script to plot cross-section bathymetric profile (here: 10 profiles, Kuril-Kamchatka Trench).
2 # cd /Users/pauline/Documents/Octave
3 # pwd
4 # load table into Octave
5 P = dlmread('table_10KKT_N.csv');
6 P
7 # assign variables
8 K = P(:,1); % assign 400-kilometer cross-section line (km) to x axis
9 D1 = P(:,2); % assign depths to y axis
10 D2 = P(:,3); % assign depths to y axis
11 D3 = P(:,4); % assign depths to y axis
12 D4 = P(:,5); % assign depths to y axis
13 D5 = P(:,6); % assign depths to y axis
14 D6 = P(:,7); % assign depths to y axis
15 D7 = P(:,8); % assign depths to y axis
16 D8 = P(:,9); % assign depths to y axis
17 D9 = P(:,10); % assign depths to y axis
18 D10 = P(:,11); % assign depths to y axis
19 # check up variables in the current session
20 whos
21 #
22 # now plot figure
23 figure;
24 clf;
25 hold on;
26 subplot(2,1,1);
27 plot(K, D1, 'r+' , 'markersize', 5 , K, D2, 'go' , 'markersize', 5, K, D3, 'b*' , 'markersize', 5, K, D4, 'mx' ,
28 'markersize', 5, K, D5, 'cv' , 'markersize', 5); % plot x against y
29 grid on;
30 grid minor on;
31 axis tight;
32 set(gca, 'xlim',[-200 200], 'xminortick', 'on');
33 title({'Octave/MATLAB plot: Kuril-Kamchatka Trench (north)' ; 'cross-section profiles 1, 7, 14, 21, 28'},
34 FontSize', 10, 'Color', 'black', 'FontWeight', 'normal', 'FontName', 'Times');
35xlabel('Observations along the 400-km cross-section line', 'FontSize', 8);
36ylabel('Depths, m', 'FontSize', 8);
37x = [0.55 0.50];
38y = [0.85 0.68];
39annotation('textarrow', x, y, 'Color', [0.4940 0.1840 0.5560], 'HeadWidth', 5,
40 'String', 'Kuril-Kamchatka Trench', 'TextColor', [0.6350 0.0780 0.1840],
41 'FontSize', 10, 'FontName', 'Times');
42ylim([-9000 200]);
43xlim([-200 200]);
44axis([-200 200 -9000 200]);
45xticks([-200:50:200]);
```
44
legend ({'profile 1', 'profile 7', 'profile 14', 'profile 21', 'profile 28'}, 'FontSize', 6, 'box', 'off', 'location', 'northeastoutside');
45
subplot(2,1,2);
46
plot(K, D6, 'r&lt;','markersize', 5, K, D7, 'go', 'markersize', 5, K, D8, 'b*','markersize', 5, K, D9, 'mx', 'markersize', 5, K, D10, 'cv', 'markersize', 5); % plot x against y
47
grid on;
48
grid minor on;
49
axis tight;
50
set(gca, 'xlim', [-200 200], 'xminortick', 'on');
51
title({'Octave/MATLAB plot: Kuril-Kamchatka Trench (north)' ; 'cross-section profiles 35, 42, 49, 56, 62'}, 'FontSize', 10, 'Color', 'black', 'FontWeight', 'normal', 'FontName', 'Times');
52
xlabel('Observations along the 400-km cross-section line', 'FontSize', 8);
53
ylabel('Depths', 'm', 'FontSize', 8);
54
dim = [0.2 0.2 0.3 0.2];
55
str = {'Greater Kuril Chain', 'Kuril Islands'};
56
annotation(' textbox ', dim, 'String', str, 'FitBoxToText ', 'on',
57
'FontSize', 10, 'FontName', 'Times');
58
ylim([-9000 200]);
59
xlim([-200 200]);
60
axis([-200 200 -9000 200]);
61
xticks([-200:50:200]);
62
legend ({'profile 35', 'profile 42', 'profile 49', 'profile 56', 'profile 62'},
63
'FontSize', 6, 'box', 'off', 'location', 'northeastoutside');
64
65
#saveas(gcf,' plot_KKT.jpg ');
66
print(' plot_KKTprofilesN ','-dpdf ','-r300 ','-bestfit')

codes/Octave.m

A.2 TeX macro language

A.2.1 LATEX code to plot bathymetric profiles

1 \begin{filecontents*}{MyTab18.csv}
2 ELEV ,y2,x2
3 145.528246366,47.0433461696,-7800 # bathymetric data here in 3 columns
4 \end{filecontents*}
5 \begin{tikzpicture}
6 \begin{axis} [grid=major,minor x tick num=10,minor y tick num=10,
7 colorbar sampled line,coloremap name=bluered,
8 title={Mariana Trench. Bathymetric Profiles Nr.16,17,18},
9 ylabel={Depth (m)},
10 legend entries={Profile18,Profile17,Profile16,},
11 scaled ticks=false,
12 yticklabel style={/pgf/number format/fixed,/pgf/number format/fixed zerofill,}]
13 \addplot+ [scatter,only marks,mark=Mercedes star flipped,coloremap name=bluered,]
14 table [x=x,y=d, col sep=comma] {MyTab16.csv};
15 \addplot+ [scatter, colorbar sampled line,only marks,mark=asterisk,coloremap
16 name=bluered,]
17 table [x=long, y=d, col sep=comma] {MyTab17.csv};
18 \addplot+ [scatter, colorbar sampled line,only marks,mark=10-pointed star,coloremap
19 name=bluered,]
20 table [x=y2,y=ELEV, col sep=comma] {MyTab18.csv};
21 \end{axis}
22 \end{tikzpicture}

codes/Latex-bathymetry.tex
## A.3 AWK language

### A.3.1 AWK shell script for table reshaping

```sh
#!/bin/sh
# Unix prog: awk, mktemp, rm
# AWK script to reshape initial long table.
# Purpose: remove unnecessary rows, only select necessary columns, reshape columns => rows
# Initial table: 12726 rows 5 columns; Output table: 201 rows 11 columns.
cd /Users/pauline/Documents/Octave
pwd
# Unix: mktemp make tempfile
TMPFILE0=$ (mktemp)
TMPFILE1=$ (mktemp)
TMPFILE2=$ (mktemp)
TMPFILE3=$ (mktemp)
TMPFILE4=$ (mktemp)
TMPFILE5=$ (mktemp)
TMPFILE6=$ (mktemp)
TMPFILE7=$ (mktemp)
TMPFILE8=$ (mktemp)
TMPFILE9=$ (mktemp)
TMPFILE10=$ (mktemp)
# awk: reshaped initial GMT table of 62 profiles (select two necessary columns; FS as space).
awk 'BEGIN{FS=" "; OFS=" "} {print $3, $5}' table2.txt > $TMPFILE0
# select only profile 1, save as table as 'table_10pr' with X and Y (location and depths):
awk '/profile -L0-00/,,/profile -L0-01/' $TMPFILE0 > table_10p.csv
# awk: only take Y column (field 5) from the initial table (depths for all profiles, 12726 rows)
awk '{print $5}' table2.txt > $TMPFILE1
# awk: select profile i from the Y column (print section of file between two regex).
# i: 1, 7, 14, 21, 28, 35, 42, 49, 56, 62.
awk '/-L0-07/,,-L0-08/' $TMPFILE1 > table_p07.csv
awk '/-L0-14/,,-L0-15/' $TMPFILE1 > table_p14.csv
awk '/-L0-21/,,-L0-22/' $TMPFILE1 > table_p21.csv
awk '/-L0-28/,,-L0-29/' $TMPFILE1 > table_p28.csv
awk '/-L0-35/,,-L0-36/' $TMPFILE1 > table_p35.csv
awk '/-L0-42/,,-L0-43/' $TMPFILE1 > table_p42.csv
awk '/-L0-49/,,-L0-50/' $TMPFILE1 > table_p49.csv
awk '/-L0-56/,,-L0-57/' $TMPFILE1 > table_p56.csv
awk '/-L0-62/,,EOF/' $TMPFILE1 > table_p62.csv
# awk: add single Y column of the profile i to the table 'table_10p.csv'; save output to 'table_10KKT.csv' (here: Kuril-Kamchatka Trench)
awk '{print $0}' < table_p07.csv | tee check.csv | paste table_10p.csv - > $TMPFILE2
awk '{print $0}' < table_p14.csv | paste $TMPFILE2 - > $TMPFILE3
awk '{print $0}' < table_p21.csv | paste $TMPFILE3 - > $TMPFILE4
awk '{print $0}' < table_p28.csv | paste $TMPFILE4 - > $TMPFILE5
awk '{print $0}' < table_p35.csv | paste $TMPFILE5 - > $TMPFILE6
awk '{print $0}' < table_p42.csv | paste $TMPFILE6 - > $TMPFILE7
awk '{print $0}' < table_p49.csv | paste $TMPFILE7 - > $TMPFILE8
awk '{print $0}' < table_p56.csv | paste $TMPFILE8 - > $TMPFILE9
awk '{print $0}' < table_p62.csv | paste $TMPFILE9 - > $TMPFILE10
# awk: delete header and tail (print only lines which do NOT match regex)
awk '/!-L0-/' $TMPFILE10 > table_10KKT.csv
# remove auxiliary files
rm -f table_p07.csv table_p14.csv table_p21.csv table_p28.csv table_p35.csv table_p42.csv table_p49.csv table_p56.csv table_p62.csv check.csv
rm -f $TMPFILE0 $TMPFILE1 $TMPFILE2 $TMPFILE3 $TMPFILE4 $TMPFILE5 $TMPFILE6 $TMPFILE7 $TMPFILE8 $TMPFILE9
$TMPFILE10
# count number of lines
awk 'END{print NR}' table2.txt
# ans: 12726
awk 'END{print NR}' table_10KKT.csv
# ans: 201
# RESULT: table reshaped. Initial: 12726 rows 5 columns; Output: 201 rows 11 columns.
# Column 1: cross-section line 400 km long (-200:200 km). Columns 2-11: profiles
```

codes/AWK.sh
## A.4 GMT shell/bash scripts

### A.4.1 GMT script for bathymetric mapping, ETOPO1 (here: KKT)

1 #!/bin/sh
2 # Purpose: shaded relief grid raster map from ETOPO1 global data set (here: Kuril-Kamchatka Trench)
3 # GMT modules: gmtset, grdcut, makecpt, grdcimage, psscale, grdcontour, psbasmap, gmtlogo, psconvert
4 # Step-1. Generate a file
5 ps=BathymetryKKT.ps
6 # Step-2. GMT set up
7 gmt set FORMAT_GEO_MAP=dddF \
8 MAP_FRAME_PEN=dimgray \
9 MAP_FRAME_WIDTH=0.1c \
10 MAP TITLE_OFFSET=1c \
11 MAP_ANNOT_OFFSET=0.1c \
12 MAP_TICK_PEN_PRIMARY=thinner, dimgray \
13 MAP GRID_PEN_PRIMARY=thin, white \
14 MAP GRID_PEN_SECONDARY=thinnest, white \
15 FONT TITLE=12p, Palatino-Roman, black \
16 FONT_ANNOT_PRIMARY=7p, Helvetica, dimgray \
17 FONT LABEL=7p, Helvetica, dimgray \
18 # Step-3. Extract a subset of ETOPO1m for the Kuril-Kamchatka Trench area
19 grdcut earth_relief_01m.grd -R140/170/40/60 -Gkkt_relief.nc
20 # Step-4. Make color palette
21 gmt makecpt -Cglobe.cpt -V -T-10000/1000 > myocean.cpt
22 # Step-5. Make raster image
23 gmt grdcimage kkt_relief.nc -Cmyocean.cpt -R140/170/40/60 -JM6i -P -I+a15+ne0.75 -Xc -K > $ps
24 # Step-6. Add legend
25 gmt psscale -Dg135/40+w6.5i/0.15i+v+0.3/0i+m1 -Rkkt_relief.nc -J -Cmyocean.cpt \
26 --FONT LABEL=8p, Helvetica, dimgray \
27 --FONT_ANNOT_PRIMARY=5p, Helvetica, dimgray \
28 -Baf+1"Topographic color scale" \
29 -I0.2 -By+1m -O -K >> $ps
30 # Step-7. Add shorelines
31 gmt grdcontour kkt_relief.nc -R -J -C1000 -W0.1p -O -K >> $ps
32 # Step-8. Add grid
33 gmt psbasmap -R -J \
34 -Bpxg8f2a4 -Bpyg6f3a3 -Bsxg4 -Bsyg3 \
35 -B+t"Bathymetry of the Kuril-Kamchatka Trench and coastal land topography" -O -K >> $ps
36 # Step-9. Add scale, directional rose
37 gmt psbasmap -R -J \
38 --FONT=8p, Palatino-Roman, dimgray \
39 --MAP TITLE_OFFSET=0.3c \
40 -Tdx1.0c/13.3c+w0.3i+f2+1+0.15i \
41 -Lx5.3i/-0.5i+c50+w500k+1"Mercator projection. Scale (km)"+f \
42 -UBL/-15p/-40p -O -K >> $ps
43 # Step-10. Add GMT logo
44 gmt logo -Dx6.2/-2.2+0.1i/0.1i+w2c -O -K >> $ps
45 # Step-11. Add subtitle
46 gmt pstext -R0/10/0/15 -JX10/10 -X0.5c -Y7.1c -N -O \
47 -F+f10p, Palatino-Roman, black+jLB >> $ps << EOF
48 3.0 15.0 ETOPO1 Global Relief Model 1 arc min resolution grid
49 EOF
50 # Step-12. Convert to image file using GhostScript
51 gmt psconvert BathymetryKKT.ps -A0.2c -E720 -Tj -Z
52 #
53 # -Bxg4f2a4 -Byg4f2a4

codes/GMT-01.sh
A.4.2 GMT script for 3D mesh grid modelling, DEM based (here: AT)

1
#!/bin/sh
2
# Purpose: 3D grid, 165/45 azimuth from the ETOPO5 (here: Aleutian Trench)
3
# GMT modules: grdcut, grd2cpt, grdcontour, pscoast, grdview, logo, psconvert
4
# Unix prog: rm
5
# Step-1. Cut grid
6
gmt grdcut earth_relief_05m.grd -R154/220/40/65 -Gat_relief.nc
7
# Step-2. Create color palette
8
gmt grd2cpt @at_relief.nc -Crainbow > rainbowAT.cpt
9
# Step-3. generate a file
10
ps=AT3D165.ps
11
# Step-4. Add contour
12
gmt grdcontour geoid.egm96.grd -JM10c -R154/220/40/65\ 
13
-p165/45 -C1 -A5+f8p,Palatino-Bold -Gd3c -Wthinnest dimgray -Y3c\ 
14
-U/-0.5c/-1c/"Data: 2 min World Geoid Image 9.2, ETOPO 5 arc min grid"\ 
15
-P -K > $ps
16
# Step-5. Add coastlines, ticks, directional rose
17
pscoast -J -R -p165/45 -B8/4NESW -Gdimgray\ 
18
-T216/42/1c\ 
19
--MAP_ANNOT_OFFSET=0.1c -O -K >> $ps
20
# Step-6. Add 3D
21
grdview at_relief.nc -J -R -JZ2i -CrainbowAT.cpt\ 
22
-p165/45 -Qsm -N-7500+glightgray\ 
23
-Wm0.07p -Wf0.1p,red -Wc0.1p,magenta\ 
24
-B8/4/2000: "Bathymetry and topography (m)":ESwZ -S5 -Y4.0c \ 
25
--FONTLABEL=8p,Palatino-Bold,darkblue\ 
26
--FONT_ANNOT_PRIMARY=7p,Helvetica,black \ 
27
--MAP_FRAME_PEN=black -O -K >> $ps
28
# Step-7. Add GMT logo
29
gmt logo -Dx10.5/0.0+0.0.0c/-5.5c+w2c -O -K >> $ps
30
# Step-8. Add title
31
gmt pstext -R0/10/0/10 -Jx1 -X-0.8c -Y0.0c -N -O -K \ 
32
-F+f10p,Palatino-Roman,black+jLB >> $ps << EOF
33
0.0 10.0 Composite overlay of the 3D topographic mesh model
34
0.0 9.5 on top of the 2D geoid contour plot
35
0.0 9.0 Region: the Aleutian Islands and Aleutian Trench, North Pacific Ocean
36
EOF
37
gmt pstext -R0/10/0/10 -Jx1 -X0.0c -Y0.0c -N -O\ 
38
-F+f8p,Palatino-Roman,dimgray+jLB >> $ps << EOF
39
7.0 8.0 Perspective view azimuth: 165/45\232
40
EOF
41
# Step-9. Convert to image file using GhostScript (portrait orientation, 720 dpi)
42
gmt psconvert AT3D165.ps -A0.2c -E720 -Tj -P -Z
43
# Step-10. Clean up
44
rm -f rainbowAT.cpt

codes/GMT-02.sh
A.4.3 GMT script for bathymetry contour mapping (here: KKT)

1 #!/bin/sh
2 # Purpose: bathymetry contour from the ETOPO5 grid global data set (here: Kuril-Kamchatka area)
3 # GMT modules: gmtset, grdcut, grdinfo, grdcontour, psbasemap, psxy, logo, pstext, psconvert
4 # Step-1. Generate a file
5 ps=GMT_JB_bathy_KKT.ps
6 # Step-2. GMT set up
7 gmt set FORMAT_GEO_MAP=dddF \
8 MAP_FRAME_PEN=dimgray \
9 MAP_FRAME_WIDTH=0.08c \
10 MAP_TICK_PEN_PRIMARY=thinner, dimgray \
11 MAP GRID_PEN_PRIMARY=thinnest, dimgray \
12 FONT TITLE=14p, Palatino-Roman, black \
13 FONT_ANNOT_PRIMARY=7p, Helvetica, darkblue \
14 FONT LABEL=7p, Palatino-Roman, dimgray \
15 # Step-3. Cut off the grid
16 gmt grdcut earth_relief_05m.grd -R140/170/40/60 -Gkkt_relief.nc -V
17 gmt grdinfo @kkt_relief.nc
18 # Step-4. Add contour
19 gmt grdcontour @kkt_relief.nc -R140/170/40/60 -JB155/50/45/55/6.0i \
20 -C500 -A1000 -S4 -T+d15p/3p \
21 --FONT_ANNOT_PRIMARY=7p, Palatino-Roman, dimgray \
22 -P -K > $ps
23 # Step-5. Basemap: title, ticks
24 gmt psbasemap -R -J \
25 -Bxg4f2a5 -Byg2f1a2 \
26 -B+t"Bathymetric contour of the Kuril-Kamchatka Trench area" \
27 -U -O -K >> $ps
28 # Step-6. Add scale, directional rose
29 gmt psbasemap -R -J \
30 --FONT=8p, Palatino-Roman, dimgray \
31 --MAP TITLE_OFFSET=0.3c \
32 -Tdg144/57.5+w0.5c+f2+1 \
33 -Lx5.1i/-0.5i+c50+w1000k+1"Conic equal-area Albers projection. Scale at 50\232N, km"+f \
34 -O -K >> $ps
35 # Step-7. Study area
36 gmt psbasemap -R -J \
37 -D144/40.2/162/51r -F+pthin, red \
38 -O -K >> $ps
39 # Step-8. Study area label annotation
40 gmt psxy -R -J -Wthin -O -K \
41 -Sqn1:+f12p, Times-Roman, red+1"Study Area"+c5p+pthick, red+o << EOF >> $ps
42 144.2 41.1
43 160.8 41.5
44 EOF
45 # Step-9. Add logo
46 gmt logo -R -J -Dx6.5/-2.2+o0.1i/0.1i+w2c -O -K >> $ps
47 # Step-10. Add text
48 gmt pstext -R0/8.5/0/11 -Jxli -F+f7p, Helvetica, dimgray+jCB -N -O -K >> $ps << END
49 0.34 -0.5 Bathymetry: ETOPO 5 arc min Global Relief Model
50 END
51 gmt pstext -R -J -F+f7p, Helvetica, dimgray+jCB -N -O >> $ps << EOF
52 4.8 -0.7 Standard parallels at 45\232 and 55\232 N
53 EOF
54 # Step-11. Convert to image file using GhostScript
55 gmt psconvert GMT_JB_bathy_KKT.ps -A0.2c -E720 -Tj -Z

codes/GMT-03.sh
A.4.4 GMT script for geoid modelling (here: KKT)

```bash
#!/bin/sh
# Purpose: Geoid model map with coastline and grid crosses
# Equidistant conic prj (here: Kuril-Kamchatka Trench). Small inserted World map: Eckert VI prj.
# GMT modules: gmtset, grd2cpt, grdimage, pscoast, grdcontour, psbasemap, psscale, psimage, logo, pstext, psconvert
# Step-1. Generate a file
ps=Geoid_KKT.ps
# Step-2. GMT set up
gmt set FORMAT_GEO_MAP=dddF \
    MAP TITLE OFFSET=1c \
    MAP FRAME PEN=dimgray \
    MAP FRAME WIDTH=0.1c \
    MAP TICK PEN_PRIMARY=thinner, dimgray \
    MAP GRID PEN_PRIMARY=thinnest \
    MAP GRID CROSS SIZE PRIMARY=0.1i \
    FONT TITLE=14p, Palatino-Roman, black \
    FONT ANNOT PRIMARY=7p, Helvetica, dimgray \
    FONT LABEL=7p, Helvetica, dimgray \
# Step-3. Generate a color palette table from grid
gmt grd2cpt geoid.egm96.grd -Crainbow > geoid.cpt
# Step-4. Generate geoid image with shading
# Step-5. Add basemap: grid, title, costline
gmt pscoast -R -J -P \
    -V -W0.25p \
    -Df -B+t"Geoid gravitational regional model: Kuril-Kamchatka Trench area" \
    -Bxa4g3f2 -Bya4g3f2 \
    -O -K >> $ps
# Step-6. Add geoid contour
# Step-7. Add scale, directional rose
gmt psbasemap -R -J \
    --FONT=7p, Palatino-Roman, dimgray \
    --MAP ANNOT OFFSET=0.0c \
    --MAP TITLE OFFSET=0.3c \
    -Tdg144/57.5+w0.5c+f2+1 \
    -Lx5.1i/-0.5i+c50+w800k+l"Equidistant conic projection. Scale, km"+f \
    -UBL/-15p/-40p -O -K >> $ps
# Step-8. Add scale, magnetic rose
gmt psbasemap -R -J \
    --FONT=7p, Palatino-Roman, dimgray \
    --FONT ANNOT_PRIMARY=7p \
    --MAP ANNOT OFFSET PRIMARY=0.1c \
    --MAP ANNOT OFFSET SECONDARY=0.1c \
    --LABEL OFFSET=0.1c \
    --MAP TICK PEN_PRIMARY=thinnest, dimgray \
    -Tmg162.5/45.2+w1.5i+d-14.5+t45/10/5+i0.25p, blue+P0.25p, red+1+jCM \
    -O -K >> $ps
# Step-9. Add legend
gmt psscale -R -J -Cgeoid.cpt \
    -Dg135/40+w4.7i/0.15i+v+o1.0/0i+m1 \
    --FONT LABEL=8p, Helvetica, dimgray \
    --FONT ANNOT_PRIMARY=5p, Helvetica, dimgray \
    -Baf+1"Gravitation modelling color scale" \
    -I0.2 -By+1mGal -O -K >> $ps
# Step-10. Insert map (global geoid)
gmt psimage -R -J Geoid_World.jpg -DjTR+w4.3c+o-5.5c/0c -O -K >> $ps
# Step-11. Add logo
gmt logo -R -J -Dx6.5/-2.2+o0.1i/0.1i+w2c -O -K >> $ps
# Step-12. Add subtitle
gmt pstext -R0/10/0/15 -JX10/10 -X0.5c -Y4.5c -N -O -K \
    -F+f10p, Palatino-Roman, black+jLB >> $ps << EOF
3.0 15.0 World Geoid Image version 9.2, 2 min resolution
EOF
# Step-13. Add text
gmt pstext -R -J -X2.5c -Y-6.4c -N -O -K \
```
66 -F+f7p,Palatino-Roman,dimgray+jCB >> $ps << END
67 10.0 0.0 Standard parallels at 45\232 and 55\232 N
68 END
69 # Step-14. Add text
70 gmt pstext -R -J -N -O \
71 -F+f7p,Palatino-Roman,dimgray+jCB >> $ps << END
72 9.7 4.8 Magnetic rose
73 END
74 # Step-15. Convert to image file using GhostScript
75 gmt psconvert Geoid_KKT.ps -A0.2c -E720 -P -Tj -Z

codes/GMT-04.sh

A.4.5 GMT script for geological World map

1 #!/bin/sh
2 # Purpose: Geological map in Eckert VI equal-area pseudocylindrical projection (here: Pacific Ocean)
3 # GMT modules: gmtset, gmtd defaults, pscoast, psxy, psbasemap, pslegend, logo, psconvert
4 # Step-1. Generate file
5 ps=GMT_geology_Wor ld.ps
6 # Step-2. GMT set up
7 gmt set FORMAT_GEO_MAP=dddF \
8 MAP_FRAME_PEN=dimgray \
9 MAP_FRAME_WIDTH=0.1c MAP TITLE_OFFSET=0.3c \
10 MAP TICK PEN_PRIMARY=thinner, dimgray \
11 MAP GRID PEN_PRIMARY=thinner, dimgray \
12 FONT TITLE=12p, Palatino-Roman, black \
13 FONT_ANNOT_PRIMARY=7p, Helvetica, dimgray \
14 FONT LABEL=7p, Palatino-Roman, dimgray
15 # Step-3. Overwrite defaults of GMT
16 gmtd defaults -D > .gmtd defaults
17 # Step-4. Plot coastmap
18 gmt pscoast -R -JKs180/9i -G papayawhip -Slightcyan -W0.25p -Dc \
19 -B+t "Geological features: World map. Central meridian at 180\232, Pacific Ocean" \
20 -Vv -K > $ps
21 # Step-5. Add geology
22 gmt psxy -R -J hotspots.gmt -Sc0.2c -Gred -O -K >> $ps
23 gmt psxy -R -J ridge.gmt -Sf0.5c/0.15c+1+t -Wthin, purple -Gpurple -O -K >> $ps
24 gmt psxy -R -J transform.gmt -Sf0.5c/0.15c+1+t -Wthin, orange -Gorange -O -K >> $ps
25 gmt psxy -R -J trench.gmt -Sf1.5c/0.2c+1+t -Wthick, red -Gred -O -K >> $ps
26 gmt psxy -R -J LIPS.2001. points.gmt -Sc0.1c -Gyellow -O -K >> $ps
27 gmt psxy -R -J LIPS.2011.gmt -L -Gp7+bred+f-+r300 -Wthinnest, red -O -K >> $ps
28 gmt psxy -R -J ophiolites.gmt -Sc0.1c -Gmagenta -O -K >> $ps
29 gmt psxy -R -J volcanoes.gmt -Sc0.1c -Ggreen -O -K >> $ps
30 # Step-6. Add grid, scale bar
31 gmt psbasemap -R -J \
32 -Bpx30g30 -Bpy10g10 \
33 -Lx11.4c/-1.3c+c50+w10000k+1"Eckert VI equal-area pseudocylindrical projection. Scale (km)"+f \
34 -UBL/45p/-40p -O -K >> $ps
35 # Step-7. Add legend
36 gmt pslegend -R -J -Dx19.0/-2.0+w5.2c+o0.0/0.2c -F+pthin+ithinner+gwhite \
37 -FONT_ANNOT_PRIMARY=8p -O -K << EOF >> $ps
38 S 0.3c c 0.2c red 0.15p 1.0c Hotspots
39 S 0.3c f+1+t 0.7c red 0.15p 1.0c Trench
40 S 0.3c f+1+t 0.7c purple 0.15p 1.0c Ridge
41 S 0.3c f+1+t 0.7c orange 0.15p 1.0c Transform lines
42 S 0.3c c 0.2c magenta 0.15p 1.0c Ophiolites
43 S 0.3c r 0.5c p7+bred+f+r300- 0.15p 1.0c Large igneous provinces (LIPs)
44 S 0.3c c 0.2c yellow 0.15p 1.0c Spots of LIPs
45 S 0.3c c 0.2c green 0.15p 1.0c Volcanoes
46 EOF
47 # Step-8. Add logo
48 gmt logo -R -J -Dx10.5/-2.7+o0.1i/0.1i+w2c -O >> $ps
49 # Step-9. Convert to image file using GhostScript (landscape orientation, 720 dpi)
50 gmt psconvert GMT_geology_Wor ld.ps -A0.5c -E720 -Tj -Z

codes/GMT-05.sh

ix

Polina Lemenkova:

Deep-Sea Trenches of the Pacific Ocean: ...Data Modeling by GMT, Python and R
A.4.6 GMT script for regional geological map (here: MAT)

1 #!/bin/sh
2 # Purpose: Map of geological settings (here: Middle America Trench). Lambert conic conformal prj.
3 # GMT modules: gmtset, gmtdefaults, makecpt, grdcut, grdinfo, pscoast, psbasemap, grdcontour, project, psxy,
4 # Generate a file
5 ps=GMT_JL_geol_MAT.ps
6 # GMT set up
7 gmt set FORMAT_GEO_MAP=dddF \
8 MAP_FRAME_PEN dimgray \
9 MAP_FRAME_WIDTH 0.1c \
10 MAP TITLE_OFFSET 0.5c \
11 MAP_ANNOT_OFFSET 0.1c \
12 MAP_TICK_PEN_PRIMARY thinner, dimgray \
13 MAP GRID_PEN_PRIMARY thinner, dimgray \
14 MAP GRID_PEN_SECONDARY thinnest, dimgray \
15 FONT TITLE 12p, Palatino-Roman, black \
16 FONT_ANNOT_PRIMARY 7p, Helvetica, dimgray \
17 FONT LABEL 7p, Helvetica, dimgray \
18 # Overwrite defaults of GMT
19 gmtdefaults -D > .gmtdefaults
20 # Cut off the relief map from ETOPO5
21 gmt grdcut earth_relief_05m.grd -R263/278/7/17 -Gmat_relief.nc -V
22 # Add coastlines; color areas: land-green water-blue
23 gmt pscoast -R263/278/7/17 -JL270/12/10/14/6i -P \
24 -W0.1p -Gpapayawhip -Slightcyan -Df -K > $ps
25 # Add elemens of basemap: title, grids, rose, scale, time stamp
26 gmt psbasemap -R -J \
27 -B+t"Geological and tectonic setting of the Guatemala Trench area" \
28 -Bpxg4f2a2.5 -Bpyg2fla2 -Bsxg4 -Bsyg4\ 29 -Lx12.6c/-2.8c+c50+w500k+1"Lambert conic conformal projection. Scale at 12\232N, km"+f \
30 -O -K >> $ps
31 # Add directional rose
32 gmt psbasemap -R -J \
33 --FONT=7p, Palatino-Roman, darkblue \
34 --MAP TITLE_OFFSET=0.3c \
35 -Tdg264/8+w0.5c+f2+1 \
36 -UBL/.6c/-2.8c -O -K >> $ps
37 # Add bathymetric contours
38 gmt grdcontour @mat_relief.nc -R -J -C500 \
39 -A2000+f7p, Times-Roman -S4 -T+d15p/3p \
40 -W0.1p -O -K >> $ps
41 # Add geological lines and points
42 gmt makecpt -Crainbow -T0/700/50 -Z > rain.cpt
43 gmt psxy -R -J trench.gmt -Sf1.5c/0.2c+1+t -Wthick, darkred -Gdarkred -O -K >> $ps
44 gmt psxy -R -J ophiolites.gmt -Sc0.2c -Ggoldenrod1 -W0.08 -O -K >> $ps
45 gmt psxy -R -J volcanoes.gmt -St0.2c -Gred -Wthinnest -O -K >> $ps
46 gmt psxy -R -J ridge.gmt -Sf0.5c/0.2c+1+t -Wthinnest, black -Ggreen -O -K >> $ps
47 gmt psxy -R -J LIPS.2011.gmt -L -Gpink1@50 -Wthinnest, red -O -K >> $ps
48 # Add fracture zones and magnetic anomalies
49 gmt psxy -R -J GSFML_SF_FZ_KM.gmt -Wthick, violet -O -K >> $ps
50 gmt psxy -R -J GSFML_SF_FZ_RM.gmt -Wthick, orange -O -K >> $ps
51 # Add slab contours
52 gmt psxy -R -J SC_camerica.txt -W0.6p, bisque4, -O -K >> $ps
53 # Add magnetic lineation picks (gray-colored)
54 gmt psxy -R -J GSFML.global.picks.gmt -Sc0.2c -Wthinnest, cadetblue -O -K >> $ps
55 # Add text
56 gmt pstext -R -J -N -O -K \
57 -F+f10p, Palatino-Roman, brown+jLB >> $ps << EOF
58 267.0 10.0 Cocos Plate
59 EOF
60 # Text names
61 gmt pstext -R -J -X0.0c -Y0.0c -N -O -K \
62 -F+f10p, Palatino-Roman, brown+jLB >> $ps << EOF
63 274.2 14.3 Caribbean Plate
64 272.0 15.5 Chortis Block
65 267.5 16.5 North American Plate
66 EOF
67 gmt pstext -R -J -X0.0c -Y0.0c -N -O -K \
68 -F+jTL+f8p,Times-Roman,black+jLB+a-340 -Gwhite@30 -Wthinnest >> $ps << EOF
69 270.0 15.8 Motagua Fault
70 EOF
71 gmt pstext -R -J -X0.0c -Y0.0c -N -O -K \
72 -F+jTL+f8p,Times-Roman,black+jLB+a-2 -Gwhite@30 -Wthinnest >> $ps << EOF
73 268.3 15.6 Polochic Fault
74 EOF
75 gmt pstext -R -J -X0.0c -Y0.0c -N -O -K \
76 -F+jTL+f8p,Times-Roman,brown+jLB+a-37 -Gwhite@30 -Wthinnest >> $ps << EOF
77 274.0 10.0 Nicoya Peninsula
78 EOF
79 gmt pstext -R -J -X0.0c -Y0.0c -N -O -K \
80 -F+jTL+f8p,Times-Roman,black+jLB+a-305 -Gwhite@30 -Wthinnest >> $ps << EOF
81 273.5 14.1 Guayape Fault
82 EOF
83 gmt pstext -R -J -X0.0c -Y0.0c -N -O -K \
84 -F+jTL+f8p,Times-Roman,blue=0.1p,black+jLB+a-350 >> $ps << EOF
85 264.7 15.5 Gulf of
86 264.7 15.2 Tehuantepec
87 271.0 12.7 Gulf of
88 271.3 12.5 Fonseca
89 EOF
90 gmt pstext -R -J -X0.0c -Y0.0c -N -O -K \
91 -F+jTL+f9p,Times-Roman,brown+jLB+a-315 >> $ps << EOF
92 263.4 12.8 Tehuantepec Ridge
93 275.4 7.3 Cocos
94 275.6 7.1 Ridge
95 EOF
96 gmt pstext -R -J -X0.0c -Y0.0c -N -O -K \
97 -F+jTL+f9p,Times-Roman,brown+jLB+a-337 >> $ps << EOF
98 272.5 16.2 Cayman Ridge
99 EOF
100 gmt pstext -R -J -X0.0c -Y0.0c -N -O -K \
101 -F+jTL+f9p,Times-Roman,brown=0.1p,black+jLB+a-28 >> $ps << EOF
102 271.3 14.0 Pacific
103 EOF
104 gmt pstext -R -J -X0.0c -Y0.0c -N -O -K \
105 -F+jTL+f9p,Times-Roman,brown=0.1p,black+jLB+a-36 >> $ps << EOF
106 273.4 12.8 Volcanic
107 EOF
108 gmt pstext -R -J -X0.0c -Y0.0c -N -O -K \
109 -F+jTL+f9p,Times-Roman,brown=0.1p,black+jLB+a-39 >> $ps << EOF
110 275.4 11.0 China
111 EOF
112 gmt pstext -R -J -X0.0c -Y0.0c -N -O -K \
113 -F+jTL+f10p,Times-Roman,blue+jLB+a-25 >> $ps << EOF
114 264.5 10.0 Pacific Ocean
115 EOF
116 # Text names
117 gmt pstext -R -J -X0.0c -Y0.0c -N -O -K \
118 -F+jTL+f10p,Times-Roman,blue+jLB+a-25 >> $ps << FIN
119 266.5 14.0 Middle
120 269.5 12.7 America
121 FIN
122 gmt pstext -R -J -X0.0c -Y0.0c -N -O -K \
123 -F+jTL+f10p,Times-Roman,blue+jLB+a-21 >> $ps << FIN
124 268.2 12.5 (Global)
125 FIN
126 # Text names
127 gmt pstext -R -J -X0.0c -Y0.0c -N -O -K \
128 -F+jTL+f10p,Times-Roman,blue+jLB+a-45 >> $ps << FIN
129 272.7 11.0 Trench
130 FIN
131 # Arrows of tectonic plates movements
132 gmt psxy -R -J -Sv0.5c+bt+ea -Gmidnightblue@30 -W1.0p -O -K << EOF >> $ps
133 265.0 11.5 50 2c
134 267.5 10.5 50 2c
135 270.0 9.5 50 2c
136 272.0 14.5 180 1c
137 272.2 14.5 0 1c
138 EOF
139
140 # Add legend
141 gmt pslegend -R -J -Dx0.5/-2.2+w14.0c+o0.1/0.1c \
142 -F+pthin+ithinner+gwhite \
143 --FONT_annot_PRIMARY=8p -O -K << FIN >> $ps
144 N 3
145 S 0.3c f+1+t 0.7c darkred 0.01c 1.0c Guatemala Trench
146 S 0.3c f+1+t 0.7c green 0.01c 1.0c Ridge
147 S 0.3c c 0.2c goldenrod1 0.01c 1.0c Ophiolites
148 S 0.3c t 0.2c red 0.01c 1.0c Volcanoes
149 S 0.3c v 0.8c midnightblue 0.01c 1.0c Tectonic plates movements
150 S 0.3c - 0.8c - 0.5p,orange 1.0c Fracture zones
151 S 0.3c - 0.7c - 0.5p,violet 1.0c Magnetic anomaliy lines
152 S 0.3c - 0.7c - 0.6p,bisque4,- 1.0c Tectonic slabs
153 S 0.3c c 0.2c -W0.25p,cadetblue 0.01c 1.0c Magnetic lineation picks
154 S 0.3c r 0.5c pink1@50 0.01c 1.0c Large igneous provinces
155 FIN
156 # Add text
157 gmt pstext -R -J -N -O -K \
158 -F+f7p,Palatino-Roman, dimgray+jLB >> $ps << END
159 274.0 3.8 Standard parallels at 10 and 14 N
160 END
161 # Add subtitle
162 gmt pstext -R -J -N -O -K \
163 -F+f10p,Palatino-Roman,black+jLB >> $ps << EOF
164 266.5 17.7 Bathymetry: ETOPO 5 arc min Global Relief Model
165 EOF
166 # Add GMT logo
167 gmt logo -R -J -Dx5.0/0.0c+o1.6c/-3.4c+w2c -O >> $ps
168 # Convert to image file using GhostScript (portrait orientation, 720 dpi)
169 gmt psconvert GMT_JL_geol Mat.ps -A1.2c -E720 -Tj -P -Z

codes/GMT-06.sh
A.4.7 GMT script for free-air gravity modelling (here: KKT)

1 #!/bin/sh
2 # Purpose: Gravity model map. Mercator prj (here: Kuril-Kamchatka Trench).
3 # GMT modules: gmtset, img2grd, grd2cpt, grdimage, pscoast, psbasemap, psscale, logo, pstext, psconvert
4 # Step-1. Generate a file
5 ps=Grav_KKT.ps
6 # Step-2. GMT set up
7 gmt set FORMAT_GEO_MAP=dddF \
8 MAP TITLE_OFFSET=1c \
9 MAP_FRAME_PEN=dimgray \
10 MAP_FRAME_WIDTH=0.1c \
11 MAP TICK_PEN_PRIMARY=thinner, dimgray \
12 MAP GRID_PEN_PRIMARY=thinnest, gray30 \
13 MAP GRID_CROSS_SIZE_PRIMARY=0.5c \
14 MAP ANNOT_OFFSET=0.1c \
15 FONT TITLE=14p, Palatino-Roman, black \
16 FONT ANNOT_PRIMARY=7p, Helvetica, dimgray \
17 FONT LABEL=7p, Helvetica, dimgray \
18 MAP LABEL_OFFSET=0.1c
19 # Step-3. Extract subset of img file in Mercator or Geographic format
20 img2grd grav_27.1.img -R140/170/40/60 -Ggrav.grd -T1 -I1 -E -S0.1 -V
21 # Step-4. Generate a color palette table from grid
22 gmt grd2cpt grav.grd -Crainbow > grav.cpt
23 # Step-5. Generate gravity image with shading
24 gmt grdimage grav.grd -I+a45+nt1 -R140/170/40/60 -JM6i -Cgrav.cpt -P -K > $ps
25 # Step-6. Add basemap: grid, title, costline
26 gmt pscoast -R -J -P \
27 -V -W0.25p \
28 -Df -B+t"Marine free-air gravity anomaly for the Kuril-Kamchatka Trench area" \
29 -Bxa4g3f2 -Bya4g3f2 \
30 -O -K >> $ps
31 # Step-7. Add scale, directional rose
32 gmt psbasemap -R -J \
33 --FONT=8p, Palatino-Roman, dimgray \
34 --MAP ANNOT_OFFSET=0.15c \
35 -Tdg143/58.5+w0.5c+f2+1 \
36 -Lx5.0i/-0.5i+c50+w800k+1"Mercator projection. Scale, km"+f \
37 -UBL/-15p/-40p -O -K >> $ps
38 # Step-8. Add legend
39 gmt psscale -R -J -Cgrav.cpt \
40 -Dg135/40+w15.0c/0.5c+v+o0.7/0i+m1 \
41 --FONT LABEL=7p, Helvetica, dimgray \
42 --FONT ANNOT_PRIMARY=7p, Helvetica, dimgray \
43 --MAP ANNOT_OFFSET=0.1c \
44 --MAP LABEL_OFFSET=0.1c \
45 -Baf+1"Marine free-air gravity anomaly color scale" \
46 -I0.2 -By+1mGal -O -K >> $ps
47 # Step-0. Add logo
48 gmt logo -R -J -Dx6.5/-2.2+o0.1i/0.1i+w2c -O -K >> $ps
49 # Step-10. Add subtitle
50 gmt pstext -R0/10/0/15 -JX10/10 -X0.5c -Y7.0c -N -O \
51 -F+f10p, Palatino-Roman, black+jLB >> $ps << EOF
52 3.0 15.0 Global gravity grid from CryoSat-2 and Jason-1, 1 min resolution
53 EOF
54 # Step-11. Convert to image file using GhostScript (portrait orientation, 720 dpi)
55 gmt psconvert Grav_KKT.ps -A0.2c -E720 -Tj -P -Z

codes/GMT-07.sh
A.4.8 GMT script for generating and plotting stacked cross-sectioning bathymetric pro-
files (here: MAT). Profiles info: 400 km long, spaced 20 km, sampled every 2km

1 #!/bin/sh
2 # Purpose: Generating and plotting stacked cross-sectioning bathymetric track profiles. Here: Guatemala Trench (MAT). Profiles info: 400 km long, spaced 20 km, sampled every 2km
3 # GMT modules: grdcut, makecpt, grimage, psscale, grdcontour, psbasemap, psxy, grdtrack, convert, pstext, logo, psconvert
4 # Unix progs: echo, rm, cat
5 # Step-1. Generate a file
6 ps=crossMAT.ps
7 # Step-2. GMT set up
8 gmt set FORMAT_GEO_MAP=dddF \
9 MAP_FRAME_PEN=dimgray \
10 MAP_FRAME_WIDTH=0.1c \
11 MAP TITLE_OFFSET=0.5c \
12 MAP_ANNOT_OFFSET=0.2c \
13 MAP TICK_PEN_PRIMARY=thinnest, dimgray \
14 MAP GRID_PEN_PRIMARY=thinnest, white \
15 MAP GRID_PEN_SECONDARY=thinnest, white \
16 FONT TITLE=12p, Palatino-Roman, black \
17 FONT_ANNOT_PRIMARY=9p, Palatino-Roman, dimgray \
18 FONT LABEL=10p, Palatino-Roman, dimgray \
19 # Step-3. Overwrite defaults of GMT
20 gmtdefaults -D > .gmtdefaults
21 # Step-4. Extract a subset of ETOPO1m for the Middle America Trench area
22 grdcut earth_relief_01m.grd -R263/278/7/17 -Gmat_relief.nc
23 # Step-5. Make color palette
24 gmt makecpt -Cterra -V -T-6500/2500 > myoceanMAT.cpt
25 # Step-6. Make raster image
26 gmt grimage mat_relief.nc -CmyoceanMAT.cpt -R263/278/7/17 -JM6i \
27 -P -I+a15+ne0.75 -Xc -K > $ps
28 # Step-7. Add color legend
29 gmt psscale -Dg260/7+w10.3c/0.4c+v+o0.3/0i+m1 -Rmat_relief.nc -J -CmyoceanMAT.cpt \
30 --FONT LABEL=8p, Helvetica, dimgray \
31 --FONT_ANNOT_PRIMARY=5p, Helvetica, dimgray \
32 -Baf+1"Color scale legend: depth and height elevations (m)" \
33 -I0.2 -By+1m -O -K >> $ps
34 # annotation
35 echo "263.3 16.7 B" | gmt pstext -R -J -F+jTL+f20p,black -Gfloralwhite -W0.5p -O -K >> $ps
36 # Step-8. Add shorelines
37 gmt grdcontour mat_relief.nc -R -J -C500 \
38 -B+t"Cross-sectional profiles of the Guatemala Trench on the selected segment" \
39 -W0.1p -O -K >> $ps
40 # Step-9. Add grid
41 gmt psbasemap -R -J \
42 -Lx13.0c/-0.5i+c50+w400k+1"Mercator projection. Scale (km)"+f \
43 -Bpxg4f2a2 -Bpyg6f2a2 -Bsxg2 -Bsyg2 \
44 --FONT=8p, Palatino-Roman, dimgray \
45 -UBL/-15p/-35p -O -K >> $ps
46 # Step-10. Add directional rose
47 gmt psbasemap -R -J \
48 --FONT=7p, Palatino-Roman, white \
49 --MAP TITLE_OFFSET=0.3c \
50 -Tdx1.0c/1.0c+w0.3i+f2+1+o0.15i -O -K >> $ps
51 # Step-11. Select two points along the Middle America Trench
52 cat << EOF > trenchMAT.txt
53 268.4 13.0
54 271.9 11.6
55 EOF
56 # Step-12. Plot trench segment and end points
57 gmt psxy -Rmat_relief.nc -J -W2p, red trenchMAT.txt -O -K >> $ps # my line
58 gmt psxy -R -J -Sc0.15i -Gred trenchMAT.txt -O -K >> $ps # points
59 # Step-13. Generate cross-track profiles 400 km long, spaced 10 km, sampled every 2km
60 # and stack these using the mean, write stacked profile
61 gmt grdtrack trenchMAT.txt -Gmat_relief.nc -C400k/2k/10k+v -Sa+sstackMAT.txt > tableMAT.txt
62 # and stack these using the median, write stacked profile
63 # gmt grdtrack trenchMAT.txt -Gmat_relief.nc -C400k/2k/20k+v -Sm+sstackMAT.txt > tableMAT.txt
```
gmt psxy -R -J -W0.5p,yellow tableMAT.txt -O -K >> $ps
# Step-14. Add text annotation
gmt pstext -R -J -F+f10,Palatino-Roman,white -O -K >> $ps << END
192 47.5 profiles 400 km long, 20 km spaced
192 46.5 samples every 2 km along each profile
180 57 Pacific Ocean
END
# Step-15. Show upper/lower values encountered as an envelope
gmt convert stackMAT.txt -o0,5 > envMAT.txt
gmt convert stackMAT.txt -o0,6 -I -T >> envMAT.txt
# Step-16. Plot graph (statistical mean for the profiles)
gmt psxy -R-200/200/-7000/2000 -JX15.2c/5c -Y13.0c envMAT.txt -W0.5p \
-Bpxag100f10+1"Distance from trench (km)" \
-Bpya2000gf+1"Depth (m)" \
-Bsxg50 -Bsyg1000 \
--FONT_ANNOT_PRIMARY=9p,Palatino-Roman dimgray \
--MAPLABEL_OFFSET=0.1c \
--MAPlegrid_pEn_pErIarIty=thinner, dimgray \
--MAPlegrid_pEnSECONDary=thinnest, dimgray -BWeSn \
--FONTopar=10p,Palatino-Roman dimgray -BWeSn \
-Glightgray -O -K >> $ps
gmt psxy -R -J -W1.0p -Ey+p0.2p stackMAT.txt -O -K >> $ps
gmt psxy -R -J -W1.0p,red stackMAT.txt -O -K >> $ps
# Step-17. Add test annotations
echo "0 1500 Mean stacked profile with error bars" | gmt pstext -R -J -Gwhite -F+jTC+f10p,red -O -K >> $ps
echo "120 -3000 Caribbean Plate" | gmt pstext -R -J -F+jTC+f10p,orangered4 -Gwhite -O -K >> $ps
echo "-10 0 Guatemala Trench" | gmt pstext -R -J -F+f10p,orangered4+jTC -Gwhite -O -K >> $ps
echo "-100 -5000 Cocos Plate" | gmt pstext -R -J -F+jTC+f10p,orangered4 -Gwhite -O -K >> $ps
echo "140 -1000 Chortis block" | gmt pstext -R -J -F+jTL+f10p,darkbrown -Gwhite -O -K >> $ps
echo "15 -5500 Oceanward Forearc" | gmt pstext -R -J -F+jTL+f10p,darkbrown+a-310 -Gwhite -O -K >> $ps
echo "-190 1500 A" | gmt pstext -R -J -F+jTL+f18p,black -Gfloralwhite -W0.5p -O -K >> $ps
# Arrow
gmt psxy -R -J -Sv0.15i+bc+ea -Gyellow -W0.5p -O -K << EOF >> $ps
-3 -1000 270 2.2c
EOF
# Step-18. Add GMT logo
gmt logo -Dx6.2/-14.7+0.25c/1.5c+w2c -O >> $ps
# Step-19. Clean up
#rm -f z.cpt trenchA2.txt tableA2.txt envA2.txt stackA2.txt
# Step-20. Convert to image file using GhostScript (portrait orientation, 720 dpi)
gmt psconvert crossMAT.ps -A0.2c -E720 -Tj -P -Z
```

codes/GMT-08.sh
A.4.9 GMT script for topographic surface modelling from the xyz ASCII data (here:
MT)

1 #!/bin/sh
2 # Purpose: Surface modelling of the topography along the Mariana Trench
3 # GMT modules: gmtset, gmtdefaults, makecpt, gmtinfo, blockmean, surface, grdgradient, grdimage, psbasmap, psscale, gmtlogo, pstext, psconvert
4 # Step-1. Generate a file
5 ps=SurfaceTMT.ps
6 # Step-2. GMT set up
7 gmt set FORMAT_GEO_MAP=dddF \
8 MAP_FRAME_PEN=dimgray \
9 MAP_FRAME_WIDTH=0.1c MAP TITLE_OFFSET=1.3c \
10 MAP ANNот OFFSET=0.1c MAP TICK_PEN_PRIMARY=thinner, dimgray \
11 MAP JRD_PEN_PRIMARY=thin, dimgray \
12 MAP JRD_PEN_SECONDARY=thinnest, dimgray \
13 F ont_TITLE=12p, Palatino-Roman, black \
14 F ont ANNот PRIMARY=6p, Palatino-Roman, dimgray \
15 F ont JABEL=6p, Palatino-Roman, dimgray \
16 # Step-3. Overwrite defaults of GMT
17 gmtdefaults -D > .gmd defaults
18 # Step-4. Download data:
19 ### http://topex.ucsd.edu/cgi-bin/get_data.cgi
20 ### E-144-162;N40-51.
21 # Step-5. Check up dimensions of the table (data range)
22 gmt info topo MT. xyz
23 # output: topo MT. xyz: N = 3815189 <120.0083/160.0083> <5.002/30.0019> <-10913/3559>
24 # Step-6. Make color palette
25 gmt makecpt -CGMT_sealand.cpt -V -T-11000/4000 > surfaceMT.cpt
26 # Step-7. Generate 1 by 1 minute block mean values from the raw ASCII data (xyg table)
27 gmt blockmean topo MT. xyz -R120/160/5/30 -I1m -Vv > topo MT_BM. xyg
28 # Step-8. Generate grid from xyz table format
29 gmt surface topo MT_BM. xyg -R120/160/5/30 -T0.25 -I30s -GSurface_MT. nc -Vv
30 # Step-9. Make gradient illumination with azimuth 45 degree
31 gmt grdgradient Surface_MT. nc -GSurface_MT. int -A0/45 -Ne1 -fg
32 # Step-10. Make raster image
33 gmt grdimage Surface_MT. nc -CsurfaceMT.cpt -R120/160/5/30 -JM6i -P -ISurface_MT. int -Xc -K > $ps
34 # Step-11. Add grid
35 gmt psbasmap -R -J \
36 -Bpxg6f2a2 -Bpyg6fla2 -Bsxg2 -Bsyg2 \
37 -B+t"Surface modelling of the topography along the Mariana Trench" -O -K >> $ps
38 # Step-12. Add scale, directional rose
39 gmt psbasmap -R -J \
40 --FONT=8p, Palatino-Roman, dimgray \
41 --MAP TITLE_OFFSET=0.2c \
42 -Tdx0.8c/9.0c+w0.3i+f2+1+o0.0c \
43 -Lx5.3i/-0.5i+c50+w600k+l"Mercator projection. Scale (km)"+f \
44 -UBL/-15p/-40p -O -K >> $ps
45 # Step-13. Add color legend
46 gmt psscale -R -J -CsurfaceMT.cpt \
47 -Dg120/4+w10.0c/0.4c+v+o-1.8/0.2c+ml \
48 --FONT JABEL=7p, Helvetica, dimgray \
49 --FONT ANNот PRIMARY=5p, Helvetica, dimgray \
50 -Baf+1"Surface topographic model color scale" \
51 -I0.2 -By+1m -O -K >> $ps
52 # Step-14. Add GMT logo
53 gmt logo -Dx6.2/-2.2+o0.1i/0.1i+w2c -O -K >> $ps
54 # Step-15. Add subtitle
55 gmt pstext -R0/10/0/15 -JX10/10 -X0.0c -Y2.2c -N -O \
56 -F+f9p, Palatino-Roman, black+jLB >> $ps << EOF
57 1.2 13.7 Modelling: GMT surface module, tension factor of the continuous curvature splines 0.25
58 0.5 13.2 Input raw table data: global 1-min grid resolution in ASCII XYZ-format, applied blockmean filter.
59 1.0 12.7 Output spatial model: 30-sec grid spacing in netCDF format, shading azimuth gradient: 45\232
60 EOF
61 # Step-16. Convert to image file using GhostScript
62 gmt psconvert SurfaceTMT.ps -A0.2c -E720 -P -Tj -Z

codes/GMT-09.sh
A.4.10 GMT script for gridding xyz data by Nearest Neighbor algorithm (here: KKT)

1 #!/bin/sh
2 # Purpose: gridding XYZ data by nearest neighbor algorithm, here: Kuril-Kamchatka Trench.
3 # GMT modules: gmtdset, gmtd defaults, gmtdinfo, gmtd convert, nearneighbor, grdcontour, pscoast, pstext, gmtlogo, psconvert
4 # Step-1. Generate a file
5 ps=GMT_NNgrid_KKT.ps
6 # Step-2. GMT set up
7 gmtd set FORMAT_GEO_MAP=dddF \
8 MAP_FRAME_PEN dimgray \
9 MAP_FRAME_WIDTH 0.1c \
10 MAP TITLE_OFFSET 1.0c \
11 MAP_ANNOT_OFFSET 0.1c \
12 MAP_TICK_PEN_PRIMARY thinner, dimgray \
13 MAP GRID_PEN_PRIMARY thinner, dimgray \
14 MAP GRID_PEN_SECONDARY thinner, dimgray \
15 MAP_ANNOT_OFFSET_PRIMARY 0.1c \
16 FONT TITLE 12p, Palatino-Roman, black \
17 FONT_ANNOT_PRIMARY 7p, Palatino-Roman, dimgray \
18 FONT_ANNOT_SECONDARY 7p, Palatino-Roman, dimgray \
19 FONT LABEL 7p, Palatino-Roman, dimgray \
20 # Step-3. Overwrite defaults of GMT
21 gmtd defaults -D > .gmtd defaults
22 # Step-4. Download data:
23 ### http://topex.ucsd.edu/cgi-bin/get_data.cgi
24 ### E-144-162; N40-51.
25 # Step-5. Examine the table
26 gmtd info topo_KKT. xyz
27 # output: N = 1023707 <144.0083/162.0083> <39.9976/50.9968> <-9677/2143>
28 # Step-6. Convert ASCII to binary
29 gmtd convert topo_KKT. xyz -bo > topo_KKT. b
30 # Step-7. Gridding using a nearest neighbor technique which is a local method: No output is given where there are no data.
31 region=`gmtd info topo_KKT. b -I1 -bi3d`
32 gmtd nearneighbor $region -I10m -S40k -Gtopo_NN_KKT. nc topo_KKT. b -bi
33 # Step-8. Add contour lines
34 gmtd grdcontour topo_NN_KKT. nc -R144/40/162/51r -JM6i -P -C500 -A1000 -Gd2i -K > $ps
35 # Step-9. Add coastline
36 gmtd pscoast -R -J -P \
37 -Bpxglfla2 -Bpyglfla2 -Df -Wthinnest \
38 -B+t"Grid contour modelling using Nearest neighbor algorithm. Kuril-Kamchatka Trench area" \
39 -TdjBR+w0.4i+1+o0.15i \
40 -Lx12.5c/-1.3c+c50+w400k+1"Mercator projection, Scale, km"+f \
41 -UBL/-15p/-45p -O -K >> $ps
42 # Step-10. Add subtitle
43 gmtd pstext -R -J -X0.5c -Y0.8c -N -O -K \
44 -F+f10p, Palatino-Roman, black+jLB >> $ps << EOF
45 144.0 51.0 Input table data: global 1-min grid resolution in ASCII XYZ-format, converted to binary
46 EOF
47 # Step-11. Add GMT logo
48 gmtd logo -Dx6.2/-2.2+0.0.3c/-0.2c+w2c -O >> $ps
49 # Step-12. Convert to image file using GhostScript (portrait orientation, 720 dpi)
50 gmtd psconvert GMT_NNgrid_KKT. ps -A0.2c -E720 -Tj -P -Z

codes/GMT-10.sh
A.4.11 GMT script for regression trend1d mixed models (here: AT)

```R
#!/bin/bash
# Purpose: Regression trend1d mixed models for the Aleutian Trench
# GMT modules: gmtset, gmtdefaults, trend1d, psxy, pstext, logo, psconvert
# Unix progs: echo, rm
# Step-1. GMT set up
```
```
gmt set FORMAT_GEO_MAP=dddF \
    MAP_FRAME_PEN=dimgray \
    MAP_FRAME_WIDTH=0.1c \
    MAP TITLE_OFFSET=0.8c \
    MAP_annot_OFFSET=0.2c \
    MAPPEN_PRIMARY=thinner, dimgray \
    MAP_DEFAULT_PEN thin dimgray \
    FONT TITLE=11p, Palatino-Roman, black \
    FONT_annot_PRIMARY=8p, Palatino-Roman, dimgray \
    FONT LABEL=9p, Palatino-Roman, dimgray \
# Step-2. Overwrite defaults of GMT
```
```
gmtdefaults -D > .gmtdefaults
# Step-3. generate file
ps=ATtrends.ps
```
```
# Step-4. Basic LS line y = a + bx
```
```
gmt trend1d -Fxm stackA2.txt -Np1 > modelAT.txt
```
```
gmt psxy -R-200/200/-8800/2000 -JX15c/4c -P \
    -Bpxag100f10 -Bsxg50 -Byaf+u"m" -Bsyg2000 -Wthinnest\ \
    --MAP GRID PEN PRIMARY=thinnest, dimgray \
    --MAP GRID PEN SECONDARY=thinnest, dimgray \
    -BWSne+gmintcream -Sc0.05c -Gred stackA2.txt -X5.0c -K >> $ps
```
```
gmt psxy -R -J -W0.5p, blue modelAT.txt \
    -UBL/-15p/-45p -O -K >> $ps
```
```
echo "m@-2@-(t) = a + b\267t" | gmt pstext -R -J \
    -F+f12p+cBL -Dj0.1i -Gcornsilk -O -K >> $ps
```
```
# Step-5. Basic LS line y = a + bx + cx^2
```
```
gmt trend1d -Fxm stackA2.txt -Np2 > modelAT.txt
```
```
gmt psxy -R -J -Bpxag100f10 -Bsxg50 -Bpyaf+u"m" -Bsyg2000 \
    --MAP GRID PEN PRIMARY=thinnest, dimgray \
    --MAP GRID PEN SECONDARY=thinnest, dimgray \
    -BWSne+gmintcream -Sc0.05c -Gred stackA2.txt -Y5.0c -O -K >> $ps
```
```
gmt psxy -R -J -W0.5p, blue modelAT.txt -O -K >> $ps
```
```
echo "m@-3@-(t) = a + b\267t + c\267t@+2@+" | gmt pstext -R -J \
    -F+f12p+cBL -Dj0.1i -Gcornsilk -O -K >> $ps
```
```
# Step-6. Basic LS line y = a + bx + cx^2 + spatial change
```
```
gmt trend1d -Fxmr stackA2.txt -Np2, f1+11 > modelAT.txt
```
```
gmt psxy -R -J -Bpxag100f10 -Bsxg50 -Bpyaf+u"m" -Bsyg2000 \
    --MAP GRID PEN PRIMARY=thinnest, dimgray \
    --MAP GRID PEN SECONDARY=thinnest, dimgray \
    -BWSne+gmintcream -Sc0.05c -Gred stackA2.txt -Y5.0c -O -K >> $ps
```
```
gmt psxy -R -J -W0.25p, blue modelAT.txt -O -K >> $ps
```
```
echo "m@-5@-(t) = a + b\267t + c\267t@+2@+ + d\267cos(2@~p@~t) + e\267sin(2@~p@~t)" | gmt pstext -R -J \
    -F+f12p+cBL -Dj0.1i -Gcornsilk -O -K >> $ps
```
```
# Step-7. Plot residuals of last model
```
```
gmt psxy -R-200/200/-2000/1000 -J -Bpxag100f10 -Bsxg50 -Bpyaf+u"m" -Bsyg1000 \
    --MAP GRID PEN PRIMARY=thinnest, dimgray \
    --MAP GRID PEN SECONDARY=thinnest, dimgray \
    -BWSne+gmintcream -W0.1 -Sc0.05c \
    -Gred modelAT.txt -i0,2 -Y5.0c -O -K >> $ps
```
```
echo "@~e@~(t) = y(t) - m@-5@-(t) (plot of the residuals)" | gmt pstext -R -J \
    -F+f12p+cBL -Dj0.1i -Gcornsilk -O -K >> $ps
```
```
# Step-8. Plot graph
```
```
gmt psxy -R-200/200/-10000/1000 -JX15c/4c envA2.txt \
    -Bpxag100f10+1"Distance from trench (km)" \
    -Bsxg50 -Bpya2000gf+1"Depth (m)" -Bsyg2000 \
    --FONT_annot_PRIMARY=8p, Palatino-Roman, dimgray \
```
67 --FONTLABEL=8p,Palatino-Roman,dimgray \
68 --MAP GRID PEN PRIMARY=thinnest,dimgray \
69 --MAP GRID PEN SECONDARY=thinnest,dimgray \
70 -BWSne+t"Graph of the modelled trend curves of the Aleutian Trench geomorphology (north)" \
71 -Glightgray -W0.2p -Y5.0c -O -K >> $ps
72 gmt psxy -R -J -W0.2p -Ey+p0.2p stackA2.txt -O -K >> $ps
73 gmt psxy -R -J -W1.0p,red stackA2.txt \
74 -O -K >> $ps
75
76 # Step-9. Add test annotations
77 echo "160 -4000 Aleutian Islands" | gmt pstext -R -J -Gwhite -F+jTC+f9p -O -K >> $ps
78 echo "-50 -300 Mean stacked profile with error bars" | gmt pstext -R -J -Gwhite -F+jTC+f10p,red -O -K >> $ps
79 echo "0 -9000 Aleutian Trench" | gmt pstext -R -J -Gwhite -F+jTC+f9p -O -K >> $ps
80 echo "-150 -8000 Pacific Plate" | gmt pstext -R -J -Gwhite -F+jTC+f9p -O -K >> $ps
81 # Step-10. Add subtitle
82 gmt pstext -R0/10/0/15 -JX15c/4c -X0.0c -Y0.5c -N -O -K \
83 -F+f10p,Palatino-Roman,black+jLB >> $ps << EOF
84 0.0 15.0 Fitted regression models y=f(x)+e, by weighted least squares (WLS), polynomial and Fourier
85 EOF
86
87 # Step-11. Add GMT logo
88 gmt logo -Dx6.2/-21.0+o0.25c/-1.3c+w2c -O >> $ps
89 # Step-12. Convert to image file using GhostScript (portrait orientation, 720 dpi)
90 gmt psconvert ATtrends.ps -A0.2c -E720 -Tj -P -Z
91 # Step-13. Clean up
92 rm -f modelAT.txt

codes/GMT-11.sh
A.4.12 GMT script for 2D bar histogram and rose diagram (here: MAT)

1 #!/bin/bash
2 # Purpose: Plot two histograms of the cross-section profiles (Middle America Trench)
3 # GMT modules: gmtset, psrose, pshistogram, pslegend, logo, psconvert
4 # Step-1. GMT set up
5 gmt set MAP TITLE OFFSET 0.5c \
6 MAP ANNOT OFFSET 0.2c \
7 MAP TICK PEN PRIMARY thinner, dimgray \
8 MAP GRID PEN thinnest, dimgray \
9 FONT TITLE 10p, Palatino-Roman, black \
10 FONT ANNOT PRIMARY 9p, Palatino-Roman, dimgray \
11 FONT LABEL 8p, Palatino-Roman, dimgray \
12 # Step-2. Generate a file
13 ps=Hist MAT.ps
14 # Step-3. Plot rose diagram
15 gmt psrose tableMAT.txt -i1,4 -R0/1/0/360 \
16 -A7r -S1.0 in \
17 -Glightsteelblue1 -Bx0.2g0.2 \
18 -By30g30+1"Bathymetric data distribution by cross-section profiles" \
19 -B+t"Rose diagram on the cross-section profiles"+gghostwhite \
20 -M0.5c+e+gred2+nlc \
21 -W0.1p, red -Cm \
22 -UBL/-15p/-65p -Vv -K > $ps
23 # Step-4. Plot histogram
24 gmt pshistogram tableMAT.txt -i4 -R-6500/2000/0/27 -JX4.8i/2.4i -X3.6i \
25 -Bpxg1000a1000f100+1"Bathymetry (m)" \
26 -Bpyg5a5f2.5+1"Frequency distribution"+u" %" -Bsyg2.5 \
27 -BWSne+t"Guatemala Trench: Histograms of the depths values on the cross-section profiles"+gghostwhite -
Gpowderblue \
28 -D+f6p, Times-Roman -L0.1p, dimgray -Z1 -W250 -N0+pred -N1+pblue -N2+pgreen \
29 -O -K >> $ps
30 # Step-5. Add legend
31 gmt pslegend -R -J -Dx1.0/-2.6+w5.0c+o-1.0/0.5c \
32 -F+pthick+ithinner+gwhite \
33 --FONT ANNOT PRIMARY=8p -O -K << EOF >> $ps
34 S 0.3c v 0.5c red 0.01c 0.6c Mean and standard deviation
35 S 0.3c v 0.5c green 0.01c 0.6c LMS mode and scale
36 S 0.3c v 0.5c blue 0.01c 0.6c Median and L1 scale
37 EOF
38 # Step-6. Add GMT logo
39 gmt logo -Dx6.0/0.0+o-0.5c/-2.5c+w2c -O >> $ps
40 # Step-7. Convert to image file using GhostScript (portrait orientation, 720 dpi)
41 gmt psconvert Hist MAT.ps -A0.2c -E720 -P -Tj -Z

codes/GMT-12.sh
A.4.13 GMT script for 3D bar histogram plot (here: KKT)

1 #!/bin/bash
2 # Purpose: 3D bar histogram plot (here: Kuril-Kamchatka Trench)
3 # GMT modules: gmtset, grd2xyz, gmtinfo, pstext, psxyz, logo, psconvert
4 # Unix progs: echo
5 # Step-1. GMT set up
6 gmt set FORMAT_GEO_MAP=ddd \
7 MAP TITLE_OFFSET 0.8c \
8 MAP ANNOT_OFFSET 0.2c \
9 MAP LABEL_OFFSET 0.3c \
10 MAP TICK_PEN_PRIMARY thinner, dimgray \
11 MAP GRID_PEN thinnest, dimgray \
12 FONT TITLE 12p, Palatino-Roman, black \
13 FONT ANNOT_PRIMARY 10p, Palatino-Roman, black \
14 FONT LABEL 10p, Palatino-Roman, black \
15 # Step-2. Generate a file
16 ps=Hist3DKKT.ps
17 # Step-3. Convert grid file to data table
18 gmt grd2xyz kkt_bathy.nc > kkt_bathy.xyz
19 # Step-4. Check up depth/heights range
20 gmt info kkt_bathy.xyz
21 #kkt_bathy.xyz: N = 87001 <140/170> <40/60> <-9317/3319>
22 # Step-5. Plot 3D histogram from the data table
23 gmt psxyz kkt_bathy.xyz -Bpxa4 -Bpya2 -Bsxg2a2 -Bsygla1 -Bz2000+1"Bathymetry and topography (m)" \
24 -BWSneZ+b+t"3D-histograms of the depth values: Kuril-Kamchatka Trench" \
25 -R144/162/40/50/-7600/2000 -JM10c -JZ7c \
26 -p215/30 -So0.083ub-6000 -P \
27 -Wthinnest -Glavenderblush -UBL/-15p/-35p -K > $ps
28 # Step-6. Add subtitle
29 gmt pstext -R0/10/0/10 -JX10/10 \
30 -F+f10p, Palatino-Roman, black+jLB -N -O -K >> $ps << EOF
31 0.5 12.5 View azimuth from the southwest (215\232) at 30\232 elevation
32 EOF
33 #
34 gmt psbasemap -R -J \
35 --FONT=8p, Palatino-Roman, dimgray \
36 --MAP TITLE_OFFSET=0.3c \
37 -Td141/41+w0.3i+1+o0.4c \
38 -O -K >> $ps
39 echo '6.0 0.0 Input data: ETOPO5 grid converted to XYZ ASCII' | gmt pstext \
40 -R0/10/0/10 -JX10/10 -Y=0.5c \
41 -F+jLB+a19 -N -O -K >> $ps
42 # Step-7. Add GMT logo
43 gmt logo -Dx6.0/0.0+o-0.5c/-1.5c+w2c -O >> $ps
44 # Step-8. Convert to image file using GhostScript (portrait orientation, 720 dpi)
45 gmt psconvert Hist3DKKT.ps -A0.5c -E720 -Tj -P -Z
46 # Quick variant:
47 # gmt grd2xyz kkt_bathy.nc | gmt psxyz -B1 -Bz1000+1"Topography (m)" -BWSneZ+b+tETOP05 \
48 # -R140/170/40/60/-9400/3400 -JM5i -JZ6i -p200/30 -So0.0833333ub-5000 -P \
49 # -Wthinnest -Glightgreen -K > $ps

codes/GMT-13.sh
# A.5 Python language scripts

## A.5.1 Python code for statistical data analysis by violin plots

```python
#!/usr/bin/env python
# coding: utf-8
import os
import pandas as pd
import matplotlib.pylab as pylab
from matplotlib import plot
import seaborn as sb

sb.set_style('darkgrid')
sb.set_context('paper')

params = {'font.family': 'Palatino',
           'axes labelsize': 8,
           'lines linewidth': .2,
           'xtick major size': 4,
           'xtick labelsize': 8,
           'figure titlesize': 8,
           'figure dpi': 300,
        }

pylab .rcParams.update (params)

# loading data
os .chdir('/Users/pauline/Documents/Python')
dfM = pd.read_csv("Tab-Bathy.csv")
dfM .head(5)

# plotting
g = sb .catplot(data=dfM, kind="violin", scale='count', palette="Paired",
               orient="v", margin titles = True)
g .fig .set size inches (10, 5)

plt .xticks (rotation=45)
plt .title('Violin plots for the Mariana Trench bathymetry')
plt .subplotsAdjust(bottom=0.15,top=0.85)

# visualizing
plt .tight_layout()

plot .savefig('plot_Viol.png')

plot.show()
```

codes/Python-01.py

## A.5.2 Python code for clustermap: bathymetric data distribution by profiles

```python
#!/usr/bin/env python
# coding: utf-8
import os
import numpy as np
import pandas as pd
from matplotlib import plot
import seaborn as sb

sb.set (style='white')
sb.set (color codes = True)
sb.set_context('paper')

os .chdir('/Users/pauline/Documents/Python')
df = pd.read_csv("Tab-Bathy.csv")

define variables and plotting
```
```python
g = sb.clustermap(df, cmap="mako", robust=True)
rotation = 45

for i, ax in enumerate(g fig. axes):  ## getting all axes of the fig object
    ax. set_xticklabels(ax. get_xticklabels(),
                       rotation = rotation
                       )

g. fig. subtitle('Mariana Trench: Clustermap of the bathymetric observations. \nDataset: 25 cross-section profiles, 518 observations in each. \nMethod: ignored outliers in colormap limits')
plt. subplots Adjust(bottom=0.20, top=0.90, right=0.90, left=0.10)

# printing and saving

plot. savefig('plot_Clust3.png', dpi=300)

plot. show()
```

codes/Python-02.py

A.5.3 Python code for histograms: distribution of the observation samples

```python
#!/usr/bin/env python
# coding: utf-8
import os
import pandas as pd
from matplotlib import pyplot as plt
import matplotlib. artist as martist
from matplotlib. offsetbox import AnchoredText
import seaborn as sb

sb. set. style("whitegrid")
sb. set. context("paper")
sb. set. color. codes()

os. chdir('/Users/pauline/Documents/Python')
dfM = pd. read. csv("Tab-Morph.csv")

fig = plt. figure(figsize=(10.0, 6.0), dpi=300)
fig. subtitle('Histogram plot of the observation sample distribution',
             fontsize=10, fontweight='bold', x=0.5, y=0.99
             )

def add_at(ax, t, loc=2):
    fp = dict(size=11)
    _at = AnchoredText(t, loc=loc, prop=fp)
    ax. add. artist(_at)
    return _at

# subplot 1
ax = fig. add. subplot(221)
sb. distplot(dfM['plate_maria'], kde=True, rug=True, hist=True,
             norm. hist=True, color="xkcd:periwinkle blue",
             axlabel='Mariana Plate observations',
             label='Mariana Plate', vertical=False
             )
add_at(ax, "A")

# subplot 2
ax = fig. add. subplot(222)
sb. distplot(dfM['plate_pacif'], kde=True, rug=True, hist=True,
             norm. hist=True, color="xkcd:aqua",
             axlabel='Pacific Plate observations',
             label='Pacific Plate', vertical=False
             )
add_at(ax, "B")

# subplot 3
ax = fig. add. subplot(223)
```
```python
48 sb.distplot(dfM['plate_carol'], kde=True, rug=True, hist=True,
49             norm_histogram=True, color="xkcd:pale violet",
50             axlabel='Caroline Plate observations',
51             label='Caroline Plate', vertical=False)
52
53 add_at(ax, "C")
54
55 # subplot 4
56 ax = fig.add_subplot(224)
57 sb.distplot(dfM['plate_phill'], kde=True, rug=True, hist=True,
58             norm_histogram=True, color="xkcd:rose pink",
59             axlabel='Philippine Plate observations',
60             label='Philippine Plate', vertical=False)
61
62 add_at(ax, "D")
63
64 # visualize
65 plt.tight_layout()
66
67 plt.subplots Adjust (top=0.92, bottom=0.08,
68                     left=0.10, right=0.95,
69                     hspace=0.25, wspace=0.35)
70 fig savefig('plot_Hist.png', dpi=300)
71 plt.show()
```

codes/Python-03.py

A.5.4 Letter-value plots for the Mariana Trench bathymetry

```python
1 #!/usr/bin/env python
2 # coding: utf-8
3 import os
4 import pandas as pd
5 import seaborn as sb
6 from matplotlib import pyplot as plt
7
8 sb.set('darkgrid')
9 sb.set_context("paper")
10
11 os chdir('/Users/pauline/Documents/Python')
12 dfM = pd.read_csv("Tab-Bathy.csv")
13 dfM .head(5)
14
15 # plotting
16 sb .catplot(data=dfM, kind="boxen", palette='Paired',
17             orient="v", legend=True, legend_out=True, margin titles=True)
18
19 plt .xticks(orientation=45)
20 plt .title('Letter-value plots for the Mariana Trench bathymetry',
21           font size=12, font family='serif')
22
23
24 # visualization and printing
25 plt .tight_layout()
26 plt .savefig('plot_Letter-value.png', dpi=300)
27 plt .subplots Adjust (bottom=0.15, top=0.85)
28 plt .show()
```

codes/Python-04.py
```python
67 plt.legend(bbox_to anchor=(1.01, 0.01, 0.15, 0.99),
68            ncol=1, mode="expand")
69
70 plt.tight_layout()
71 plt.xticks(np.arange(2), ('Philippine Plate', 'Sunda Plate'))
72 add_at(ax, "B")
73
74 # visualization
75 plt.tight_layout()
76 plt.subplots Adjust (top=0.85, bottom=0.15,
77                    left=0.10, right=0.90,
78                    hspace=0.25, wspace=0.35)
79
80 fig savefig('plot Strips Phil.png', dpi=300)
81 plt.show()
```

codes/Python-05.py

A.5.6 Python code for the correlogram matrices by Seaborn library

```python
#!/usr/bin/env python
# coding: utf-8
import os
import numpy as np
import pandas as pd
import matplotlib.pylab as pylab
from matplotlib import pyplot as plt
import seaborn as sb
os chdir('/Users/pauline/Documents/Python')
sb.set (style='white')
sb.set_context('paper')
params = {'figure.fид size': (10, 10),
          'legend.fид size': 14,
          'font. family': 'Times'
        }
pylab .rcParams.update (params)
df = pd.read_csv("Tab-Morph.csv")
corr = df .corr (method='kendall')
cmap = "RdBu"
# plotting heatmap
f, ax = plt .subplots()
sb. heatmap (corr, cmap =cmap, center=0,
            vmin=-1.1, vmax=1.1,
            annot = True, annot_kws={"size":8},
            square = True, linewidths=.05, linecolor='grey',
            cbar = True, mask = False, cbar_kws={"shrink": .5},
        )
plt .title('Mariana Trench: Kendall correlation for the environmental factors',
           fontsize=13, fontfamily='serif')
plt .subplots Adjust (bottom=0.15, top=0.85, right=0.90, left=0.10)
plt .xticks (rotation=30)
plt .yticks()
# visualizing and saving figure
plt .tight_layout()
```

codes/Python-06.py
A.5.7 Python code for the regression analysis

1
#!/usr/bin/env python
2
# coding: utf-8
3
import os
4
import numpy as np
5
import pandas as pd
6
import matplotlib.pyplot as plt
7
import seaborn as sb
8
9
sb.set_style('darkgrid')
10
sb.set_context("paper")
11
sb.set(font_scale = 3)
12
13
osudu = oschdir('/Users/pauline/Documents/Python')
14
dfM = pd.read_csv("Tab-Bathy.csv")
15
16
# defining loop sequence
17 profiles_nrs = list(map(lambda x: x, range(25)))
18
19 profiles_list = []
20
21
22 for i in profiles_nrs:
23     profiles_list.append('profile{}'.format(i + 1))
24
25
26
27
28
# plotting
29 g = sblmplot(data=df, x="observ", y="Depths",
30               col="Profiles", hue="Profiles", colWrap=5,
31               fit_reg=True, truncate=True,
32               x_jitter=True, y_jitter=True,
33               scatter=True, markers='.', order=2, height=6
34             )
35
g.set_axis labels("Observation points", "Depths, m").figsubplots Adjust(wspace=.04)
36
37
# visualizing and saving picture
38 plt.tight_layout()
39
40
41
42
43
44

# savefig('plot_FacetGrid.png', dpi=300)

# show()

codes/Python-07.py

A.5.8 Python code for Letter-value plots for the Mariana Trench bathymetry

1
#!/usr/bin/env python
2
# coding: utf-8
3
import os
4
import pandas as pd
5
import seaborn as sb
6
from matplotlib import plot
7
8
sb.set_style('darkgrid')
9
sb.set_context("paper")
10
11
oschdir('/Users/pauline/Documents/Python')
12
dfM = pd.read_csv("Tab-Bathy.csv")
13
dfM. head(5)
14
15
# plotting
```python
16 sb.catplot(data=dfM, kind="boxen", palette='Paired',
17            orient="v", legend=True, legend_out=True, margin Titles=True
18 )
19 plt.xticks(rotation=45)
20 plt.title('Letter-value plots for the Mariana Trench bathymetry',
21          fontsize=12, fontfamily='serif'
22 )
23
24 # visualization and printing
25 plt.tight_layout()
26 plt.savefig('plot_Letter-value.png', dpi=300)
27 plt.subplots Adjust (bottom=0.15, top=0.85)
28 plt.show()
```

codes/Python-04.py

A.5.9 Python code for joint Hexagonal and KDE plots

```python
#!/usr/bin/env python
# coding: utf-8
import os
import pandas as pd
from matplotlib import plot
import seaborn as sb

sb.set('white')
sb.set_context('paper')
sb.set_color_codes()
os chdir('/Users/pauline/Documents/Python')

# defining a loop
profiles_nrs = list(map(lambda x: x, range(25)))
profiles_list = []

for i in profiles_nrs:
    profiles_list.append('profile'.format(i + 1))

# generating data frame
dfB = pd.read_csv("Tab-Bathy.csv")
df = dfB.melt(id_vars=['observ'],
             value_vars=profiles_list,
             var_name='Profiles', value_name='Depths'
)

# plotting
sb.jointplot(x='observ', y='Depths', data=df,
             kind='kde', dropna=True, color="m"
)

sb.jointplot(x="observ", y="Depths", data=df,
             kind="hex", dropna=True
)

plt.subplots Adjust (bottom=0.15, top=0.85, right=0.90, left=0.10)

# visualizing
plt.tight_layout()
plot.savefig('plot_Hexbin.png', dpi=300)
plot.show()
```

codes/Python-09.py

A.5.10 Python code for the correlogram plot (here: Pearson's method)

```python
#!/usr/bin/env python
# coding: utf-8
import os
import numpy as np
```
```python
import pandas as pd
from matplotlib import plotly as plt
import seaborn as sb

os chdir('/Users/pauline/Documents/Python')
sb.set (style='white')
sb.set_context('paper')
df = pd.read_csv("Tab-Morph.csv")

# computing correlation matrix
corr = df.corr (method='pearson')

# generating colormap
pal = sb.color palette("tab20c")
cmap = pal

# plotting heatmap
f, ax = plt.subplots (figsize=(11, 9))
sb. heatmap (corr, cmap=cmap, vmax=0.3, center=0, annot = True,
             annot_kws={"size":8}, square = True, linewidths=.05, linecolor='grey',
             cbar = True, mask = False, cbar_kws={"shrink": .5})

plt. title('Mariana Trench: Pearson correlation for the environmental factors',
           fontsize=13, fontfamily='serif')

plt. subplots Adjust (bottom=0.20, top=0.90, right=0.90, left=0.10)

plot. xticks (rotation=30, size=9)
plot. yticks (rotation=0, size=9)

# visualizing and saving
plot. tight layout()
plot. savefig('plot_CorrP.png', dpi=300)
plot. show()
```

codes/Python-10.py

A.5.11 Python code for a box-and-whisker plot for the Mariana Trench bathymetry

```python
#!/usr/bin/env python
# coding: utf-8
import os
import pandas as pd
import seaborn as sb
from matplotlib import plotly as plt

sb.set_style('whitegrid')
sb.set_context('paper')

os chdir('/Users/pauline/Documents/Python')
dfB = pd.read_csv("Tab-Bathy.csv")

# define variables and plotting
sb.boxplot (data=dfB, orient="v", palette='coolwarm', saturation=1,
           width=0.8, dodge = True, fliersize=5, linewidth=0.2,
           whis=5, notch = True, ax = None)

sb.despine (offset=10, trim = True) # offset the spines away from the sample data

plot. xticks (rotation=45)
plot. yticks (rotation=45)

plot. title('Box-and-whisker plot for the Mariana Trench bathymetry',
           fontsize=12, fontfamily='sans-serif')

# printing and saving
plot. tight layout()
plot. savefig('plot Boorp.png', dpi=300)
plot. show()
```
```python
61 plt.setp(markerline, alpha=0.7)
62 plt.xticks(x, ordered DF['group'])
63 plt.xlabel('Cross-section profiles')
64 plt.ylabel('tg$^\circ\text{circ}$ (A/H)')
65 add_at(ax2, "B")
66
67 # visualizing
68 plt.tight_layout()
69 plt.subplots Adjust (top=0.85, bottom=0.15,
70                     left=0.20, right=0.95,
71                     hspace=0.25, wspace=2.8
72 )
73 plt savefig('plot_Stems.png')
74 plt.show()
```

codes/Python-12.py

A.5.13 Python code for plotting dendrograms

```python
#!/usr/bin/env python
# coding: utf-8
import os
import numpy as np
import pandas as pd
from matplotlib import plot as plt
from scapy.cluster import hierarchy
from scapy.cluster.hierarchy import dendrogram, linkage

os chdir('/Users/pauline/Documents/Python')
df = pd.read_csv("Tab-Morph.csv")
df = df.set_index('profile')
del df.index.name

# calculate distance between each sample
Z = hierarchy.linkage(df, 'average')

# plotting
dendrogram(Z, labels=df.index, leaf_rotate=0, orientation="left",
            distance_sort='ascending')

plot. title('Hierarchical cluster dendrogram for the geomorphic similarity \nof the 25bathymetric profiles,
            Mariana Trench',
           fontsize=10, fontfamily='sans-serif')

# visualizing and saving
plot. tight_layout()
plot. savefig('plot_Dendro.png', dpi=300)
plot. show()
```

codes/Python-13.py

A.5.14 Python code for 3D scatter plots: correlation of the factors (sediment thickness, slope steepness, bathymetry)

```python
#!/usr/bin/env python
# coding: utf-8
import numpy as np
import pandas as pd
import matplotlib.cm as cmx
import matplotlib.pylab as pylab
import matplotlib.pylab as plt
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.artist as martist
from matplotlib.offsetbox import AnchoredText
```
```python
from matplotlib colours import ListedColormap

df = pd.read_csv("Tab-Morph.csv")

params = {'figure.figsize': (10, 8),
           'figure.dpi': 300,
           'figure titlesize': 14,
           'font family': 'Palatino',
           'axes labelsize': 8,
           'axes titlesize': 12,
           'axes titlepad': 1,
           'axes labelpad': .5,
        }

pylab.rcParams.update(params)

def add_at(ax, t, loc=2):
    fp = dict(size=11)
    _at = AnchoredText(t, loc=loc, prop=fp)
    ax.addArtist(_at)
    return _at

fig = plt.figure()
fig.suptitle('3D correlation scatter plot, factors: \n sediment thickness, slope steepness, bathymetry (
    observation samples)',
              x=0.5, y=0.97)

# subplot 1
ax = fig.add_subplot(221, projection='3d')
ax.scatter(df.plate_pacif, df.sedim_thick, df.slope_angle,
           c='ee827c', edgecolors='grey', s=130, alpha=.9)
ax.set_xlabel('Pacific Plate')
ax.set_ylabel('sediment thickness')
ax.set_zlabel('slope angle')
ax.view_init(30, 185)
plt.title('Pacific Plate')
add_at(ax, "A")

# subplot 2
ax = fig.add_subplot(222, projection='3d')
ax.scatter(df.plate_phill, df.sedim_thick, df.slope_angle,
           c='f8b500', edgecolors='grey', s=130, alpha=.6)
ax.set_xlabel('Philippine Plate')
ax.set_ylabel('sediment thickness')
ax.set_zlabel('slope angle')
ax.view_init(30, 185)
plt.title('Philippine Plate')
add_at(ax, "B")

# subplot 3
ax = fig.add_subplot(223, projection='3d')
ax.scatter(df.plate_carol, df.sedim_thick, df.slope_angle,
           c='aacf53', edgecolors='grey', s=130, alpha=.8)
ax.set_xlabel('Caroline Plate')
ax.set_ylabel('sediment thickness')
ax.set_zlabel('slope angle')
ax.view_init(30, 185)
plt.title('Caroline Plate')
add_at(ax, "C")

# subplot 4
ax = fig.add_subplot(224, projection='3d')
ax.scatter(df.plate_maria, df.sedim_thick, df.slope_angle,
           c='0095d9', edgecolors='grey', s=130, alpha=.7)
ax.set_xlabel('Mariana Plate')
ax.set_ylabel('sediment thickness')
ax.set_zlabel('slope angle')
ax.view_init(30, 185)
plt.title('Mariana Plate')
add_at(ax, "D")
```
```python
79
80 plt.tight_layout()
81
82
83
84
85
```

codes/Python-14.py

A.5.15 Python code for ANOVA

```python
1 #!/usr/bin/env python
2 # coding: utf-8
3 from __future__ import print_function
4 import os
5 import numpy as np
6 import pandas as pd
7 import matplotlib.pyplot as plt
8 import statsmodels.api as sm
9 from statsmodels.compat import urlopen
10 from statsmodels.formula.api import ols
11 from statsmodels.stats.anova import anova_lmsd
12 from statsmodels.graphicsapi import interaction plot, abline plot
13 pd.set_option("display.width", 100)
14
15 os.chdir('/Users/pauline/Documents/Python')
16
17 df = pd.read_csv("Tab-Morph.csv")
18
19 E = df.sedim_thick
20 M = df.plate_pacif
21 X = df.igneous_volc
22 S = df.slope_angle
23
24 cw_lmsd = ols('M ~ S + C(E)', data=df).fit() #Specify C for Categorical
25 print(cw_lmsd)
26
27 print(cw_lmsdirec)
28
29 cw_lmsd = ols('M ~ E + C(X)', data=df).fit() #Specify C for Categorical
30 print(cw_lmsd)
31 print(cw_lmsdirec)
```

codes/Python-15.py

A.5.16 Python code for KDE, example for the subplot (F)

```python
1 #!/usr/bin/env python
2 # coding: utf-8
3 import os
4 import pandas as pd
5 import matplotlib.pyplot as plt
6 from matplotlib import pyplot as plt
7 import matplotlib. artist as martist
8 from matplotlib. offsetbox import AnchoredText
9 import seaborn as sns
10
11 os. chdir('/Users/pauline/Documents/Python')
12 df = pd. read_csv("Tab-Bathy.csv")
13 dfM = pd. read_csv("Tab-Morph.csv")
14 sns. set_style('darkgrid')
15 sns. set_context('paper')
16
```
```python
17 params = {'figure.figsize': (10, 6),
18           'figure.dpi': 300,
19           'figure titlesize': 14,
20           'font family': 'Palatino',
21           'axes labelsize': 10,
22           'legend fontsize': 8,
23           'legend loc': 'best',
24           'xtick labelsize': 8,
25           'ytick labelsize': 8,
26           'axes labelpad': 2,
27       }
28 pylab .rcParams.update (params)
29
30 fig = plt .figure (figsize=(10.0, 6.0), dpi=300)
31 fig .suptitle ('Kernel Density Estimation: probability of the depth ranges, Mariana Trench',
32             x=0.5, y=0.97)
33
34 def add_at (ax, t, loc=1):
35     fp = dict (size=11)
36     _at = AnchoredText (t, loc=loc, prop=fp)
37     ax .addArtist (_at)
38
39
40 # subplot 1
41 ax = fig .add_subplot (231)
42 ax = sns .kdeplot (df ['profile1'], shade = True, color ="r")
43 ax = sns .kdeplot (df ['profile2'], shade = True, color ="#ffd900")
44 ax = sns .kdeplot (df ['profile3'], shade = True, color ="b")
45 ax = sns .kdeplot (df ['profile4'], shade = True, color ="#e95295")
46 ax = sns .kdeplot (df ['profile5'], shade = True, color ="#00a3af")
47 ax .set (xlabel='Depths', m', ylabel='KDE')
48 ax .set title ("profiles 1-5", fontsize=9, fontfamily='serif')
49 add_at (ax, "A", loc=2)
50
51 # subplot 2
52 ax = fig .add_subplot (232)
53 ax = sns .kdeplot (df ['profile6'], shade = True, color ="r")
54 ax = sns .kdeplot (df ['profile7'], shade = True, color ="#ffd900")
55 ax = sns .kdeplot (df ['profile8'], shade = True, color ="b")
56 ax = sns .kdeplot (df ['profile9'], shade = True, color ="#e95295")
57 ax = sns .kdeplot (df ['profile10'], shade = True, color ="#00a3af")
58 ax .set (xlabel='Depths', m', ylabel='KDE')
59 plt .title ("profiles 6-10", fontsize=9, fontfamily='serif')
60 add_at (ax, "B", loc=2)
61
62 # subplot 3
63 ax = fig .add_subplot (233)
64 ax = sns .kdeplot (df ['profile11'], shade = True, color ="r")
65 ax = sns .kdeplot (df ['profile12'], shade = True, color ="#ffd900")
66 ax = sns .kdeplot (df ['profile13'], shade = True, color ="b")
67 ax = sns .kdeplot (df ['profile14'], shade = True, color ="#e95295")
68 ax = sns .kdeplot (df ['profile15'], shade = True, color ="#00a3af")
69 ax .set (xlabel='Depths', m', ylabel='KDE')
70 plt .title ("profiles 11-15", fontsize=9, fontfamily='serif')
71 add_at (ax, "C")
72
73 # subplot 4
74 ax = fig .add_subplot (234)
75 ax = sns .kdeplot (df ['profile16'], shade = True, color ="r")
76 ax = sns .kdeplot (df ['profile17'], shade = True, color ="#ffd900")
77 ax = sns .kdeplot (df ['profile18'], shade = True, color ="b")
78 ax = sns .kdeplot (df ['profile19'], shade = True, color ="#c3d825")
79 ax = sns .kdeplot (df ['profile20'], shade = True, color ="#00a3af")
80 ax .set (xlabel='Depths', m', ylabel='KDE')
81 plt .title ("profiles 16-20", fontsize=9, fontfamily='serif')
82 add_at (ax, "D")
83
84 # subplot 5
85 ax = fig .add_subplot (235)
```
```python
86 ax = sns.kdeplot(df['profile21'], shade=True, color="r")
87 ax = sns.kdeplot(df['profile22'], shade=True, color="#ffd900")
88 ax = sns.kdeplot(df['profile23'], shade=True, color="b")
89 ax = sns.kdeplot(df['profile24'], shade=True, color="#c3d825")
90 ax = sns.kdeplot(df['profile25'], shade=True, color="#00a3af")
91 ax.set(xlabel='Depths', m', ylabel='KDE')
92 plt.title("profiles 21-25")
93 add_at(ax, "E")
94
95 # subplot 6
96 ax = fig.add_subplot(236)
97 ax = sns.kdeplot(dfM['Min'], shade=True, color="r")
98 ax = sns.kdeplot(dfM['Mean'], shade=True, color="#ffd900")
99 ax = sns.kdeplot(dfM['Max'], shade=True, color="b")
100 ax = sns.kdeplot(dfM['1stQ'], shade=True, color="#65318e")
101 ax = sns.kdeplot(dfM['3rdQ'], shade=True, color="#00a3af")
102 ax.set(xlabel='Depths', m', ylabel='KDE')
103 plt.title("bathymetric depth ranges, profiles 1-25")
104 add_at(ax, "F")
105
106 # visualizing and saving
107 plt.tight_layout()
108 plt.subplots Adjust (top=0.90, bottom=0.08,
109                 left=0.10, right=0.95,
110                 hspace=0.3, wspace=0.3
111 )
112 plt.savefig('plot_KDE.png', dpi=300)
113 plt.show()
```

codes/Python-16.py

A.5.17 Python code for stacked area charts on the bathymetry

```python
1 #!/usr/bin/env python
2 # coding: utf-8
3 import pandas as pd
4 import numpy as np
5 import seaborn as sns
6 import matplotlib as mpl
7 import matplotlib.pyplot as plt
8 import matplotlib.ticker as ticker
9 import os
10
11 sns.set_style('white')
12 sns.set_context('paper')
13
14 # data frame
15 os.chdir('/Users/pauline/Documents/Python')
16 df = pd.read_csv("Tab-Morph.csv")
17 df = pd.DataFrame(data=df, columns=['Min', '1stQ', 'Median', 'Mean', '1stQ', 'Max'])
18
19 # plotting
20 fig = plt.figure(figsize=(8, 6))
21 ax = df.plot.area(stacked=False, alpha=0.8, colormap='PuBu_r')
22 plt.legend(bbox_to塞chor=(1.05, 1), loc=2, borderaxespad=0.)
23 plt.title('Stacked area chart for the Mariana Trench bathymetry: \ndepths by 25 cross-section profiles',
24          fontsize=12, fontfamily='serif')
25 ax.set_xlabel('Bathymetric profiles')
26 ax.set_ylabel('Depths, m')
27 plt.xticks(np.arange(1, 26, step=1), rotation=30)
28
29 # visualizing and saving
30 plt.tight_layout()
31 plt.savefig('plot_StackAreaB.png', dpi=300)
32 plt.show()
```

codes/Python-17.py
A.5.18 Python code for the facetted plot of the radar charts

```python
#!/usr/bin/env python
# coding: utf-8
import os
import numpy as np
import pandas as pd
import matplotlib.pylab as pylab
import matplotlib.pyplot as plt
import matplotlib.artist as martist
from matplotlib.offsetbox import AnchoredText
from math import pi
import seaborn as sns

osudu = os.path

df = pd.read_csv("Tab-Morph.csv")

params = {'figure.figsize': (10, 5),
           'figure.dpi': 300,
           'figure titlesize': 14,
           'font.family': 'Palatino',
           'axes.grid': True,
           'axes labelsize': 8,
           'polaraxes.grid': True,
        }

pylab.rcParams.update(params)

def add_at(ax, t, loc=2):
    fp = dict(size=11)
    _at = AnchoredText(t, loc=loc, prop=fp)
    ax.addArtist(_at)
    return _at

# show 6 different variables on our radar chart, so take them out and set as a np.array.
labels = np.array(['Median', 'Max', '1stQ', '3rdQ', 'Min', 'Mean'])
stats1 = df.loc[1, labels].values
stats2 = df.loc[5, labels].values
stats3 = df.loc[12, labels].values
stats4 = df.loc[15, labels].values
stats5 = df.loc[18, labels].values
stats6 = df.loc[23, labels].values

# close the plot
angles = np.linspace(0, 2* np.pi, len labels, endpoint=False)
angles = np.concatenate((angles, [angles[0]]))
stats1 = np.concatenate((stats1, [stats1[0]]))
stats2 = np.concatenate((stats2, [stats2[0]]))
stats3 = np.concatenate((stats3, [stats3[0]]))
stats4 = np.concatenate((stats4, [stats4[0]]))
stats5 = np.concatenate((stats5, [stats5[0]]))
stats6 = np.concatenate((stats6, [stats6[0]]))

fig = plt.figure()
fig.suptitle('Radar chart for the bathymetry of the Mariana Trench',
             x=0.5, y=0.99)

# subplot 1
ax = fig.add_subplot(231, polar=True)
ax. plot(angles, stats1, 'o-', linewidth=2)
ax. fill(angles, stats1, c='g', alpha=0.2)
ax. set_thetagrids(angles * 180/np.pi, labels)

plt. title('profile (nr.1)')
ax. annotate('A', xy=(1.02, .90), xy coordinates="axes fraction")
ax. add_at(ax, "A")

# subplot 2
ax = fig. add_subplot(232, polar=True)
ax. plot(angles, stats2, 'o-', linewidth=2)
```
```python
67 ax.fill(angles, stats2, c='a0d8ef', alpha=0.4)
68 ax.set_thetagrids(angles * 180/np.pi, labels)
69 plt.title('profile (nr.5)')
70 add_at(ax, "B")
71
72 # subplot 3
73 ax = fig.add_subplot(233, polar=True)
74 ax.plot(angles, stats3, 'o-', linewidth=2)
75 ax.fill(angles, stats3, c='ee827c', alpha=0.4)
76 ax.set_thetagrids(angles * 180/np.pi, labels)
77 plt.title('profile (nr.12)')
78 add_at(ax, "C")
79
80 # subplot 4
81 ax = fig.add_subplot(234, polar=True)
82 ax.plot(angles, stats4, 'o-', linewidth=2)
83 ax.fill(angles, stats4, c='plum', alpha=0.4)
84 ax.set_thetagrids(angles * 180/np.pi, labels)
85 plt.title('profile (nr.15)')
86 add_at(ax, "D")
87
88 # subplot 5
89 ax = fig.add_subplot(235, polar=True)
90 ax.plot(angles, stats5, 'o-', linewidth=2)
91 ax.fill(angles, stats5, c='ffd900', alpha=0.2)
92 ax.set_thetagrids(angles * 180/np.pi, labels)
93 plt.title('profile (nr.19)')
94 add_at(ax, "E")
95
96 # subplot 6
97 ax = fig.add_subplot(236, polar=True)
98 ax.plot(angles, stats6, 'o-', linewidth=2)
99 ax.fill(angles, stats6, c='c3d825', alpha=0.4)
100 ax.set_thetagrids(angles * 180/np.pi, labels)
101 plt.title('profile 24')
102 add_at(ax, "F")
103
104 plt.tight_layout()
105
106
107
108
109
110

fig.savefig('plot_RadarChart.png', dpi=300)

plt.show()
```

codes/Python-18.py

A.5.19 Python code for the distribution of the bathymetric data by stacked bar plots

```python
1 #!/usr/bin/env python
2 # coding: utf-8
3 import os
4 import numpy as np
5 import pandas as pd
6 import matplotlib.pyplot as plt
7 from matplotlib import rc
8
9 osudu = oschdir('/Users/pauline/Documents/Python')
10 df = pd.read_csv("Tab-Morph.csv")
11
12 bars1 = df.plate_phill
13 bars2 = df.plate_pacif
14 bars3 = df.plate_maria
15 bars4 = df.plate_carol
16
17 # position of the bars on the x-axis
```
```python
18 profiles = df.profile
19
20 # generate a loop for 25 profiles
21 names = range(1, 26)
22
23 # plotting
24 barWidth = 1
25 ax = plt.subplots(111)
26 plt.bar(profiles, bars1, color='dbd0e6', edgecolor='white',
27        width=barWidth, label='Philippine Plate')
28 plt.bar(profiles, bars2, bottom=(bars1), color='a0d8ef',
29        edgecolor='white', width=barWidth,
30        label='Pacific Plate')
31 plt.bar(profiles, bars3, bottom=(bars1 + bars2), color='eebbcb',
32        edgecolor='white', width=barWidth,
33        label='Mariana Plate')
34 plt.bar(profiles, bars4, bottom=(bars1 + bars2 + bars3), color='c1d8ac',
35        edgecolor='white', width=barWidth,
36        label='Caroline Plate')
37
38 # Custom X axis
39 pltxticks(profiles, names, fontweight='normal', fontsize=7, rotation=30)
40
41 # Show graphic
42 plt.legend()
43 ax.legend(loc='upper center', bbox_to anchor=(0.5, -0.10),
44          shadow=True, markerscale=2, ncol=4, fontsize=6, title=False)
45 ax.set xlabel('Profiles (1:25)', fontsize=10)
46 ax.set ylabel('Observations (1:518)', fontsize=10)
47 plt. title('Mariana Trench: Stacked barplots for the distribution \nof the bathymetric observations across
tectonic plates',
48          fontsize=10, fontfamily='sans-serif')
49
50 # visualize and save
51 plt.tight_layout()
52 plt. savefig('plot_StackBar.png', dpi=300)
53 plt. show()
```

codes/Python-19.py

A.5.20 Python code for analysis of the distribution of sediment thickness, stacked bar charts

```python
1 #!/usr/bin/env python
2 # coding: utf-8
3 import pandas as pd
4 import numpy as np
5 import seaborn as sns
6 import matplotlib as mpl
7 import matplotlib.pylayer as plt
8 import matplotlib.ticker as ticker
9 import os
10
11 sns. set style('white')
12 sns. set context('paper')
13
14 # data frame
15 os. chdir('/Users/pauline/Documents/Python')
16 df = pd. read_csv("Tab-Morph.csv")
17 df = pd. Frame(data = df, columns = ['Min', '1stQ', 'Median', 'Mean', '1stQ', 'Max'])
18
19 # plotting
20 fig = plt. figure(figsize=(8, 6))
21 ax = df. plot. area(stacked = False, alpha = 0.8, colormap = 'PuBu_r')
22 plt. legend(bbox_to anchor=(0.05, 1), loc=2, borderaxespad=0.)
23 plt. title('Stacked area chart for the Mariana Trench bathymetry: \ndepths by 25 cross-section profiles',
```
24 | fontsize=12, fontfamily='serif')
25 | ax.set_xlabel('Bathymetric profiles')
26 | ax.set_ylabel('Depths, m')
27 | plt.xticks(np.arange(1, 26, step=1), rotation=30)
28 |
29 | # visualizing and saving
30 | plt.tight_layout()
31 | plt.savefig('plot_StackAreaB.png', dpi=300)
32 | plt.show()

codes/Python-20.py

A.5.21 Python code for pie charts visualizing bathymetry vs tectonic plates

1 | #!/usr/bin/env python
2 | # coding: utf-8
3 | import os
4 | import pandas as pd
5 | import numpy as np
6 | from matplotlib import pyplot as plt
7 | 
8 | osudu = oschdir('/Users/pauline/Documents/Python')
9 | dfM = pd.read_csv("Tab-Morph.csv")
10 11 | # dataset
12 | df = pd.DataFrame({'Pacific Plate':dfM.plate_pacif,
13 | 'Philippine Plate':dfM.plate_phill,
14 | 'Mariana Plate':dfM.plate_maria,
15 | 'Caroline Plate':dfM.plate_carol},
16 | index=dfM.profile)
17 18 | # plot chart
19 | df plot(kind='pie', subplots = True, figsize=(10, 10),
20 | legend=False, table=False,
21 | fontsize=8, sort_columns = True,
22 | layout=(2, 2), colormap='tab20b',
23 | title='Mariana Trench: Pie charts for the \nsample points distribution by tectonic plates',
24 | )
25 26 | # visualize and save
27 | plt.tight_layout()
28 | plt.savefig('plot_Pie.png', dpi=300)
29 | plt.show()

codes/Python-21.py

A.5.22 Python code for QQ plots visualizing descriptive statistics for the bathymetry

1 | from __future__ import print_function
2 | %matplotlib inline
3 | import os
4 | import numpy as np
5 | from scapy import stats
6 | import pandas as pd
7 | import matplotlib.pylab as pylab
8 | import matplotlib.pyplot as plt
9 | import matplotlib.artist as martist
10 | from matplotlib.offsetbox import AnchoredText
11 | import statsmodels{o}api as sm
12 | from statsmodels graphics{o}api import qqplot
13 | import seaborn as sns
14 |
15 | sns.set_style('darkgrid')
16 |
```python
17 os.chdir('/Users/pauline/Documents/Python')
18 df = pd.read_csv("Tab-Morph.csv")
19
20 params = {'figure.figsize': (14, 7),
21           'figure.dpi': 300,
22           'figure titlesize': 16,
23           'font family': 'Palatino',
24           'axes labelsize': 10,
25           'xtick labelsize': 8,
26           'ytick labelsize': 8,
27           'axes labelpad': 2,
28       }
29 pylab.rcParams.update(params)
30
31 def add_at(axes, t, loc=2):
32     fp = dict(size=11)
33     _at = AnchoredText(t, loc=loc, prop=fp)
34     axes.addArtist(_at)
35     return _at
36
37 fig, axes = plt.subplots(2, 3)
38
39 plt.suptitle('QQ statistics plots of the geology of the Mariana Trench',
40             x=0.54, y=.92)
41
42 fig = qqplot(df.sedim_thick, line='q', fit=True,
43               linewidth=.5, alpha=.5,
44               markerfacecolor='#00a497', markeredgedcolor='grey',
45               ax=axes[0, 0])
46 add_at(axes[0, 0], "A")
47
48 fig = qqplot(df.slope_angle, line='q', fit=True,
49               linewidth=.5, alpha=.5, markerfacecolor='#4d5aaf',
50               markeredgedcolor='grey', ax=axes[0, 1])
51 add_at(axes[0, 1], "B")
52
53 fig = qqplot(df.plate_pacif, line='q', fit=True,
54               linewidth=.5, alpha=.4, markerfacecolor='#69821b',
55               markeredgedcolor='grey', ax=axes[0, 2])
56 add_at(axes[0, 2], "C")
57
58 fig = qqplot(df.plate_phill, line='q', fit=True,
59               linewidth=.5, alpha=.4, markerfacecolor='#640125',
60               markeredgedcolor='grey', ax=axes[1, 0])
61 add_at(axes[1, 0], "D")
62
63 fig = qqplot(df.plate_maria, line='q', fit=True,
64               linewidth=.1, alpha=.4, markerfacecolor='#b44c97',
65               markeredgedcolor='grey', ax=axes[1, 1])
66 add_at(axes[1, 1], "E")
67
68 fig = qqplot(df.igneous_volc, line='q', fit=True,
69               lw=.1, alpha=.4, markerfacecolor='#4d5aaf',
70               markeredgedcolor='grey', ax=axes[1, 2])
71 add_at(axes[1, 2], "F")
72
73 plt.show()
```

codes/Python-22.py

A.5.23 Python code for WLS calculations

```python
1 #!/usr/bin/env python
2 # coding: utf-8
3 from __future__ import print_function
4 import os
```
```python
5 $matplotlib inline
6 import numpy as np
7 from scipy import stats
8 import pandas as pd
9 import statsmodels.api as sm
10 import matplotlib.pyplot as plt
11 from statsmodels.sandbox.regression.predstd import wlsær prediction
12 from statsmodels.iolib.table import (SimpleTable, default_txt fmt)
13 import seaborn as sns
14 from patsy import dmatrices
15
16 sns.set_style('whitegrid')
17
18 os chdir('/Users/pauline/Documents/Python')
19 df = pd.read_csv("Tab-Morph.csv")
20 df = df.dropna()
21 nsample = 25
22 x = df.plate_pacif
23 X = np. column_stack((x, (x - 5)**2))
24 X = sm.addconstant(X)
25 beta = [5., 0.5, -0.01]
26 sig = 0.5
27 w = np. ones(nsample)
28 w[nsample * 6//10:] = 3
29 y_true = np. dot(X, beta)
30 e = np. random. normal (size = nsample)
31 y = y_true + sig * w * e
32 X = X[: , [0,1]]
33
34 mod_wls = sm.WLS(y, X, weights = 1. /(w ** 2))
35 res_wls = mod_wls.fit()
36 print (res_wls. summary())
37
38 res_ols = sm.OLS(y, X).fit()
39 print (res_ols. params)
40 print (res_wls. params)
41
42 se = np. vstack([ [res_wls.bse], [res_ols.bse], [res_ols.HC0 se],
43                  [res_ols.HC1 se], [res_ols.HC2 se], [res_ols.HC3 se] ]])
44 se = np. round (se,4)
45 colnames = ['x1', 'const']
46 rownames = ['WLS', 'OLS', 'OLS_HCO', 'OLS_HC1', 'OLS_HC3', 'OLS_HC3']
47 tabl = SimpleTable (se, colnames, rownames, txt fmt = default_txt fmt)
48 print (tabl)
49
50 covb = res_ols.cov_params()
51 prediction_var = res_ols.mse_resid + (X * np. dot(covb, X.T.).T).sum(1)
52 prediction_std = np. sqrt (prediction_var)
53 tppf = stats.t. ppf(0.975, res_ols. df_resid)
54
55 prstd_ols, iv_1_ols, iv_u_ols = wlsær prediction_std(res_ols)
56
57 prstd, iv_1, iv_u = wlsær prediction_std(res_wls)
58
59 bbox props = dict (boxstyle='round', pad=0.3', fc='w',
60                  edgecolor='grey', linewidth=1, alpha=0.9)
61
62 fig, ax = plt. subplots (figsize=(8,6), dpi=300)
63 ax. plot(x, y, 'o', label="Bathymetric \nObservations", linewidth=.7)
64 ax. plot(x, y_true, 'b--', label="True", linewidth=.9)
65 # OLS
66 ax. plot(x, res_ols.fittedvalues, 'r--')
67 ax. plot(x, iv_u_ols, 'r--', label="Ordinary Least Squares", linewidth=.7)
68 ax. plot(x, iv_1_ols, 'r--', linewidth=.7)
69 # WLS
70 ax. plot(x, res_wls.fittedvalues, 'g--.')
71 ax. plot(x, iv_u, 'g--', label="Weighted Least Squares", linewidth=.7)
72 ax. plot(x, iv_1, 'g--', linewidth=.7)
73 ax. legend(loc="best");
```
```python
74 ax.set_xlabel('Number of observations', fontsize=10)
75
76 plt.title("Weighted Least Squares of data distribution ")
77 \nat Pacific Plate by 25 bathymetric profiles",
78     fontsize=14)
79 plt annotate('A', xy=(-0.01, 1.06), xycoordinates="axes fraction",
80             fontsize=18, bbox=bbox)
81
82 # visualizing and saving
83 plt.tight_layout()
84
85 plt.subplots Adjust (top=0.87, bottom=0.08,
86                  left=0.10, right=0.95,
87                  hspace=0.2, wspace=0.2
88 )
89 plt savefig('plot_WLSa.png', dpi=300)
90 plt show()
```

codes/Python-23.py

A.5.24 Python code for quantile (QQ) regression

```python
1 from __future__ import print_function
2 %matplotlib inline
3 import os
4 import numpy as np
5 from scapy import stats
6 import pandas as pd
7 import matplotlib.pylab as pylab
8 import matplotlib.pylab as plt
9 import matplotlib.artist as martist
10 from matplotlib.offsetbox import AnchoredText
11 import statsmodels{o}api as sm
12 from statsmodels graphics{o}api import qqplot
13 import seaborn as sns
14
15 sns.set_style('darkgrid')
16
17 os.chdir('/Users/pauline/Documents/Python')
18 df = pd.read_csv("Tab-Morph.csv")
19
20 params = {'figure.fiel dsize': (14, 7),
21          'figure.dpi': 300,
22          'figure titlesize': 16,
23          'font.family': 'Palatino',
24          'axes labelsize': 10,
25          'xtick labelsize': 8,
26          'ytick labelsize': 8,
27          'axes labelpad': 2,
28        }
29 pylab .rcParams.update (params)
30
31 def add_at (axes, t, loc=2):
32     fp = dict (size=11)
33     _at = AnchoredText (t, loc=loc, prop=fp)
34     axes.add_artist(_at)
35     return _at
36
37 fig, axes = plt.subplots (2, 3)
38
39 plt.suptitle('QQ statistics plots of the geology of the Mariana Trench',
40             x=0.54, y=.92)
41
42 fig = qqplot(df.sedim_thick, line='q', fit=True,
43              linewidth=.5, alpha = .5,
44              markerfacecolor='00a497', markeredgecolor='grey',
45              ax=axes[0,0])
```
```python
46 add_at(axes[0, 0], "A")
47
48 fig = qqplot(df.slope_angle, line='q', fit=True,
50               linewidth=.5, alpha = .5, markerfacecolor='#4d5aaf',
51               markeredgecolor='grey', ax=axes[0, 1])
52
53 fig = qqplot(df.plate_pacif, line='q', fit=True,
54               linewidth=.5, alpha = .4, markerfacecolor='#69821b',
55               markeredgecolor='grey', ax=axes[0, 2])
56
57 add_at(axes[0, 2], "C")
58
59 fig = qqplot(df.plate_phill, line='q', fit=True,
60               linewidth=.5, alpha = .4, markerfacecolor='#640125',
61               markeredgecolor='grey', ax=axes[1, 0])
62
63 fig = qqplot(df.plate_maria, line='q', fit=True,
64               linewidth=.1, alpha = .4, markerfacecolor='#b44c97',
65               markeredgecolor='grey', ax=axes[1, 1])
66
67 add_at(axes[1, 0], "D")
68
69 fig = qqplot(df.igneous_volc, line='q', fit=True,
70               lw=.1, alpha = .4, markerfacecolor='#4d5aaf',
71               markeredgecolor='grey', ax=axes[1, 2])
72
73 add_at(axes[1, 2], "F")
74
75 plt.show()
```

codes/Python-24.py

A.5.25 Python code for SARIMA model

```python
1 #!/usr/bin/env python
2 # coding: utf-8
3 import os
4 import numpy as np
5 import pandas as pd
6 from Kap统计 import norm
7 import statsmodels.ap as sm
8 import matplotlib.pyplot as plt
9 from datetime import datetime
10 import requests
11 from io import BytesIO
12 import seaborn as sns
13
14 sns.set_style('darkgrid')
15
16 os.chdir('/Users/pauline/Documents/Python')
17 data = pd.read_csv("Tab-Morph.csv")
18 data.index = data.profile
19
20 # Fit the model
21 mod = sm.tsa statespace.SARIMAX(data['sedim_thick'], trend='c', order=(1,1,1))
22 res = mod.fit Nature)
23 print(res综述性)
24
25 # Dataset
26 data['ln_wpi'] = np.log(data['sedim_thick'])
27 data['D.ln_wpi'] = data['plate_phill'].diff()
28
29 # Graph data
30 fig, axes = plt.subplots(1, 2, figsize=(15,4), dpi=300)
31
32 # Levels
33 axes[0].plot(data.index._mpl_repr(), data['sedim_thick'],")
```
```python
34 axes[0].set_xlabel('Bathymetric profiles, 1:25', fontsize=10)
35 axes[0].set(title='Mariana Trench: Sediment thickness index, \nby bathymetric profiles')
36 axes[0]. annotate('A', xy=(0.95, .92), xycoordinates="axes fraction", fontsize=12,
37               bbox=dict(Boxstyle='round', pad=0.3', fc='w', edgecolor='grey', linewidth=1, alpha=0.9))
38
39 # Log difference
40 axes[1].plot(data.index._mpl_repr(), data['D.ln_wpi'], '-')
41 axes[1].hlines(0, data.index[0], data.index[-1], 'r')
42 axes[1].set_xlabel('Bathymetric profiles, 1:25', fontsize=10)
43 axes[1].set(title='Mariana Trench: Data distribution index on \nPhillipine Plate, difference of logs')
44 axes[1]. annotate('B', xy=(0.95, .92), xycoordinates="axes fraction", fontsize=12,
45               bbox=dict(Boxstyle='round', pad=0.3', fc='w', edgecolor='grey', linewidth=1, alpha=0.9))
46
47 # Graph data
48 fig, axes = plt.subplots(1, 2, figsize=(15,4), dpi=300)
49
50 fig = sm.graphics.tsa.plot_acf(data iloc [1: ]['D.ln_wpi'], lags=21, ax=axes[0])
51 fig[0]. annotate('C', xy=(0.95, .92), xycoordinates="axes fraction", fontsize=12,
52               bbox=dict(Boxstyle='round', pad=0.3', fc='w', edgecolor='grey', linewidth=1, alpha=0.9))
53
54 fig = sm.graphics.tsa. plot_pacf(data iloc [1: ]['D.ln_wpi'], lags=21, ax=axes[1])
55 fig[1]. annotate('D', xy=(0.95, .92), xycoordinates="axes fraction", fontsize=12,
56               bbox=dict(Boxstyle='round', pad=0.3', fc='w', edgecolor='grey', linewidth=1, alpha=0.9))
57
58 plt.show()
```

codes/Python-25.py

A.5.26 Python code for Euler-Venn diagrams

```python
1 #!/usr/bin/env python
2 # coding: utf-8
3 from matplotlib import pyplot as plt
4 from matplotlib import cm
5 from matplotlib_venn import venn2, venn2_circles, venn3, venn3_circles
6
7 figure, axes = plt.subplots(2, 2, figsize=(7, 7), dpi=300)
8
9 bbox props = dict(Boxstyle='round', pad=0.3', fc='w',
10                 edgecolor='grey', linewidth=1, alpha=0.9)
11
12 venn3(subsets=(6317, 3552, 2949, 0, 0, 0, 132),
13        ax=axes[0][0], alpha=.3,
14        set_colors=('blue','lightblue','green'),
15        set labels = ('Philippine', 'Mariana', 'Pacific', 'Caroline'))
16 plt annotate('Caroline', xy=(-0.6, 1.3),
17           xycoordinates="axes fraction", fontsize=12)
18 plt annotate('A', xy=(-1.55, 2.4),
19           xycoordinates="axes fraction",
20           fontsize=12, bbox=bbox=bbox props)
21
22 venn3(subsets=(1086, 2801, 1550, 0, 0, 2293, 4883),
23        set labels = ('Sediment \nthickness', 'Slope angle', 'Igneous \nvolcanic spots'),
24        set_colors=('#a59aca','#e45e32','#aacf53'),
25        alpha = .7, ax=axes[0][1])
26 plt annotate('B', xy=(-0.05, 2.4),
27           xycoordinates="axes fraction",
28           fontsize=12, bbox=bbox=bbox props)
29
30 venn3(subsets=(4, 1, 6, 6, 4, 5, 1),
31        set labels = ('Strong \nSlope', 'Extreme \nSlope', 'Steep Slope'),
32        set_colors=('#98d98e','#d9333f','#ffd900'),
33        alpha = .7, ax=axes[1][0])
34 plt annotate('Very \nSteep', xy=(-1.4, 0.08),
35           xycoordinates="axes fraction", fontsize=12)
36 plt annotate('Very \nStrong', xy=(-0.56, 0.07),
```
```python
37    xycoordinates="axes fraction", fontsize=12)
38    plt annotate('C', xy=(-1.55, 1.02),
39                xycoordinates="axes fraction",
40                fontsize=12, bbox=bbox=bbox
41
42    venn2(subsets=('10': 1, '01': 1, '11': 1},
43            set labels = ('GIS', 'R & Python', 'Geology'),
44            set colors=('pink','purple','magenta'),
45            alpha = .3, ax=axes[1][1])
46
47    plt annotate('Geology',
48                xy=(0.8, 0.08), xycoordinates="axes fraction", fontsize=12)
49    plt annotate('D', xy=(-.05, 1.02),
50                xycoordinates="axes fraction",
51                fontsize=12, bbox=bbox=bbox props)
52
53    plt.suptitle('Interplay of various factors in \nMariana Trench system: Euler-Venn diagrams',
54                 x=0.54, y=.98, fontsize=12)
55
56    # visualizing and saving
57    plt.tight_layout()
58
59    plt.subplots Adjust (top=0.90, bottom=0.08,
60                      left=0.10, right=0.95,
61                      hspace=0.25, wspace=0.35
62)
63
64    plt savefig('plot_Venn.png', dpi=300)
65    plt show()
```

codes/Python-26.py
## A.6 R language scripts

### A.6.1 R code to create histograms using (ggplot) library

Source data available on my GitHub.

```r
MDepths <- read.csv("Depths.csv", header=TRUE)
X01<- MDepths[,01]
X01<-X01[!is.na(X01)]
as.data.frame(X01)
dat01<- data.frame(X01)
p01<-ggplot.dat01(aes(X01)) +
  labs(title = "Profile Nr.01", x = "Depths, m", y = "Density") +
  theme(
    plot.title = element_text(family = "Skia", face = 2, size = 10),
    panelITAITA=ggplot2::elementRect(fill = "gray91"),
    legendDash = c(.95, .95),
    legend justification = c("right", "top"),
    legend.box.just = "right",
    legend.key = margin(6, 6, 6, 6),
    legend direction = "vertical",
    legendett = element-blank(),
    legend.key.width = unit(.5,"cm"),
    legend.key height = unit(.3,"cm"),
    legend-spacing = unit(.3,"cm"),
    legendbox = elementRect(colour = "honeydew4", size=0.2),
    legend.text = element_text(family = "Arial", colour="black", size=6, face=1),
    legend.title = element-blank(),
    strip.text.x = element_text(colour = "white"),
    panelITAmajor = element_line("white", size = 0.3),
    panelITAmenor = element_line("white", size = 0.3, linetype = "dotted"),
    axis.text.x = element_text(family = "Arial", face = 3, color = "gray24", size = 5, angle = 0),
    axis.text.y = element_text(family = "Arial", face = 3, color = "gray24", size = 4, angle = 90),
    axis.ticks = unit(.1,"cm"),
    axis line = element-blank(),
    # axis line = element line (size = .3, color = "grey80", linetype = "solid"),
    axis.text.y = element_text(margin = margin(t = 20, r = .3), family = "Times New Roman", face = 1, size = 6)
  ),
  axis.title.x = element_text(family = "Times New Roman", face = 1, size = 6, margin = margin(t = .2))) +
  scale_x continuous (breaks = pretty (dat01$X01, n = 4), minor_breaks = seq (min (dat01$X01), max (dat01$X01), by = 500)) +
  scale_y continuous (breaks = scales::pretty_breaks(n = 4), labels = scales:::percent) +
  scale fill distiller ( palette = "RdGy") +
  scale_color_manual (name = "Statistics:", values = c(median = "purple", mean = "green4", density = "blue", norm_dist = "black")) +
  geom_histogram (binwidth = 200, aes (fill = ..density.., x = dat01$X01, y = ..density..), color = "blue", size = .1)
  +
  stat_function (fun = dnorm, args = list(mean = mean (dat01$X01), sd = sd (dat01$X01)), lwd = 0.2, color = 'black') +
  stat_density (geom = "line", size = .3, aes (color = "density")) +
    geom_vline (aes (color = "mean", xintercept = mean (X01)), lty = 4, size = .3) +
    geom_vline (aes (color = "median", xintercept = median (X01)), lty = 2, size = .3) +
    geom_vline (aes (color = "norm_dist", xintercept = dnorm (X01)), lty = 2, size = .3)
)

p01
```

codes/R-01.r
A.6.2 R code to generate boxplots 'whiskerplots' using default boxplot function

Source data available on my GitHub.

1
2 # BoxPlot (or WhiskerPlot)
3
4 # Part 1: create data.frame
5
6 # step-1. read-in table. generate data frame.
7 MDepths <- read.csv("Depths.csv", header=TRUE, sep = ",")
8 # step-2. clean up data frame from NA values
9
10 MDepths <- na.omit(MDepths)
11
12 row.has.na <- apply(MDF, 1, function(x)(any(is.na(x)))) # check up deleted NA
13
14 sum(row.has.na) # sum up NA values: [1] 0
15
16 head(MDepths) # look up cleaned data frame.
17
18 # Part 2: create "whisker boxplot"
19
20 # step-3. generate list of profiles (to be shon on axis X)
21
22 profile_names <- paste(c("profile"), seq(1:25), sep="")
23
24 # step-4. generate box plot using arguments (here: 25 profiles)
25
26 p<- boxplot(MDepths$profile1, MDepths$profile2, MDepths$profile3, MDepths$profile4, MDepths$profile5, MDepths$
27 profile6, MDepths$profile7, MDepths$profile8, MDepths$profile9, MDepths$profile10, MDepths$profile11,
28 MDepths$profile12, MDepths$profile13, MDepths$profile14, MDepths$profile15, MDepths$profile16, MDepths$
29 profile17, MDepths$profile18, MDepths$profile19, MDepths$profile20, MDepths$profile21, MDepths$profile22,
30 MDepths$profile23, MDepths$profile24, MDepths$profile25,
31 main = "Mariana Trench Depths Boxplot",
32 outline = TRUE,
33 outlier.color = "seagreen", outlier.shape = 8, outlier.size = 2,
34
35 # xlab = "Profiles",
36 ylab = "Depths",
37 las = 2,
38 col = viridis(25, alpha=.2),
39 names = profile_names)
40
41 p

codes/R-02.r
A.6.3 R code for notched boxplot using (ggboxplot)

Source data available on my GitHub.

```R
# BoxPlot (or WhiskerPlot) using ggboxplot
# Part 1: data.frame
# step-1. read in table, create data frame
MDepths <- read.csv("Depths.csv", header=TRUE, sep = ",")
# step-2. clean NA

df <- na.omit(MDepths)

row.has.na <- apply(MDF, 1, function(x) (any(is.na(x)))) # , NA

sum(row.has.na) # sum up NA: [1] 0

head(df) # look up data frame
# step-3. select profiles depths)

MDepths DF <- data.frame(profiles = 1:25, depths = c(df$profile1, df$profile2, df$profile3, df$profile4, df$
profile5, df$profile6, df$profile7, df$profile8, df$profile9, df$profile10, df$profile11, df$profile12, df
$profile13, df$profile14, df$profile15, df$profile16, df$profile17, df$profile18, df$profile19, df$
profile20, df$profile21, df$profile22, df$profile23, df$profile24, df$profile25))

# Part 2: boxplot ("whisker boxplot")
# step-4. plot by MDepths DF.

p<- ggboxplot(
  MDepths DF,
  title="11Mariana Trench, Profiles 1-25.",
  subtitle = "Notched Boxplot for Data Groups by 25 Profiles with Outliers",
  caption = "Statistics Processing and Graphs: \nR Programming. Data Source: QGIS",
  x = "profiles",
  y = "depths",
  width = 0.8,
  notch = TRUE,
  fill = "profiles",
  linetype = 1, size = .1,
  outlier.colour = "grey44",
  palette = c("magma"),
  orientation = "horizontal"
)

p
# step-5 add theme
boxplot_Mariana<- p +
  theme(
    plot.title = element_text(family = "Kai", face = "bold", size = 12),
    plot.subtitle = element_text(family = "Hei", face = "bold", size = 8),
    plot caption = element_text face = 2, size = 6),
    panel-background=ggplot2::elementRect (fill = "white"),
    legend.justification = c(.85, .1),
    legend.position = c(.85, .1),
    legend.box.just = "right", legendmargin = margin(6, 6, 6, 6),
    legend direction = "vertical",
    legend background = elementRect (fill = "white"),
    legend.key.width = unit(.3,"cm"),
    legend.key height = unit(.3,"cm"), legendspacing = unit(.3,"cm"),
    legend.box-background = elementRect (colour = "honeydew4", size=0.2),
    legend.text = element_text (family = "Arial", colour="black", size=6, face=1),
    legend.title = element_text (family = "Arial", colour="black", size=6, face=1),
    strip.text.x = element_text (colour = "white"),
    panel.grid.major = element_line("gray24", size = 0.1, linetype = "dotted"),
    panel.grid.minor = element_line("gray24", size = 0.1, linetype = "dotted"),
    axis.text.x = element_text (family = "Arial", face = 3, color = "gray24", size = 6, angle = 15),
    axis.text.y = element_text (family = "Arial", face = 3, color = "gray24", size = 6, angle = 90),
    axis.ticks.length = unit (.1,"cm"),
    axis line = element_line (size = .3, colour = "grey80"),
    axis.title.y = element_text (margin = margin (t = 20, r = .3), family = "Times New Roman", face = 2, size = 8)
  ),
  axis title.x = element_text (family = "Times New Roman", face = 2, size = 8,margin = margin (t = .2)))
boxplot_Mariana
```

codes/R-03.r
57 axis.ticks.length=unit(.1,"cm"),
58 axis line = element_line(size = .3, colour = "grey80"),
59 axis.title.y = element_text(margin = margin(t = 20, r = .3), family = "Times New Roman", face = 2, size = 8),
60 axis.title.x = element_text(family = "Times New Roman", face = 2, size = 8, margin = margin(t = .2))) +
61 guides(col = guide legend(nrow = 2, ncol = 3, byrow = TRUE)) # extend legend vertically.
62
QQ_facetwrapMD

codes/R-04.r

A.6.5 R code for regression analysis for the bathymetric profiles

Source data available on my GitHub.

1 # Regression Analysis
2 # Part 1: create data.frame
3 # step-1. read in table, create data frame.
4 MDepths <- read.csv("Depths.csv", header=TRUE, sep = ",")
5
6 # step-2. clean up data frame from the NA
7 MDF <- na.omit(MDepths)
8 row.has.na <- apply(MDF, 1, function(x){any(is.na(x))})
9 (row.has.na) # sum up NA, result: [1] 0
10 head(MDF) #
11
12 # Part 2: perform regression analysis and plot (Mathematical method includes 3 types of curves with confidence intervals and quantiles).
13 # step-3. (here: profile \#1)
14 Loess_profile11 <- ggplot(MDF, aes(x = observ, y = profile11)) +
15 geom_point(aes(x = observ, y = profile11, colour = "Samples", shape = "Samples"), show.legend=TRUE) +
16 geom.smooth(aes(x = observ, y = profile11, colour = "Loess method"), method = loess, se = TRUE, span = .4, size = .3, linetype = "solid", show.legend=TRUE) +
17 geom.smooth(aes(x = observ, y = profile11, colour = "Glm method"), method = glm, se = FALSE, span = .4, size=.4, linetype = "dotted", show.legend=TRUE) +
18 geom.smooth(aes(x = observ, y = profile11, colour = "Lm method"), method = lm, se = TRUE, size=.3, linetype = "solid", show.legend=TRUE) +
19 geom.quantile(aes(x = observ, y = profile11, colour = "Quantiles"), linetype = "solid", show.legend=TRUE) +
20 xlab("Observations") +
21 ylab("Depths, m") +
22 scale_color_manual(values = c("Samples" = seagreen, "Loess method" = "red", "Lm method" = "blue", "Glm method" = "orange", "Quantiles" = "purple")) + # set up colors
23 scale shape_manual(values = c("Samples" = 1)) + # set up shapes (here: \#1 - "transparent circle")
24 # scale_size_manual(values = c.profile11 = 1)) +
25 labs(title="Mariana Trench, Profile 11.",
26 subtitle = "Local Polynomial Regression, \nConfidence Interval, Quantiles \n(LOESS method: locally weighted scatterplot \nsmoothing for non-parametric regression)",
27 caption = "Statistics Processing and Graphs: \nR Programming. Data Source: QGIS") +
28 theme(
29 plot-margin = margin(5, 10, 20, 5),
30 plot.title = element_text(family = "Kai", face = "bold", size = 8),
31 plot.subtitle = element_text(family = "Hei", face = "bold", size = 6),
32 plotCAPTION = element_text face = 2, size = 6),
33 panelancor=ggplot2::elementRect(fill = "white"),
34 legend.justification = "bottom",
35 legendposition = "bottom",
36 legend.boxjust = "right",
37 legend direction = "horizontal",
38 legend.box = "horizontal",
39 legend.boxancor=elementRect(colour = "honeydew4", size=0.2),
40 legendancor=elementRect(fill = "white"),
41 legend.keywidth = unit(1,"cm"),
42 legend.keyheight = unit(.5,"cm"),
43 legend-spacing.x = unit(.2,"cm"),
44 legend-spacing.y = unit(.1,"cm"),
45 legend.text = element_text(colour="black", size=6, face=1),
46 legend.title = element_text(colour="black", size=6, face=1),
47 strip.text.x = element_text(colour = "white", size=6, face=1),
48 panelancor=element_line("gray24", size = 0.1, linetype = "solid"),
```R
49 panel.grid.minor = element_line("gray24", size = 0.1, linetype = "dotted"),
50 axis.text.x = element_text(face = 3, color = "gray24", size = 6, angle = 15),
51 axis.text.y = element_text(face = 3, color = "gray24", size = 6, angle = 15),
52 axis.ticks.length=unit(.1,"cm"),
53 axis line = element_line(size = .3, colour = "grey80"),
54 axis.title.y = element_text(margin = margin(t = 20, r = .3), face = 2, size = 8),
55 axis.title.x = element_text(face = 2, size = 8, margin = margin(t = .2))) +
56 guides(col = guide legend(nrow = 1, ncol = 6, byrow = TRUE))
57 Loess_profile11
58
59 # Part 2: combine 3 plots on one layout
60 library(ggpubr)
61 #ggarrange function
62
63 Regression_Profiles11824 <- ggarrange(Loess_profile11, Loess_profile18, Loess_profile24, labels = c("1", "2",
64 "3"), ncol = 3, nrow = 1, common.legend = TRUE, legend = "bottom")
```

codes/R-05.r

## A.6.6 R code for cluster analysis, dendrograms

Source data available on my GitHub.

```R
1 # Part 1: generate data.frame
2 # step-1. read-in table
3 MDepths <- read.csv("Depths.csv", header=TRUE, sep = ",")
4 # step-2. clean up data frame from NA
5 MDF <- na.omit(MDepths)
6 row.has.na <- apply(MDF, 1, function(x) {any(is.na(x))})
7 sum(row.has.na) # : [1] 0
8 head(MDF) #
9 # Part-2. Hierarchical Cluster Analysis, Dendrograms
10 library(dendextend)
11 # step-3. generate 1st dendrogram (here: 25 clusters)
12 dend <- MDF[1:25,] %>% scale %>% dist %>% # calculate a distance matrix,
13 hclust (method = "average") %>%
14 as.dendrogram %>%
15 set("labels", c("profile"), rep(1:25), sep="")) %>%
16 set("labels_col", "blue") %>% set("labels_cex", c(.7)) %>%
17 set("branches_k_color", k=5) %>% set("branches_lwd", 1) %>%
18 set("nodes_pch", 19) %>% set("nodes_cex", 1) %>%
19 set("nodes_col", "pluml") %>%
20 set("leaves_pch", 19) %>% set("leaves_col", c("blue", "red"))
21 dend %>% plot(main = "Mariana Trench: \nCluster Analysis Dendrogramm-1 of the Bathymetric Profiles \nUnsorted
22 Dendrogramm")
23 # step-4. generate 2nd dendrogram from the 1st one, sorted by cluster size
24 dend2 <- sort(dend)
25 dend2 %>% set("branches_k_color", k=3) %>% set("branches_lwd", 1) %>%
26 set("labels_col", "blue") %>% set("labels_cex", c(.7)) %>%
27 set("branches_k_color", k=5) %>% set("branches_lwd", 1) %>%
28 set("nodes_pch", 19) %>% set("nodes_cex", 1) %>%
29 set("nodes_col", "pluml") %>%
30 set("leaves_pch", 19) %>% set("leaves_col", c("blue", "red"))
31 dend2 %>% plot(main = "Mariana Trench: \nCluster Analysis Dendrogramm-2 of the Bathymetric Profiles \nSorted
32 Dendrogramm")
33 # step-5. compare both dendrograms (sorted one with unsorted)
34 tanglegram(dend, dend2)
35 tanglegram(dend, dend2) %>% plot(main = "Mariana Trench: \nComrapison of the Cluster Dendrogramms 1 and 2")
36 # step-6. Hierarchical Clustering with P-Values via Multiscale Bootstrap Resampling
37 data(MDF)
38 result <- pvclust(MDF, method.dist="cor", method.hclust="average", nboot=10)
39 plot(result, main = "Mariana Trench Bathymetric Profiles 1-25: \nHierarchical Clustering with P-Values (AU/BP,
40 %) \nvia Multiscale Bootstrap Resampling")
41 pvrect(result)
42 # step-7. pvclust and dendextend - results in view of sorted dendrogram
43 result %>% as.dendrogram %>%
```

li

Polina Lemenkova:

Deep-Sea Trenches of the Pacific Ocean: ...Data Modeling by GMT, Python and R
```r
42 set("branches_k_color", k = 5, value = c("purple", "orange", "cyan1", "firebrick1", "springgreen")) %>%
43 plot(main = "Mariana Trench Bathymetric Profiles 1-25: Cluster Dendrogram\nwith AU/BP Values (%). nAU:
Approximately Unbiased p-Value \n and BP: Bootstrap Probability")
44 result %>% text
45 result %>% pvrect
46 # the end. results can be saved as a pdf via "Save As" (here: 5 figures for every step from 3- to 7)
```

codes/R-06.r

## A.6.7 R code for correlogram by (ggplot) library

Source data available on my GitHub.

```r
1 # Part 1: generate data.frame
2 # step-1. read in table.
3 MDepths <- read.csv("Depths.csv", header=TRUE, sep = ",")
4 # step-2. clean up data frame from NA values
5 MDF <- na.omit(MDepths)
6 row.has.na <- apply(MDF, 1, function(x) (any(is.na(x)))) # check up if there are any NA
7 sum(row.has.na) # sum up NA, should be: [1] 0
8 head(MDF) # look up data frame
9 # Part 2. Generae and draw correlogram
10 # step-3. Generae correogram matrix from the MDF dataframe using Pearson method as all data are normally
distributed. Because the data are excessive, use only half of them, the other becomes NA. reate
correlation matrix using Pearson, as all variables are normally distributed.
11 thecor<-round(cor(MDF[,sort(c("profile1", "profile2", "profile3", "profile4", "profile5", "profile6", "profile7
", "profile8", "profile9", "profile10", "profile11", "profile12", "profile13", "profile14", "profile15", "
profile16", "profile17", "profile18", "profile19", "profile20","profile21", "profile22", "profile23", "
profile24", "profile25
ehed), method="pearson", use="pairwise completeobs"),2)
12 thecor[lower.tri(thecor)]<- NA
13 thecor
14 # step-4. merge columns "profile" of the matrix using function melt from the library reshape2. Delete NA values
//
15 library(reshape2)
16 thecor<-melt(thecor)
17 thecor$Var1<-as.character(thecor$Var1)
18 thecor$Var2<-as.character(thecor$Var2)
19 thecor<-na.omit(thecor)
20 head(thecor)
21 # step-5. draw correlogram using function geom tile
22 Correlogramm_Mariana <- ggplot(thecor, aes(Var2, Var1)) +
23 geom tile(data=thecor, aes(fill=value), color="white") +
24 scale_fillgradient2(low = "blue", high = "red", mid = "white", midpoint = 0, limit = c(-1,1), name = "
Correlation
")) +
25 coord_equal() +
26 labs(title="Mariana Trench, Profiles Nr.1-25.", subtitle = "Correlogram of Correlation Matrix",
27 caption = "Statistics Processing and Graphs: \nR Programming. Data Source: QGIS") +
28 theme(
29 plotmargin = margin(5, 10, 20, 5),
30 plot.title = element_text(family = "Kai", face = "bold", size = 12), # for Chinese font use Kai
31 plot.subtitle = element_text(family = "Hei", face = "bold", size = 10), # for Chinese font use Hei
32 plotcaption = element_text(face = 2, size = 6),
33 panelGrid=ggplot2::elementRect(fill = "white"),
34 legend justification = "bottom", legend. position = "bottom",
35 legend. box. just = "right",
36 legend. direction = "horizontal",
37 legend. box = "horizontal",
38 legend. box. background = elementRect(colour = "honeydew4", size=0.2),
39 legend. background = elementRect(fill = "white"),
40 legend. key. width = unit(1,"cm"), legend. key. height = unit(.5,"cm"),
41 legend. spacing. x = unit(.2,"cm"), legend. spacing. y = unit(.1,"cm"),
42 legend. text = element_text(colour="black", size=6, face=1),
43 legend. title = element_text(colour="black", size=6, face=1),
44 strip. text. x = element_text(colour = "white", size=6, face=1),
45 panel. grid. major = element_line("gray24", size = 0.1, linetype = "solid"),
46 panel. grid. minor = element_line("gray24", size = 0.1, linetype = "dotted"),
47 axis. text. x = element_text(face = 3, color = "gray24", size = 6, angle = 45),
```
```r
axis.text.y = element_text(face = 3, color = "gray24", size = 6, angle = 15),
axis.ticks.length=unit(.1,"cm"),
axis line = element_line(size = .3, colour = "grey80"),
axis.title.y = element_text(margin = margin(t = 20, r = .3), face = 2, size = 8),
axis.title.x = element_text(face = 2, size = 8, margin = margin(t = .2))) +
guides(col = guide legend(nrow = 1, ncol = 6, byrow = TRUE)) # improve design of the legend.
Correlogramm_Mariana
ggsave("Correlogramm_Mariana.pdf", device = cairo pdf, fallback_resolve = 300)
```

codes/R-07.r

## A.6.8 R code for Principal Component Analysis (PCA)

Source data available on my GitHub.

```r
# libraries: 'factoextra', 'FactoMiner' zip, openxlsx, carData, pbkrtest, rio, car, flashClust, leaps, scatterplot3d, FactoMineR, ca, igraph
# Part 1 Creating dataframe.
MDepths <- read.csv("Depths.csv", header=TRUE, sep = ",") # Reading Table.
df<- read.csv("Depths.csv", header=TRUE, sep = ",")
MDF<- na.omit(MDepths) # step-2. cleaning dataframe from NA values
row.has.na <- apply(MDF, 1, function(x)(any(is.na(x))))
sum(row.has.na) # count NAs: [1] 0
head(MDF) # ready-to-use dataframe.

# Part 2. Create plot of Principal Component Analysis (PCA)
PCA_Mariana <- autoplot(prcomp(MDF), loadings = TRUE, loadings.colour = 'blue', loadings.label = TRUE, loadings
  .label.size = 3) +
geom_point(color = "blue") +
scale_color_brewer(palette="Dark2") +
labs title="Mariana Trench, Profiles Nr.1-25.",
subtitle = "PCA (Principal Component Analysis)",
caption = "Statistics Processing and Graphs: \nR Programming. Data Source: QGIS") + # add theme
theme plotmargin = margin(5, 10, 20, 5),
plot.title = element_text(family = "Kai", face = "bold", size = 12), # Chinese font
plot.subtitle = element_text(family = "Hei", face = "bold", size = 10), # Chinese font
plotCAPtion = element_text(face = 2, size = 6), panel-background=ggplot2::elementRect(fill = "white"),
legend.justification = "bottom", legend(position = "bottom", legend.box.just = "right"),
legend direction = "horizontal", legend.box = "horizontal",
legend.box-background = elementRect(colour = "honeydew4", size=0.2),
legend-background = elementRect(fill = "white"),
legend.key.width = unit(1,"cm"), legend.key height = unit(.5,"cm"), legendSpacing.x = unit(.2,"cm"),
legendSpacing.y = unit(.1,"cm"), legend.text = element_text(colour="black", size=6, face=1),
legend.title = element_text(colour="black", size=6, face=1),
strip.text.x = element_text(colour = "white", size=6, face=1),
panel.grid.major = element_line("gray24", size = 0.1, linetype = "solid"),
panel.grid.minor = element_line("gray24", size = 0.1, linetype = "dotted"),
axis.text.x = element_text(face = 3, color = "gray24", size = 6, angle = 45),
axis.text.y = element_text(face = 3, color = "gray24", size = 6, angle = 15),
axis.ticks.length=unit(.1,"cm"), axis line = element_line(size = .3, colour = "grey80"),
axis.title.y = element_text(margin = margin(t = 20, r = .3), face = 2, size = 8),
axis.title.x = element_text(face = 2, size = 8, margin = margin(t = .2))) +
guides(col = guide legend(nrow = 1, ncol = 6, byrow = TRUE)) # Legend design
PCA_Mariana
```

codes/R-08.r
A.6.9 R code for k-means clustering

Source data available on my GitHub.

1 # Part 1: generate data.frame with geomorphological data
2 # step-1. load table, generate data frame
3 MorDF <- read.csv("Morphology.csv", header=TRUE, sep = ",")
4 head(MorDF)
5 summary(MorDF)
6
7 # Part 2: Clustering
8 # step-2. generate several options of cluster analysis with various k (number of k centers: 2 to 7)
9 k2MorDF <- kmeans(MorDF, centers = 2, nstart = 25)
10 str(k2MorDF)
11 k2MorDF
12
13 fviz_cluster(k2MorDF, data = MorDF)
14 k3MorDF <- kmeans(MorDF, centers = 3, nstart = 25)
15 str(k3MorDF)
16 k3MorDF
17
18 fviz_cluster(k3MorDF, data = MorDF)
19 k4MorDF <- kmeans(MorDF, centers = 4, nstart = 25)
20 str(k4MorDF)
21 k4MorDF
22 fviz_cluster(k4MorDF, data = MorDF)
23
24 k5MorDF <- kmeans(MorDF, centers = 5, nstart = 25)
25 str(k5MorDF)
26 k5MorDF
27 fviz_cluster(k5MorDF, data = MorDF)
28
29 k6MorDF <- kmeans(MorDF, centers = 6, nstart = 25)
30 str(k6MorDF)
31 k6MorDF
32
33 fviz_cluster(k6MorDF, data = MorDF)
34 k7MorDF <- kmeans(MorDF, centers = 7, nstart = 25)
35 str(k7MorDF)
36 k7MorDF
37 fviz_cluster(k7MorDF, data = MorDF)
38 # step-3. save values of plots in p1-p7
39 p2 <- fviz_cluster(k2MorDF, geom = "point", data = MorDF) + ggtitle("Nr. of centers k = 2") + theme(plot.title = element_text(size = 10), legend.title = element_text(size=8), legend.text = element_text(colour="black", size = 8))
40 p3 <- fviz_cluster(k3MorDF, geom = "point", data = MorDF) + ggtitle("Nr. of centers k = 3") + theme(plot.title = element_text(size = 10), legend.title = element_text(size=8), legend.text = element_text(colour="black", size = 8))
41 p4 <- fviz_cluster(k4MorDF, geom = "point", data = MorDF) + ggtitle("Nr. of centers k = 4") + theme(plot.title = element_text(size = 10), legend.title = element_text(size=8), legend.text = element_text(colour="black", size = 8))
42 p5 <- fviz_cluster(k5MorDF, geom = "point", data = MorDF) + ggtitle("Nr. of centers k = 5") + theme(plot.title = element_text(size = 10), legend.title = element_text(size=8), legend.text = element_text(colour="black", size = 8))
43 p6 <- fviz_cluster(k6MorDF, geom = "point", data = MorDF) + ggtitle("Nr. of centers k = 6") + theme(plot.title = element_text(size = 10), legend.title = element_text(size=8), legend.text = element_text(colour="black", size = 8))
44 p7 <- fviz_cluster(k7MorDF, geom = "point", data = MorDF) + ggtitle("Nr. of centers k = 7") + theme(plot.title = element_text(size = 10), legend.title = element_text(size=8), legend.text = element_text(colour="black", size = 8))
45 # step-4. collect all plots on one layout to compare
46 figure <- plot_grid(p2, p3, p4, p5, p6, p7, labels = c("1", "2", "3", "4", "5", "6"), ncol = 2, nrow = 3)
47 # step-5. add comot titla, subtitle and lower subscript.
48 ClustersMariana6 <- figure +
49 labs(title="Mariana Trench, Profiles Nr.1-25.",
50 subtitle = "Geomorphological Cluster Analysis (k-means)",
51 caption = "Statistics Processing and Graphs: \nR Programming. Data Source: QGIS") +
52 theme(plot-margin = margin(5, 10, 20, 5), plot.title = element_text(family = "Kai", face = "bold", size = 12),
53 plot.subtitle = element_text(family = "Hei", face = "bold", size = 10),
```r
54 plot.caption = element_text(face = 2, size = 6), panel-background=ggplot2::elementRect(fill = "white"),
55 legend.justification = "bottom", legendposition = "bottom", legend.box.just = "right", legend direction = "",
56 legend.box = "horizontal", legend.box-background = elementRect(colour = "honeydew4", size=0.2),
57 legend-background = elementRect(fill = "white"),
58 legend.key.width = unit(1,"cm"), legend.key height = unit(.5,"cm"),
59 legend-spacing.x = unit(.2,"cm"), legend-spacing.y = unit(.1,"cm"),
60 legend.text = element_text(colour="black", size=6, face=1),
61 legend.title = element_text(colour="black", size=6, face=1))
62 ClustersMariana6
```

codes/R-09.r

## A.6.10 R code for Pairwise Standard Scatter Plots of k-means Cluster Correlation (comparing 4 tectonic plates)

Source data available on my GitHub.

```r
1 # libraries: 'factoextra', 'FactoMiner' zip, openxlsx, carData, pbkrtest, rio, car, flashClust, leaps,
2 scatterplot3d, FactoMineR, ca, igraph
3 # Part 1: generate data.frame with geomorphology
4 # step-1. load table, generate data.frame
5 MorDF <- read.csv("Morphology.csv", header=TRUE, sep = ",")
6 head(MorDF)
7 summary(MorDF)
8
9 # Part 2: Pairwise Standard Scatter Correlation Plots
10 # step-2. doing cluster analysis with k=6 (optimal number in this case)
11 k6MorDF <- kmeans(MorDF, centers = 6, nstart = 25)
12 str(k6MorDF)
13 k6MorDF
14 fviz_cluster(k6MorDF, data = MorDF)
15
16 # step-3 standard pairwise scatter plots to illustrate the clusters compared to the original variables.
17 #Here: compare angles of steepness of the Mariana Trench on various tectonic plates (it crosses 4 tectonic
18 # 3.1.for Mariana Plate
19 PairM <- MorDF %>%
20 as_tibble() %>%
21 mutate cluster = k6MorDF$cluster,
22 profile = row.names(MorDF) %>%
23 ggplot(aes(x = plate_maria, y = tg_angle, color = factor cluster, label = profile)) +
24 geom_text()
25 # 3.2.for Philippine Plate
26 PairPh <- MorDF %>%
27 as_tibble() %>%
28 mutate cluster = k6MorDF$cluster,
29 profile = row.names(MorDF) %>%
30 ggplot(aes(x = plate_phill, y = tg_angle, color = factor cluster, label = profile)) +
31 geom_text()
32 PairPh
33 # 3.3.for Pacific Plate
34 PairPc<- MorDF %>%
35 as_tibble() %>%
36 mutate cluster = k6MorDF$cluster,
37 profile = row.names(MorDF) %>%
38 ggplot(aes(x = plate_pacif, y = tg_angle, color = factor cluster, label = profile)) +
39 geom_text()
40 PairPc
41 # 3.4.for Caroline Plate
42 PairC<- MorDF %>%
43 as_tibble() %>%
44 mutate cluster = k6MorDF$cluster,
45 profile = row.names(MorDF) %>%
46 ggplot(aes(x = plate_carol, y = tg_angle, color = factor cluster, label = profile)) +
47 geom_text()
```

lv

Polina Lemenkova:

Deep-Sea Trenches of the Pacific Ocean: ...Data Modeling by GMT, Python and R
```r
# step-4. subscript every plot
p1<- PairM + ggtitle("MARIANA Plate; Trench Profiles 1:25; Trench Angles (tg(A/H)") + theme plot.title =
  element_text(size = 8), legend.title = element_text(size=8), legend.text = element_text(colour="black",
  size = 8), axis.title = element_text(size = 8))

p2<- PairPh + ggtitle("PHILIPPINE Plate; Trench Profiles 1:25; Trench Angles (tg(A/H)") + theme plot.title =
  element_text(size = 8), legend.title = element_text(size=8), legend.text = element_text(colour="black",
  size = 8), axis.title = element_text(size = 8))

p3<- PairPc + ggtitle("PACIFIC Plate; Trench Profiles 1:25; Trench Angles (tg(A/H)") + theme plot.title =
  element_text(size = 8), legend.title = element_text(size=8), legend.text = element_text(colour="black",
  size = 8), axis.title = element_text(size = 8))

p4<- PairC + ggtitle("CAROLINE Plate; Trench Profiles 1:25; Trench Angles (tg(A/H)") + theme plot.title =
  element_text(size = 8), legend.title = element_text(size=8), legend.text = element_text(colour="black",
  size = 8), axis.title = element_text(size = 8))

# step-5. place all 4 plots on one layout
Pair-figure <- plot_grid(p1, p2, p3, p4, labels = c("1", "2", "3", "4"), ncol = 2, nrow = 2)

# step-6. add common title, subtitle, lower subscript
PairwisePlates <- Pair-figure +
  labs (title = "Mariana Trench, Profiles Nr.1-25.",
  subtitle = "Pairwise Standard Scatter Plots of k-means Cluster Correlation",
  caption = "Clusters compared to the original variables \nStatistics Processing and Graphs: R Programming. Data
  Source: QGIS") +
  theme(
    plotmargin = margin(5, 10, 20, 5),
    plot.title = element_text (margin = margin(t = 0, r = 20, b = 5, l = 0), family = "Kai", face = "bold", size =
      12),
    plot.subtitle = element_text (margin = margin(t = 0, r = 20, b = 4, l = 0), family = "Hei", face = "bold", size
      = 10),
    plotcaption = element_text (face = 2, size = 6),
    panel_background = ggplot2::elementRect (fill = "white"),
    legend.justification = "bottom",
    legendDashPosition = "bottom",
    legend.box = "right",
    legend direction = "horizontal",
    legend.box = "horizontal",
    legend.boxbackground = elementRect (colour = "honeydew4", size=0.2),
    legendbackground = elementRect (fill = "white"),
    legend.keywidth = unit (.1, "cm"),
    legend.keyheight = unit (.5, "cm"),
    legend-spacing = unit (.2, "cm"),
    legend-spacing.y = unit (.1, "cm"),
    legend.text = element_text (colour="black", size=6, face=1),
    legend.title = element_text (colour="black", size=6, face=1))

PairwisePlates
```

codes/R-10.r
A.6.11 R code for 'lollipop' charts and diverging bars by (ggplot) library

Source data available on my GitHub.

1 # Part-1. Generate initial data frame
2 # step-1. read in table
3 MorDF <- read.csv("Morphology.csv", header=TRUE, sep = ",")
4 head(MorDF)
5 summary(MorDF)
6 # step-2. select two necessary columns from the initial table: numeric and symbol values. Generate from the
7 profile<- as.character(MorDF$profile)
8 tg_angle <- as.numeric(MorDF$tg_angle)
9 MDF<- data.frame/profile, tg_angle)
10 head(MDF)
11
12 # Part-2. change data frame MDF.
13 # step-3. Add new column for bathymetric profile names (here: by rows 1:25)
14 MDF$"profile name" <- rownames(MDF)
15 # step-4. re-calculate argument values (by axis X) normalized by the difference between mean and standard
16 MDF$norm_tg_angle <- round((MDF$tg_angle - mean(MDF$tg_angle))/sd(MDF$tg_angle), 2) # compute normalized tg-
17 # step-5. distribute values of the normalized argument on "above" and "below" mean
18 MDF$angle_type <- ifelse(MDF$norm_tg_angle < 0, "below", "above") # above / below avg flag
19 # step-6. sort data frame
20 MDF <- MDF[order(MDF$norm_tg_angle), ] # sort
21 # step-7. values by Y axis (here: profile names) convert onto factor
22 MDF$"profile name" <- factor(MDF$"profile name", levels = MDF$"profile name") # convert to factor to retain
23 class(MDF$profile name) # check up class
24 # [1] "factor" - should be
25 MDF # look up new data frame (5 columns vs initial 2 columns)
26
27 # Part-3. draw 2 plots by data frame MDF created in Part-2.
28 # step-8. Diverging Barcharts
29 Diverging_Bars<- ggplot(MDF, aes(x = MDF$"profile name", y = MDF$norm_tg_angle, label = MDF$norm_tg_angle)) +
30 geom_bar(stat='identity', aes(fill = MDF$angle_type), width=.5) +
31 xlab("Profiles, Nr.") +
32 ylab(expression(tg*degree*(A/H))) +
33 scale_fill_manual(name="(tg(A/H))",
34 labels = c("Above Average", "Below Average"),
35 values = c("above"="lawngreen", "below"="corall")) +
36 labs title=" Mariana Trench. Diverging Bars",
37 subtitle=expression(paste("Normalized steepness ", tg*degree*(A/H), " vs profiles 1:25"))) +
38 coord flip() +
39 theme(plot.title = element_text(size = 10),
40 legend.title = element_text(size=8), legend.text = element_text(colour="black", size = 8))
41 Diverging_Bars
42 # step-9. Plotting "Lollipop Chart"
43 Lollipop <- ggplot(MDF, aes(x = MDF$"profile name", y = MDF$norm_tg_angle, label = MDF$norm_tg_angle)) +
44 xlab("Profiles, Nr.") +
45 ylab(expression(tg*degree*(A/H))) +
46 geom_point(stat='identity', fill="black", size=6) +
47 geom_segment(aes(y = 0, x = MDF$"profile name", yend = MDF$norm_tg_angle, xend = MDF$"profile name"), color = "
48 black") +
49 labs title="Mariana Trench: Diverging Lollipop Chart",
50 subtitle=expression(paste("Normalized steepness ", tg*degree*(A/H), " vs profiles 1:25"))) +
51 ylim(-2.5, 2.5) +
52 coord flip() +
53 theme(plot.title = element_text(size = 10), legend.title = element_text(size=8), legend.text = element_text(
54 Lollipop
55 # step-10. place both pots on one layout
56 figure <-plot_grid(Diverging_Bars, Lollipop, labels = c("1", "2"), ncol = 2, nrow = 1)
57 # step-11. add common title, subtitle, subscript
58 LollipopBar <- figure +
59 labs title="Mariana Trench, Profiles Nr.1-25.",
60 subtitle = "Geomorphological Analysis: Normalised Steepness Angles",
61 caption = "Statistics Processing and Graphs: \nR Programming. Data Source: QGIS") +
62 theme(
63 plot-margin = margin(5, 10, 20, 5),
64 plot-title = element_text margint = margin(t = 0, r = 20, b = 5, 1 = 0), family = "Kai", face = "bold", size =
12),
65 plot.subtitle = element_text margin = margin(t = 0, r = 20, b = 4, 1 = 0), family = "Hei", face = "bold", size
= 10),
66 plot.caption = element_text face = 2, size = 6),
67 panel-background=ggplot2::elementRect (fill = "white"),
68 legend.justification = "bottom",
69 legendDash = "bottom",
70 legend.boxjust = "right",
71 legend direction = "horizontal",
72 legend.box = "horizontal",
73 legend.boxbackground = elementRect (colour = "honeydew4", size = 0.2),
74 legendbackground = elementRect (fill = "white"),
75 legend.keywidth = unit(1, "cm"),
76 legend.keyheight = unit (.5, "cm"),
77 legend-spacing.x = unit (.2, "cm"),
78 legend-spacing.y = unit (.1, "cm"),
79 legend.text = element_text (colour = "black", size = 6, face = 1),
80 legend.title = element_text (colour = "black", size = 6, face = 1))
81 LollipopBar

codes/R-11.r
A.6.12 R code for Dumbbell chart by (ggalt) and (ggplot2) libraries

Source data available on my GitHub.

1 # Part-1. Generate data frame
2 # step-1. read in table
3 MorDF <- read.csv("Morphology.csv", header=TRUE, sep = ",")
4 head(MorDF)
5 summary(MorDF)
6
7 # Part-2. Draw Dumbbell chart
8 theme_set theme_classic()
9 # step-2. set up factor value (here: numbers of the bathymetric profiles 1:25)
10 profile<- factor(MorDF$profile, levels=as.character(MorDF$profile)) # for right ordering of the dumbells
11 # step-3. compare distribution of the bathymetric observation points in a pair "Pacific vs Philippine plates"
12 PacPhil <- ggplot(MorDF, aes(x = plate_phill, xend = plate_pacif, y = profile, group = profile)) +
13 geom_dumbbell (color = "thistle4", size = 0.3, colour_xend = "deeppink", size_xend = 1.5, colour_x = "darkviolet",
14 size_x = 1.5, show.legend = T) +
15 labs(x = "Observation Points", y = "Profiles", title = "Dumbbell Chart 
16 subtitle = "Value Change: Observation Points; Philippine Plate vs Pacific Plate",
17 caption = "OUC, Qingdao2018. 
18 scale_x continuous (breaks = c (seq (0, 500, by = 100)), minor_breaks = c (seq (0, 500, by = 50))) +
19 scale_y continuous (breaks = c (seq (1, 25, by = 1))) +
20 theme (plot. title = element_text (margin = margin (t = 0, r = 20, b = 5, l = 0), family = "Kai", face = "bold",
21 size = 12),
22 plot. subtitle = element_text (margin = margin (t = 0, r = 20, b = 4, l = 0), family = "Hei", face = "bold", size
23 = 8),
24 plot. caption = element_text (margin = margin (t = 20, r = 10, b = 4, l = 0), family = "Kai", face = "bold", size
25 = 8),
26 plot. background = elementRect (fill = "white"),
27 axis. text.x = element_text (face = 3, color = "gray24", size = 6),
28 axis. text.y = element_text (face = 3, color = "gray24", size = 6),
29 axis. title.y = element_text (size = 8), axis. title.x = element_text (size = 8),
30 axis. ticks = elementBlanks, legend. position = "top",
31 panel. background = elementRect (fill = "grey95", colour = "grey95"),
32 panel. grid. major = element_line ("white", size = 0.4), panel. grid.minor = element_line ("white", size = 0.4,
33 linetype = "dotted"), panel. border = elementBlanks ()
34 PacPhil
35 # step-4. compare distribution of the bathymetric observation points in a pair "Mariana vs Caroline plates"
36 MarCar <- ggplot (MorDF, aes (x = plate_maria, xend = plate_carol, y = profile, group = profile)) +
37 geom_dumbbell (color = "thistle4", size = 0.3, colour_xend = "orange", size_xend = 1.5, colour_x = "navy", size_x
38 = 1.5, show.legend = T) +
39 labs (x = "Observation Points", y = "Profiles",
40 title = "Dumbbell Chart 
41 subtitle = "Value Change: Observation Points; Mariana Plate vs Caroline Plate",
42 caption = "OUC, Qingdao 2018. 
43 scale_x continuous (breaks = c (seq (0, 500, by = 100)), minor_breaks = c (seq (0, 500, by = 50))) +
44 scale_y continuous (breaks = c (seq (1, 25, by = 1))) +
45 theme (plot. title = element_text (margin = margin (t = 0, r = 20, b = 5, l = 0), family = "Kai", face = "bold",
46 size = 12),
47 plot. subtitle = element_text (margin = margin (t = 0, r = 20, b = 4, l = 0), family = "Hei", face = "bold", size
48 = 8),
49 plot. caption = element_text (margin = margin (t = 20, r = 10, b = 4, l = 0), family = "Kai", face = "bold", size
50 = 8),
51 plot. background = elementRect (fill = "white"),
52 axis. text.x = element_text (face = 3, color = "gray24", size = 6),
53 axis. text.y = element_text (face = 3, color = "gray24", size = 6),
54 axis. title.y = element_text (size = 8), axis. title.x = element_text (size = 8),
55 axis. ticks = elementBlanks, legend. position = "top",
56 panel. background = elementRect (fill = "grey95", colour = "grey95"),
57 panel. grid. major = element_line ("white", size = 0.4),
58 panel. grid.minor = element_line ("white", size = 0.4, linetype = "dotted"),
59 panel. border = elementBlanks ()
60 MarCar
61 # step-5. place both plots on one layout.
62 figure <- plot_grid (MarCar, PacPhil, labels = c("1", "2"), ncol = 2, nrow = 1)

codes/R-12.r

lix

Polina Lemenkova:

Deep-Sea Trenches of the Pacific Ocean: ...Data Modeling by GMT, Python and R
A.6.13 R code for categorywise bar charts

Source data available on my GitHub.

1 # Part-1. Prepare data frame
2 # step-1. read in table. create initial data frame
3 MDepths <- read.csv("DepthTect.csv", header=TRUE, sep = ",")
4 # step-2. clean up data frame from NA values
5 MDF <- na.omit(MDepths)
6 row.has.na <- apply(MDF, 1, function(x) {any(is.na(x))) # check up if there is any NA
7 sum(row.has.na) # sum up all NA, should be: [1] 0
8 head(MDF) # look up clean data frame
9 # step-3. merge table columns by 3 parameters, here: depths, tectonics, steepness angles. using melt library(
10 DFDT = melt(setDT(MDF), measure = patterns("^profile", "^tectonics", "^tg"), value.name = c("depths", "
11 DFDT
12
13 # Part 2: draw categorywise bar chart, with colors by categories
14 # step-4. draw diagram, add , legend, design
15 g <- ggplot(DFDT, aes (variable)) +
16 geom_bar(aes (fill = tectonics), width = 0.5, na.rm = TRUE) +
17 theme (axis.text.x = element_text (angle = 65, vjust = 0.6)) +
18 xlab("Profiles, Nr.") +
19 ylab("Observation Points") +
20 labs (title = "Mariana Trench, Profiles Nr.1-25.",
21 subtitle = "Categorywise Bar Chart. 
22 caption = "Statistics Processing and Graphs: R Programming. Data Source: QGIS") +
23 scale_fill_brewer ( palette = "RdBu") +
24 theme (
25 plot .margin = margin (5, 10, 20, 5),
26 plot .title = element_text (margin = margin (t = 0, r = 20, b = 5, 1 = 0), family = "Kai", face = "bold", size =
27 plot .subtitle = element_text (margin = margin (t = 0, r = 20, b = 4, 1 = 0), family = "Hei", face = "bold", size
28 plot .caption = element_text (face = 2, size = 6),
29 panel .background = ggplot2::elementRect (fill = "white"),
30 axis .title.y = element_text (size = 8),
31 axis .title.x = element_text (size = 8),
32 legend .justification = "bottom",
33 legend .position = "bottom",
34 legend .box.just = "right",
35 legend .direction = "horizontal",
36 legend .box = "horizontal",
37 legend .box .background = elementRect (colour = "honeydew4", size = 0.2),
38 legend .background = elementRect (fill = "white"),
39 legend .key .width = unit (.1, "cm"),
40 legend .key .height = unit (.5, "cm"),
41 legend .spacing .x = unit (.2, "cm"),
42 legend .spacing .y = unit (.1, "cm"),
43 legend .text = element_text (colour = "black", size = 6, face = 1),
44 legend .title = element_text (colour = "black", size = 6, face = 1))
45 g

codes/R-13.r