{"id":936,"date":"2011-06-16T10:25:44","date_gmt":"2011-06-16T14:25:44","guid":{"rendered":"http:\/\/www.nomad.priv.at\/researchblog\/?p=936"},"modified":"2011-06-16T10:25:44","modified_gmt":"2011-06-16T14:25:44","slug":"fixed-unable-to-plot-a-decent-x-axis-in-a-time-series-plot-using-zoo","status":"publish","type":"post","link":"http:\/\/www.nomad.priv.at\/researchblog\/?p=936","title":{"rendered":"Fixed: Unable to plot a decent x-Axis in a time series plot using zoo"},"content":{"rendered":"<p>Here is the <a href=\"http:\/\/www.nomad.priv.at\/researchblog\/?p=502\">link<\/a> to the original problem. Briefly, I was unable to plot a custom x-axis showing abbreviated months in a time series plot of a zoo object.<\/p>\n<p>In the <code>plot.zoo()<\/code> function set <\/p>\n<pre class=\"brush: r; title: ; notranslate\" title=\"\">xaxt = &quot;n&quot;<\/pre>\n<p> to suppress plotting of the x-axis<\/p>\n<p>Since I needed abbreviated months to be plotted as the x-axis, I loaded a csv file with the dates of the first of each month as follows and converted it to dates:<\/p>\n<p>&#8220;month&#8221;<br \/>\n2004-12-01<br \/>\n2005-01-01<br \/>\n2005-02-01<br \/>\n&#8230;<\/p>\n<p>(I included Dec 2004, because otherwise &#8220;Jan&#8221; would not be plotted)<\/p>\n<pre class=\"brush: r; title: ; notranslate\" title=\"\">month &lt; - read.csv(&quot;~\/R\/2005months.csv&quot;)<\/pre>\n<pre class=\"brush: r; title: ; notranslate\" title=\"\">month$month &lt; - as.Date(month$month, &quot;%Y-%m-%d&quot;)<\/pre>\n<p>After the <code>plot.zoo<\/code> command I added the following line &#8211; <\/p>\n<pre class=\"brush: r; title: ; notranslate\" title=\"\">axis(1, month$month, format(month$month, &quot;%b&quot;))<\/pre>\n<p>The solution was inspired by a <a href=\"https:\/\/stat.ethz.ch\/pipermail\/r-help\/2006-June\/107953.html\">post from Gabor Grothendieck<\/a> on r-help. The original solution is still the only way to plot abbreviated months for time series plots of monthly averages.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here is the link to the original problem. Briefly, I was unable to plot a custom x-axis showing abbreviated months in a time series plot of a zoo object. In the plot.zoo() function set xaxt = &quot;n&quot; to suppress plotting of the x-axis Since I needed abbreviated months to be plotted as the x-axis, I &hellip; <a href=\"http:\/\/www.nomad.priv.at\/researchblog\/?p=936\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Fixed: Unable to plot a decent x-Axis in a time series plot using zoo<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6,4],"tags":[277,511,394],"class_list":["post-936","post","type-post","status-publish","format-standard","hentry","category-r","category-research","tag-plot","tag-r","tag-zoo"],"_links":{"self":[{"href":"http:\/\/www.nomad.priv.at\/researchblog\/index.php?rest_route=\/wp\/v2\/posts\/936","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.nomad.priv.at\/researchblog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.nomad.priv.at\/researchblog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.nomad.priv.at\/researchblog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.nomad.priv.at\/researchblog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=936"}],"version-history":[{"count":0,"href":"http:\/\/www.nomad.priv.at\/researchblog\/index.php?rest_route=\/wp\/v2\/posts\/936\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.nomad.priv.at\/researchblog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=936"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.nomad.priv.at\/researchblog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=936"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.nomad.priv.at\/researchblog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=936"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}