<?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; matplotlibrc</title>
	<atom:link href="http://scienceoss.com/tags/matplotlibrc/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>Adjust settings for matplotlib using rc and matplotlibrc</title>
		<link>http://scienceoss.com/adjust-settings-for-matplotlib-using-rc-and-matplotlibrc/</link>
		<comments>http://scienceoss.com/adjust-settings-for-matplotlib-using-rc-and-matplotlibrc/#comments</comments>
		<pubDate>Tue, 22 Jan 2008 04:30:52 +0000</pubDate>
		<dc:creator>ryan</dc:creator>
				<category><![CDATA[matplotlib]]></category>
		<category><![CDATA[plotting]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[matplotlibrc]]></category>
		<category><![CDATA[pylab]]></category>
		<category><![CDATA[rc]]></category>
		<category><![CDATA[settings]]></category>

		<guid isPermaLink="false">http://scienceoss.com/?p=69</guid>
		<description><![CDATA[The matplotlibrc file contains many useful parameters for tweaking your setup to your liking, and it&#8217;s worth at least skimming through to get an idea of what it contains. Editing the file makes more permanent changes, while using the pylab rcParams dictionary or rc() and rcdefaults() functions lets you make and revert changes on the [...]]]></description>
			<content:encoded><![CDATA[<p>The matplotlibrc file contains many useful parameters for tweaking your setup to your liking, and it&#8217;s worth at least skimming through to get an idea of what it contains.  Editing the file makes more permanent changes, while using the pylab rcParams dictionary or rc() and rcdefaults() functions lets you make and revert changes on the fly.</p>
<p>View the rc parameters by using</p>
<pre class = "prettyprint"><code class = "code">import pylab as p
print p.rcParams</code></pre>
<p>Examples ensue.<br />
<span id="more-69"></span></p>
<h3>Where is matplotlibrc?</h3>
<p>On my machine (Ubuntu 7.10) it&#8217;s in <span class="c">/usr/lib/python2.5/site-packages/matplotlib/mpl-data/matplotlibrc</span>.  If I wanted to customize it, I could put a copy in ~/.matplotlib/matplotlibrc.  If you&#8217;re on Windows, you can put a copy in <span class="c">C:\Documents and Settings\yourname\.matplotlib</span></p>
<p>Editing this file makes changes that are in effect every time you use matplotlib.</p>
<p>To make temporary changes, use the <code>pylab.rc</code> function or set values in the <span class="c">rcParams</span> dictionary.  I&#8217;ll describe both ways below.</p>
<h3>An example</h3>
<p>For example, I want to make a series of plots for a manuscript.  The default font size is a little too small for these plots, and tweaking the font size for every one of the plots would be tedious.  Let&#8217;s see what my rc options are.</p>
<pre class = "prettyprint"><code class = "code">
import pylab as p
p.rcParams
</code></pre>
<p>Among a large number of options, I see some that will be of use:</p>
<pre class = "prettyprint"><code class = "code">...
...
'axes.labelsize': 12.0,
...
'xtick.labelsize': 12.0,
...
'ytick.labelsize': 12,0,
...
</code></pre>
<h3>Two ways to change settings</h3>
<p>It&#8217;s personal preference which one you use.  Either way, you only have to do this once.  From then on, all plots will use these new parameters, until you reset the parameters using <span class="c">rcdefaults()</span></p>
<p>Using rcParams, I could set the properties like this:</p>
<pre class = "prettyprint"><code class = "code">
rcParams['axes.labelsize'] = 16.0
p.rcParams['xtick.labelsize'] = 16.0
p.rcParams['ytick.labelsize'] = 16.0</code></pre>
<p>Alternatively, I could use rc:</p>
<pre class = "prettyprint"><code class = "code">
p.rc(('xtick','ytick','axes'), labelsize=16.0)
</code></pre>
<h3>Now, plot!</h3>
<pre class = "prettyprint"><code class = "code">
p.plot([1,2,3])
p.xlabel('x axis')
p.ylabel('y axis')
p.show()
</code></pre>
<p>Here&#8217;s the new figure.  Any other figure I make will have the same text size.<br />
<img src='http://blog.anonrandomname.com/wp-content/uploads/2008/01/image1.png' alt='Increased text size using rc params' /></p>
<p>Until, that is, I reset to the defaults:</p>
<pre class = "prettyprint"><code class = "code">p.rcdefaults()</code></pre>
<p>The result is this:<br />
<img src='http://blog.anonrandomname.com/wp-content/uploads/2008/01/image2.png' alt='reset to the default params' /></p>
]]></content:encoded>
			<wfw:commentRss>http://scienceoss.com/adjust-settings-for-matplotlib-using-rc-and-matplotlibrc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

