<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>scienceoss.com &#187; ggplot</title>
	<atom:link href="http://scienceoss.com/tags/ggplot/feed/" rel="self" type="application/rss+xml" />
	<link>http://scienceoss.com</link>
	<description>useful tidbits for using open source software in science</description>
	<lastBuildDate>Wed, 26 May 2010 03:34:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Reorder factors for ggplot</title>
		<link>http://scienceoss.com/reorder-factors-for-ggplot/</link>
		<comments>http://scienceoss.com/reorder-factors-for-ggplot/#comments</comments>
		<pubDate>Sun, 23 Mar 2008 21:35:45 +0000</pubDate>
		<dc:creator>ryan</dc:creator>
				<category><![CDATA[ggplot2]]></category>
		<category><![CDATA[R]]></category>
		<category><![CDATA[facet grid]]></category>
		<category><![CDATA[factors]]></category>
		<category><![CDATA[ggplot]]></category>
		<category><![CDATA[reorder]]></category>

		<guid isPermaLink="false">http://scienceoss.com/reorder-factors-for-ggplot/</guid>
		<description><![CDATA[A somewhat contrived example . . . first, illustrate the problem: library(ggplot2) ggplot(iris)+aes(x=Sepal.Width)+geom_histogram()+facet_grid(Species~.) How do we get these histograms to be better sorted? The following will reorder the factor variable, Species, by the mean of Sepal.Width: iris$Species = reorder(iris$Species, iris$Sepal.Width, mean) ggplot(iris)+aes(x=Sepal.Width)+geom_histogram()+facet_grid(Species~.) Now the histograms are sorted by the mean sepal width.]]></description>
			<content:encoded><![CDATA[<p>A somewhat contrived example . . . first, illustrate the problem:</p>
<pre class="prettyprint"><code class="code">library(ggplot2)
ggplot(iris)+aes(x=Sepal.Width)+geom_histogram()+facet_grid(Species~.)</code></pre>
<p><a href='http://scienceoss.com/wp-content/uploads/2008/03/hist-unsorted.png' title='Unsorted histogram'><img src='http://scienceoss.com/wp-content/uploads/2008/03/hist-unsorted.png' alt='Unsorted histogram' /></a><br />
How do we get these histograms to be better sorted?  The following will reorder the factor variable, <span class="c">Species</span>, by the mean of <span class="c">Sepal.Width</span>:</p>
<pre class="prettyprint"><code class="code">iris$Species = reorder(iris$Species, iris$Sepal.Width, mean)
ggplot(iris)+aes(x=Sepal.Width)+geom_histogram()+facet_grid(Species~.)</code></pre>
<p><a href='http://scienceoss.com/wp-content/uploads/2008/03/hist-sorted.png' title='Sorted histogram'><img src='http://scienceoss.com/wp-content/uploads/2008/03/hist-sorted.png' alt='Sorted histogram' /></a><br />
Now the histograms are sorted by the mean sepal width.</p>
]]></content:encoded>
			<wfw:commentRss>http://scienceoss.com/reorder-factors-for-ggplot/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Change properties of ggplot plots</title>
		<link>http://scienceoss.com/change-properties-of-ggplot-plots/</link>
		<comments>http://scienceoss.com/change-properties-of-ggplot-plots/#comments</comments>
		<pubDate>Mon, 04 Feb 2008 16:28:54 +0000</pubDate>
		<dc:creator>ryan</dc:creator>
				<category><![CDATA[plotting]]></category>
		<category><![CDATA[R]]></category>
		<category><![CDATA[ggplot]]></category>
		<category><![CDATA[grayscale]]></category>
		<category><![CDATA[parameters]]></category>

		<guid isPermaLink="false">http://scienceoss.com/change-properties-of-ggplot-plots/</guid>
		<description><![CDATA[Try ?ggopt to see the different ways of adjusting plot background, axes, aspect ratio, border colors, and strip labels. Change the font size of the labels. This acts on the currently active plot. grid.gedit('label', gp=gpar(fontsize=16)) Or just change one type of label (here, the yaxis). grid.gedit(gPath("yaxis", "labels"), gp=gpar(col="red")) Use a black and white theme The [...]]]></description>
			<content:encoded><![CDATA[<p>Try </p>
<pre class="prettyprint"><code class="code">?ggopt</code></pre>
<p>to see the different ways of adjusting plot background, axes, aspect ratio, border colors, and strip labels.</p>
<h3>Change the font size of the labels.</h3>
<p>This acts on the currently active plot.</p>
<pre class="prettyprint"><code class="code">grid.gedit('label', gp=gpar(fontsize=16))</code></pre>
<p>Or just change one type of label (here, the yaxis).</p>
<pre class="prettyprint"><code class="code">grid.gedit(gPath("yaxis", "labels"), gp=gpar(col="red"))</code></pre>
<h3>Use a black and white theme</h3>
<p>The newest version of ggplot2 (0.5.7) allows you to have black and white themes.</p>
<pre class="prettyprint"><code class="code">pl = ggplot(diamonds)+aes(x=carat, y=price) +
    geom_point()+theme_bw
pl
</code></pre>
<p>I like to tweak the <span class="c">theme_bw</span> a little before using it as above:</p>
<pre class="prettyprint"><code class="code">theme_bw$grid.colour = "grey80"
theme_bw$border.colour = "gray70"</code></pre>
<h3>Change the strip labels</h3>
<pre class="prettyprint"><code class="code">pl$strip.gp = gpar(fill="grey90")
pl$strip.txt.gp = gpar(col="black", fontsize=16)
pl</code></pre>
<h3>Change factor colors to grayscale</h3>
<pre class="prettyprint"><code class="code">pl+scale_colour_grey(end=0.7,start=0,name='')
pl</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://scienceoss.com/change-properties-of-ggplot-plots/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

