{"id":410,"date":"2014-01-01T22:13:10","date_gmt":"2014-01-02T03:13:10","guid":{"rendered":"http:\/\/homepages.uc.edu\/~yaozo\/wordpress\/?p=410"},"modified":"2014-01-01T22:13:10","modified_gmt":"2014-01-02T03:13:10","slug":"combining-superscripts-subscripts-and-other-symbols-in-axis-labels","status":"publish","type":"post","link":"https:\/\/zhuoyao.net\/index.php\/2014\/01\/01\/combining-superscripts-subscripts-and-other-symbols-in-axis-labels\/","title":{"rendered":"Combining superscripts, subscripts and other symbols in axis labels"},"content":{"rendered":"<p>Here was a tricky questions just sent to me:<\/p>\n<blockquote><p>I&#8217;m trying to get \u00a0\u03b444\/42Ca915a (\u2030) to look like\u00a0\u03b4<sup>44\/42<\/sup>Ca<sub>915a<\/sub>\u00a0(\u2030). I only need at this time to do the ylab. I tried using the code below from the blog.<\/p><\/blockquote>\n<blockquote><p>\nI have tried plotting it in<\/p><\/blockquote>\n<blockquote><p>boxplot(Ensisheim, ylim=c(-1.0,-0.4), col=&#8221;red&#8221;, ylab=expression(paste(delta^{<wbr><\/wbr>44\/42}, &#8220;Ca (\\u2030)&#8221;))<\/p><\/blockquote>\n<blockquote><p>and as just<\/p><\/blockquote>\n<blockquote><p>\u00a0plot(x, y, ylab=expression(paste(delta^{<wbr><\/wbr>44\/42},\u00a0&#8220;Ca (\u2030)&#8221;))).<\/p><\/blockquote>\n<h4>Solution<\/h4>\n<p>It took a bit of trial and error, but I was able to work a solution thanks to posts at stackoverflow (<a href=\"http:\/\/stackoverflow.com\/questions\/10628547\/use-superscripts-in-r-axis-labels\">here<\/a>\u00a0and\u00a0<a href=\"http:\/\/stackoverflow.com\/questions\/10156417\/subscripts-in-plots-in-r\">here<\/a>)<\/p>\n<div>x\u00a0&lt;- seq(1:10)<\/div>\n<div><\/div>\n<div>par(mar=c(5,6,5,5))<\/div>\n<div>boxplot(x,\u00a0ylab=expression(paste(delta^&#8221;44\/42&#8243;,\u00a0&#8220;Ca&#8221;\u00a0[&#8220;915a&#8221;],\u00a0&#8221; (\u2030)&#8221;)))<\/div>\n<div><\/div>\n<div>Remember you can substitute\u00a0\\u2030\u00a0for\u00a0\u2030.<\/div>\n<div><\/div>\n<div><a href=\"http:\/\/4.bp.blogspot.com\/-x6g6vEnl-yo\/UJlu0jjtfiI\/AAAAAAAAAF4\/8_M3FAhJLqo\/s1600\/calciumplotbig.png\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" src=\"http:\/\/4.bp.blogspot.com\/-x6g6vEnl-yo\/UJlu0jjtfiI\/AAAAAAAAAF4\/8_M3FAhJLqo\/s320\/calciumplotbig.png\" width=\"320\" height=\"269\" border=\"0\" \/><\/a><\/div>\n<div><\/div>\n<h4>\nWhat&#8217;s happening?<\/h4>\n<div><\/div>\n<div><\/div>\n<div>expression(paste(delta^&#8221;44\/42&#8243;,\u00a0&#8220;Ca&#8221;\u00a0[&#8220;915a&#8221;],\u00a0&#8221; (\u2030)&#8221;))<\/div>\n<div><\/div>\n<div>The superscript command\u00a0^\u00a0and subscript command\u00a0[]\u00a0don&#8217;t have to be followed by a comma, but if you want to call them as commands, rather the print them as characters, you have to take them out of the quotation marks, so we have\u00a0&#8220;Ca&#8221;\u00a0[&#8220;915a&#8221;]rather than\u00a0&#8220;Ca[915a]&#8221;.\u00a0If you want to join up multiple superscript\/subscript\/special character commands within the\u00a0expression(paste())\u00a0environment, after your superscript command is over, you need a comma before you can ask it to print\u00a0&#8220;Ca&#8221;, and similarly after your subscript command is over you need a comma before you can ask \u00a0it to print \u00a0&#8221; (\u2030)&#8221;.<\/div>\n<p>&nbsp;<\/p>\n<div><\/div>\n<div><\/div>\n<h4>A special note on margins<\/h4>\n<p>You noticed the code \u00a0par(mar=c(5,6,5,5))I called above before I plotted my figure. This asks R to make the lefthand margin larger than the others. When using superscripts on the y-axis, I&#8217;ve found the top edge of the superscript character can sometimes \u00a0get cut off when you save the pdf from R. Just in case, make extra room in the margins!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here was a tricky questions just sent to me: I&#8217;m trying to get \u00a0\u03b444\/42Ca915a (\u2030) to look like\u00a0\u03b444\/42Ca915a\u00a0(\u2030). I only need at this time to&hellip; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[20],"tags":[],"class_list":["post-410","post","type-post","status-publish","format-standard","hentry","category-r"],"_links":{"self":[{"href":"https:\/\/zhuoyao.net\/index.php\/wp-json\/wp\/v2\/posts\/410","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/zhuoyao.net\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/zhuoyao.net\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/zhuoyao.net\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/zhuoyao.net\/index.php\/wp-json\/wp\/v2\/comments?post=410"}],"version-history":[{"count":0,"href":"https:\/\/zhuoyao.net\/index.php\/wp-json\/wp\/v2\/posts\/410\/revisions"}],"wp:attachment":[{"href":"https:\/\/zhuoyao.net\/index.php\/wp-json\/wp\/v2\/media?parent=410"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/zhuoyao.net\/index.php\/wp-json\/wp\/v2\/categories?post=410"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/zhuoyao.net\/index.php\/wp-json\/wp\/v2\/tags?post=410"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}