{"id":1435,"date":"2015-01-28T13:51:40","date_gmt":"2015-01-28T13:51:40","guid":{"rendered":"http:\/\/all-geo.org\/volcan01010\/?p=1435"},"modified":"2015-06-08T09:29:53","modified_gmt":"2015-06-08T08:29:53","slug":"easily-plot-magma-compositions-tas-diagrams-in-python","status":"publish","type":"post","link":"https:\/\/all-geo.org\/volcan01010\/2015\/01\/easily-plot-magma-compositions-tas-diagrams-in-python\/","title":{"rendered":"Easily plot magma compositions (TAS diagrams) in Python"},"content":{"rendered":"<p>I recently made a total alkali vs silica (TAS) plot to compare the magma of the Hekla 1947 eruption with the compositions of magmas from previous eruptions.\u00a0 This post contains the code to draw the plot, including a module that draws the different compositional regions for you.<\/p>\n<h3>\u00a0Total alkali vs silica plots<\/h3>\n<p>Volcanic rocks have a range of compositions, and consequently a range of properties.\u00a0 The most important measure is the proportion of silica (SiO<sub>2<\/sub>).\u00a0 Low-silica magmas such as basalt are more dense, have high melting points and form less-viscous (i.e. more runny) melts than high-silica magmas such as rhyolite.\u00a0 Eruptions of andesite magma or higher are more likely to explosive and pumice-forming as pressurised gases struggle to escape from the sticky magmas.\u00a0 Magmas that are rich in alkali metals (Na, K) are typically less-viscous and crystallise slightly different minerals to the lower-alkali compositions.<\/p>\n<p>TAS plots are a graphical representation of the silica and alkali contents of a magma.\u00a0 The regions on this TAS plot are named with familiar (and unfamiliar) magma types and were defined in a report by Le Maitre et al. (2002).\u00a0 The <a href=\"https:\/\/en.wikipedia.org\/wiki\/TAS_classification\" target=\"_blank\">TAS classification<\/a> page on Wikipedia has more information and links to their individual pages.<\/p>\n<div id=\"attachment_1436\" style=\"width: 610px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/all-geo.org\/volcan01010\/wp-content\/uploads\/2015\/01\/Tephrabase_Hekla1947.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-1436\" class=\"size-full wp-image-1436\" src=\"http:\/\/all-geo.org\/volcan01010\/wp-content\/uploads\/2015\/01\/Tephrabase_Hekla1947_600.png\" alt=\"Example total alkali versus silica plot with the different compositional fields marked.  The plot compares tephra from the Hekla 1947 eruption found in the UK (Hall and Pilcher, Swindles) with in Iceland (Larsen et al) and other eruptions from Hekla volcano. Click to enlarge.\" width=\"600\" height=\"438\" srcset=\"https:\/\/all-geo.org\/volcan01010\/wp-content\/uploads\/2015\/01\/Tephrabase_Hekla1947_600.png 600w, https:\/\/all-geo.org\/volcan01010\/wp-content\/uploads\/2015\/01\/Tephrabase_Hekla1947_600-300x219.png 300w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><p id=\"caption-attachment-1436\" class=\"wp-caption-text\">Example total alkali versus silica plot with the different compositional fields marked. The plot compares tephra from the Hekla 1947 eruption found in the UK (Hall and Pilcher 2002; Swindles 2006) with in Iceland (Larsen et al. 1999) and other eruptions from Hekla volcano. Click to enlarge.<\/p><\/div>\n<p>The plot shows that the <a href=\"https:\/\/en.wikipedia.org\/wiki\/Hekla#1947.E2.80.931948\" target=\"_blank\">Hekla 1947 eruption<\/a> was dacite-andesite in composition.\u00a0 As you might expect for this composition, it began explosively (showering southern Iceland with pumice and ash for a few hours) before going on to produce lava flows for over a year.\u00a0 The data were downloaded from <a href=\"http:\/\/www.tephrabase.org\/\" target=\"_blank\">Tephrabase<\/a> and <a href=\"http:\/\/www.earthchem.org\/portal\" target=\"_blank\">EarthChem<\/a> databases, respectively.<\/p>\n<h3>\u00a0tasplot.py<\/h3>\n<p>The following code was used to draw the TAS plot above.\u00a0 I wrote a module, called tasplot, with the code that draws and labels the fields via the <strong>add_LeMaitre_fields()<\/strong> function.\u00a0 All the other commands are typical for plotting with Python and Matplotlib.<\/p>\n<p>Follow the instructions on the BitBucket repository page at <a href=\"https:\/\/bitbucket.org\/jsteven5\/tasplot\" target=\"_blank\">https:\/\/bitbucket.org\/jsteven5\/tasplot<\/a> to install.\u00a0 You can browse the source code of tasplot.py directly by clicking <a href=\"https:\/\/bitbucket.org\/jsteven5\/tasplot\/src\/90ed07ec34fa13405e7d2d5c563341b3e5eef95f\/tasplot.py?at=master\">here<\/a>.<\/p>\n<pre class=\"brush: python; collapse: false; light: true; title: ; wrap-lines: false; notranslate\" title=\"\">\r\n# Import plotting modules\r\nimport matplotlib.pyplot as plt\r\nimport tasplot  # This imports the tasplot module\r\n\r\n# Set up figure\r\nfig = plt.figure()  # create figure\r\nax1 = plt.subplot(111)  # create axes and store as variable\r\ntasplot.add_LeMaitre_fields(ax1)  # add TAS fields to plot\r\n\r\n# Note that you can change the default colour and font size e.g.\r\n# &gt;&gt;&gt; tasplot.add_LeMaitre_Fields(ax1, color='red', fontsize=8)\r\n\r\n# Plot the data (from pre-existing variables)\r\nax1.plot(hallpilcher_silica, hallpilcher_alkali, 'o', alpha=1,\r\n         label='Hall and Pilcher (2002)')\r\nax1.plot(larsen_silica, larsen_alkali, 'o', alpha=1,\r\n         label='Larsen et al. (1999)')\r\nax1.plot(swindles_silica, swindles_alkali, 'o', alpha=1,\r\n         label='Swindles (2006)')\r\nax1.plot(earthchem_silica, earthchem_alkalis, 'o',\r\n         color=(0.8, 0.8, 0.8), alpha=0.5, mec='white',\r\n         label='EarthChem database', zorder=0)\r\n\r\n# Decorate the plot\r\nplt.xlabel(r'SiO$_2$ (wt%)')  # Use LaTeX notation for subscript\r\nplt.ylabel(r'Na$_2$O + K$_2$O (wt%)')\r\nplt.legend(loc='upper left', numpoints=1)\r\nplt.title('Tephrabase: Hekla 1947 samples')\r\nplt.savefig('Tephrabase_Hekla1947.png', dpi=150,\r\n            bbox_inches='tight')\r\n\r\n#\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I recently made a total alkali vs silica (TAS) plot to compare the magma of the Hekla 1947 eruption with the compositions of magmas from previous eruptions.\u00a0 This post contains the code to draw the plot, including a module that &hellip; <a href=\"https:\/\/all-geo.org\/volcan01010\/2015\/01\/easily-plot-magma-compositions-tas-diagrams-in-python\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1435","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/all-geo.org\/volcan01010\/wp-json\/wp\/v2\/posts\/1435","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/all-geo.org\/volcan01010\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/all-geo.org\/volcan01010\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/all-geo.org\/volcan01010\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/all-geo.org\/volcan01010\/wp-json\/wp\/v2\/comments?post=1435"}],"version-history":[{"count":12,"href":"https:\/\/all-geo.org\/volcan01010\/wp-json\/wp\/v2\/posts\/1435\/revisions"}],"predecessor-version":[{"id":1525,"href":"https:\/\/all-geo.org\/volcan01010\/wp-json\/wp\/v2\/posts\/1435\/revisions\/1525"}],"wp:attachment":[{"href":"https:\/\/all-geo.org\/volcan01010\/wp-json\/wp\/v2\/media?parent=1435"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/all-geo.org\/volcan01010\/wp-json\/wp\/v2\/categories?post=1435"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/all-geo.org\/volcan01010\/wp-json\/wp\/v2\/tags?post=1435"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}