tag:blogger.com,1999:blog-91511444623446545552024-03-05T08:24:59.066-08:00Scientific figure designSallyhttp://www.blogger.com/profile/00391077265779122872noreply@blogger.comBlogger20125tag:blogger.com,1999:blog-9151144462344654555.post-4552875816329430412014-09-18T12:22:00.003-07:002014-09-18T12:26:52.099-07:00Points of View from Nature MethodsVia the <a href="http://depts.washington.edu/deshelp/">UW Design Help Desk</a> I discovered the <a href="http://blogs.nature.com/methagora/2013/07/data-visualization-points-of-view.html">Points of View</a> column at <i>Nature Methods</i>. While Points of View has been discontinued, there's a lot of great content in the 35 columns that were published, <a href="http://blogs.nature.com/methagora/2013/07/data-visualization-points-of-view.html">which are compiled here</a>. Spend a few minutes poking around and read about using color effectively, improving figure clarity, exploring data, and more.Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-9151144462344654555.post-51087282757564240212013-12-05T16:54:00.001-08:002013-12-05T16:54:40.509-08:00Figure width<div dir="ltr" style="text-align: left;" trbidi="on">
I had a breakthrough with a figure today. I had made a plot that I really didn't like, and I just couldn't figure out the way to make it better. The answer ended up being that I needed to make the figure <i>narrower</i>.<br />
<br />
Tufte talks about data angles and says that data looks best when the majority of the data falls on roughly a 45 degree angle. Obviously, there are many exceptions to this rule, but in my case today, it really helped my figure.<br />
<br />
Here is an early version of this figure. The goal is to see how a number of properties at four different locations vary throughout an annual cycle. Some of the cycles can be seen, but overall no clear message from the figure stands out.<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhH6Dyv-GcwY3cn16gxIbuvbaHWlURA5ld1sNjdnguqdPgN_kkwGeV9opsj1y_jacayhC8RYXy6XGCjBW31SRaZoZt73Hcocy2sXG2-COIJ490sfl0svJ4PtdPoyhGfr6dJNncBACvrVhhG/s1600/annual_cycles_good_v23.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="640" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhH6Dyv-GcwY3cn16gxIbuvbaHWlURA5ld1sNjdnguqdPgN_kkwGeV9opsj1y_jacayhC8RYXy6XGCjBW31SRaZoZt73Hcocy2sXG2-COIJ490sfl0svJ4PtdPoyhGfr6dJNncBACvrVhhG/s640/annual_cycles_good_v23.png" width="468" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Early, wide version of the figure</td></tr>
</tbody></table>
<br />
<br />
Here is the updated version of the figure.<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEic-AREmsVpUiUrh-qsH4C5E2yEaypCC4ft8cmyBv90pU7Rv0STFKtpl-BKKuTxzXuG4nP_T9gii3GRCih3c7-EyIXHchQGhFUEba3RzsuOJeOD1tnC5JY_ZMQ8nTkt7ZX94bq0ghyphenhyphenbg1MF/s1600/annual_cycles_all_times.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="640" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEic-AREmsVpUiUrh-qsH4C5E2yEaypCC4ft8cmyBv90pU7Rv0STFKtpl-BKKuTxzXuG4nP_T9gii3GRCih3c7-EyIXHchQGhFUEba3RzsuOJeOD1tnC5JY_ZMQ8nTkt7ZX94bq0ghyphenhyphenbg1MF/s640/annual_cycles_all_times.png" width="274" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Revised, narrow version of the figure. (The height is the same as the older version.)</td></tr>
</tbody></table>
<br />It is much easier to see how the annual cycles change at the four locations with the narrower figure. Considering, that I only have 12 data points along the x-axis for each variable and position, I did not need such a wide figure. Now, my slopes are also steeper which makes the variability of the annual cycles more obvious. (A lot more data is falling at 45 degree angles like Tufte suggests.)<div>
<br /></div>
<div>
I made a few other changes too. I care most about the data from 23W and 140W, and I care least about the data from 170W. Therefore, I plotted the least important data in a light gray and the most important data in bold red and black. It's now much easier to differentiate the annual cycles at each position.</div>
<div>
<br /></div>
<div>
If I were to publish this figure, I might remove the gridlines. Are they too much chart clutter? They were, however, helpful today though when I was comparing my results to older published results of similar variables. (A quick note on gridlines: I much prefer my very light gray solid grid lines compared to the matlab default of black dots.)</div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<div>
<br /><br /></div>
</div>
</div>
Sallyhttp://www.blogger.com/profile/00391077265779122872noreply@blogger.com0tag:blogger.com,1999:blog-9151144462344654555.post-17732160226502435902013-11-11T11:31:00.001-08:002013-11-11T11:35:00.869-08:00Hold On!<div dir="ltr" style="text-align: left;" trbidi="on">
There's a weird bug in MATLAB with the function HOLD ON. I'm sure we've all used HOLD ON when making figure — it needs to be used in order to plot multiple lines. However, WHERE the HOLD ON command is used makes a big different in the appearance of plots.<br />
<br />
For instance, if I were to write the commands:<br />
<br />
<div style="text-align: left;">
<span style="font-family: Courier New, Courier, monospace;">% define some function</span></div>
<div style="text-align: left;">
<span style="font-family: Courier New, Courier, monospace;">x = 0:0.1:2*pi;</span></div>
<div style="text-align: left;">
<span style="font-family: Courier New, Courier, monospace;">y1 = sin(x);</span></div>
<div style="text-align: left;">
<span style="font-family: Courier New, Courier, monospace;">y2 = cos(x);</span></div>
<div style="text-align: left;">
<span style="font-family: Courier New, Courier, monospace;"><br /></span></div>
<div style="text-align: left;">
<span style="font-family: Courier New, Courier, monospace;">% plot the functions</span></div>
<div style="text-align: left;">
<span style="font-family: Courier New, Courier, monospace;">figure</span></div>
<div style="text-align: left;">
<span style="font-family: Courier New, Courier, monospace;"><br /></span></div>
<div style="text-align: left;">
<span style="font-family: Courier New, Courier, monospace;">% subplot 1: plot the first function BEFORE using HOLD ON</span></div>
<div style="text-align: left;">
<span style="font-family: Courier New, Courier, monospace;">subplot(211)</span></div>
<div style="text-align: left;">
<span style="font-family: Courier New, Courier, monospace;">plot(x,y1,'linewidth',2)</span></div>
<div style="text-align: left;">
<span style="font-family: Courier New, Courier, monospace;">hold on</span></div>
<div style="text-align: left;">
<span style="font-family: Courier New, Courier, monospace;">plot(x,y2,'r','linewidth',2)</span></div>
<div style="text-align: left;">
<span style="font-family: Courier New, Courier, monospace;"><br /></span></div>
<div style="text-align: left;">
<span style="font-family: Courier New, Courier, monospace;">% subplot 2: plot the first function AFTER using HOLD ON</span></div>
<div style="text-align: left;">
<span style="font-family: Courier New, Courier, monospace;">subplot(212)</span></div>
<div style="text-align: left;">
<span style="font-family: Courier New, Courier, monospace;">hold on</span></div>
<div style="text-align: left;">
<span style="font-family: Courier New, Courier, monospace;">plot(x,y1,'linewidth',2)</span></div>
<div style="text-align: left;">
<span style="font-family: Courier New, Courier, monospace;">plot(x,y2,'r','linewidth',2)</span></div>
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Times, Times New Roman, serif;">The following figure results:</span><br />
<span style="font-family: Times, Times New Roman, serif;"><br /></span>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhjNclXEl2j2-p4kH0W9NpqcPCTnMp4nP9BL60HkCaOXCyagR-i5Rn7CFbGIrlL8iov9RaIPSR6yJmIL7V8Di8nx8c0e_NKXV7LGdbBHfEvYB4Z6xMrMtRfTKME3Ru3-xmS17jST-6JY_7N/s1600/hold_on_example1.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="311" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhjNclXEl2j2-p4kH0W9NpqcPCTnMp4nP9BL60HkCaOXCyagR-i5Rn7CFbGIrlL8iov9RaIPSR6yJmIL7V8Di8nx8c0e_NKXV7LGdbBHfEvYB4Z6xMrMtRfTKME3Ru3-xmS17jST-6JY_7N/s400/hold_on_example1.png" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><br /></td></tr>
</tbody></table>
<span style="font-family: Times, Times New Roman, serif;"><br /></span>
<span style="font-family: Times, Times New Roman, serif;">There is a border around the plot on all four sides in the top subplot, whereas there is only a border on the bottom and left in the bottom subplot. This difference is due ONLY to the position of the HOLD ON command. </span><br />
<span style="font-family: Times, Times New Roman, serif;"><br /></span>
<span style="font-family: Times, Times New Roman, serif;">When HOLD ON comes AFTER the first function is plotted, an entire border is plotted. Whereas, when HOLD ON comes BEFORE the first function is plotted, the border is only on the left and bottom.</span><br />
<br />
<br />
<span style="font-family: Times, Times New Roman, serif;">The position of HOLD ON not only changes the plot borders, but it can change how the data is plotted, such as with SEMILOGY:</span><br />
<span style="font-family: Times, Times New Roman, serif;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;">% define a random function that will vary over a large range</span><br />
<span style="font-family: Courier New, Courier, monospace;">x = 1:100;</span><br />
<span style="font-family: Courier New, Courier, monospace;">y = 2.^(rand(100,1)*100);</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;">figure</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;">% plot SEMILOGY before HOLD ON is used</span><br />
<span style="font-family: Courier New, Courier, monospace;">subplot(211)</span><br />
<span style="font-family: Courier New, Courier, monospace;">semilogy(x,y,'linewidth',2)</span><br />
<span style="font-family: Courier New, Courier, monospace;">hold on</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;">% plot SEMILOGY after HOLD ON is used</span><br />
<span style="font-family: Courier New, Courier, monospace;">subplot(212)</span><br />
<span style="font-family: Courier New, Courier, monospace;">hold on</span><br />
<span style="font-family: Courier New, Courier, monospace;">semilogy(x,y,'linewidth',2)</span><br />
<span style="font-family: Times, Times New Roman, serif;"><br /></span>
<span style="font-family: Times, Times New Roman, serif;">The following figure results:</span><br />
<span style="font-family: Times, Times New Roman, serif;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiRdxKzd4ykI053rd8DfcAQKr59K54AVdZ6rio3wNifQ6H-CTejJODPLLnDHNMr720Dw4shT28ZiWIFp7rXLnnu07v_um5Gh0q4LSRmu1hJGt9uMoXWwmfW6EgOHaaQGFZTPjg1zffyjbho/s1600/hold_on_example2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="310" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiRdxKzd4ykI053rd8DfcAQKr59K54AVdZ6rio3wNifQ6H-CTejJODPLLnDHNMr720Dw4shT28ZiWIFp7rXLnnu07v_um5Gh0q4LSRmu1hJGt9uMoXWwmfW6EgOHaaQGFZTPjg1zffyjbho/s400/hold_on_example2.png" width="400" /></a></div>
<span style="font-family: Times, Times New Roman, serif;"><br /></span>
<span style="font-family: Times, Times New Roman, serif;"><br /></span>
<span style="font-family: Times, Times New Roman, serif;">In this case, not only is there the same difference with the subplot borders, but when HOLD ON is used BEFORE SEMILOGY, MATLAB just uses a regular plot command rather than SEMILOGY as seen in the second subplot. HOLD ON must not be used before SEMILOGY for SEMILOGY to plot correctly. </span><br />
<span style="font-family: Times, Times New Roman, serif;"><br /></span>
<span style="font-family: Times, Times New Roman, serif;"><br /></span>
<span style="font-family: Times, Times New Roman, serif;">I was confused by this bug for quite a while, not understanding why sometimes I would get an entire border around my figures and sometimes I wouldn't. Once I figured out that it was the placement of the HOLD ON command that changed the border, I actually started strategically placing HOLD ON to avoid having to use the BOX ON and BOX OFF commands to turn the top and right borders on and off. </span><br />
<span style="font-family: Times, Times New Roman, serif;"><br /></span>
<span style="font-family: Times, Times New Roman, serif;">It was today that I realized that the placement of HOLD ON also is what prevents SEMILOGY from working correctly! Knowing this bug will prevent many headaches in the future.</span><br />
<span style="font-family: Times, Times New Roman, serif;"><br /></span></div>
Sallyhttp://www.blogger.com/profile/00391077265779122872noreply@blogger.com1tag:blogger.com,1999:blog-9151144462344654555.post-84954316672684158712013-09-27T16:13:00.000-07:002013-09-27T16:13:30.334-07:00Fake colorbar<div dir="ltr" style="text-align: left;" trbidi="on">
Often I want to plot two (or many) datasets that have the same time vector. I simply use the SUBPLOT command in MATLAB to do so. A problem arises, however, when one of these datasets happens to be three-dimensional — something that I want to plot with pcolor. When I add a colorbar to that subplot, the time-axis (x-axis) no longer lines up with the other subplots.<div>
<br /></div>
<div>
<br /><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi9_HeaYzT1ipEt4cOz_zKZBmQjbQPStgPZ_Y3W7Ihqdu3aCMB9yENmsalJsnppwpMe393NaTvAnGv45acs4F0qNlzJlPqRj1rMxmu9Skwp-BoBY-PzGnATxtr_7SxK8GDvqSbNAQhh6wje/s1600/bad_time_axes.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi9_HeaYzT1ipEt4cOz_zKZBmQjbQPStgPZ_Y3W7Ihqdu3aCMB9yENmsalJsnppwpMe393NaTvAnGv45acs4F0qNlzJlPqRj1rMxmu9Skwp-BoBY-PzGnATxtr_7SxK8GDvqSbNAQhh6wje/s1600/bad_time_axes.png" height="478" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">BAD: The time-axes for (a) and (b) have different scales because of the colorbar in (b).</td></tr>
</tbody></table>
<div>
<br /></div>
<br /><div>
To fix this problem, I wrote a simple function called <a href="http://www.mathworks.com/matlabcentral/fileexchange/43660">FAKECOLORBAR</a> which changes the size of the subplot that does not require a colorbar so it matches the subplot with the colorbar.</div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhe7jRW3QffJNiRJkyOMEByMFLwRlzuCiFxKNC8j7pjiBPQKEUu7df8W2eFvdqC1LxpKs9DBOqgePr6FNTxUhH7V1ohWcngp6JmUDIYSeMuc-KP3lRS8B9nreD16juSZzf3Q5CLwylOlAfI/s1600/good_time_axes.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhe7jRW3QffJNiRJkyOMEByMFLwRlzuCiFxKNC8j7pjiBPQKEUu7df8W2eFvdqC1LxpKs9DBOqgePr6FNTxUhH7V1ohWcngp6JmUDIYSeMuc-KP3lRS8B9nreD16juSZzf3Q5CLwylOlAfI/s1600/good_time_axes.png" height="474" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">GOOD: The time-axes for (a) and (b) now align because I used FAKECOLORBAR on (a)</td></tr>
</tbody></table>
<div>
<br /></div>
<div>
<br /></div>
<div>
Now, if someone could just tell me how to fix the phi in the title of (b) so that it is not partially cutoff...</div>
</div>
<div>
<br /></div>
<div>
Oh, and these data will in a jagged and blocky way unless I subtract 2000 years from the time vector, which is why the x-axis label in (b) says "January 7" instead of "January 2007." I'm sure others have run into this problem before. Another problem for another day.</div>
<div>
<br /></div>
<div>
<br /></div>
</div>
Sallyhttp://www.blogger.com/profile/00391077265779122872noreply@blogger.com1tag:blogger.com,1999:blog-9151144462344654555.post-44618667010691880012013-08-09T15:04:00.001-07:002013-08-09T15:04:53.737-07:00Undocking figures<div dir="ltr" style="text-align: left;" trbidi="on">
My coworker, Cheryl, was so excited today when she realized that by undocking her matlab figures she can now save them the way she wants to. See the link on the matlab forum: <a href="http://www.mathworks.com/matlabcentral/newsreader/view_thread/245320" style="background-color: white; color: #1155cc; font-family: arial, sans-serif; font-size: 12.727272033691406px;" target="_blank">http://www.mathworks.com/<wbr></wbr>matlabcentral/newsreader/view_<wbr></wbr>thread/245320</a>. Sometimes it's these little things that are so unintuitive to fix that can make figure creation more difficult than it needs to be.<br />
<br />
I've been out of the country for the past 8 months and away from matlab (and a computer). Now I've returned to work and hope to have many new and exciting thoughts about figure design.<br />
<br />
<br /></div>
Sallyhttp://www.blogger.com/profile/00391077265779122872noreply@blogger.com0tag:blogger.com,1999:blog-9151144462344654555.post-77981109551069713012012-10-05T08:35:00.004-07:002012-10-05T08:35:56.931-07:00Junk ChartsI was typing in a web address in my browser, and one of the auto-complete suggestions was for <a href="http://www.junkcharts.typepad.com/">Junk Charts</a>, a blog about bad figures found in the wild. I had visited it a while back but forgotten about it. Check it out for some particularly egregious examples of chart junk.Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-9151144462344654555.post-2928600774558859222012-09-11T13:58:00.001-07:002012-09-11T13:58:50.521-07:00FakeColorBack on May 17, I posted a method that my officemates Nick and Noel use to plot multiple colormaps in one figure. Andy Pickering has taken their idea and written a function called '<a href="http://students.washington.edu/sally2/FakeColor.m">FakeColor</a>.' Really useful for making multiple contour plots with different colormaps.<br />
<br />
Thanks Andy!Sallyhttp://www.blogger.com/profile/00391077265779122872noreply@blogger.com0tag:blogger.com,1999:blog-9151144462344654555.post-77362910918645680572012-09-04T02:22:00.002-07:002012-09-04T02:22:25.481-07:00Visual StrategiesCheck out <a href="http://www.nytimes.com/2012/09/04/science/visual-strategies-transforms-data-into-art-that-speaks.html">this brief review</a> of a new book on scientific figure design, <i>Visual Strategies</i>, in The New York Times. Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-9151144462344654555.post-86650145626386311652012-05-17T16:22:00.002-07:002012-05-17T16:22:55.886-07:00multiple colormaps in matlabHow do I use multiple colormaps in a single matlab figure? This is probably one of the biggest frustrations that almost all matlab users have to deal with. I would argue that this shortcoming of matlab --- combined with the default jet colormap --- have led to an entire generation of ugly scientific figures.<br />
<br />
I used to use freezeColors and cbfreeze to make plots and colorbars with different colormaps. However, now that I use export_fig regularly, these do not work. (The incompatibility has to do with different renderers. Export_fig uses the painters renderer (aka. "the good renderer") but freezeColors does not allow the painters renderer to be used.)<br />
<br />
My (super awesome) officemates, Nick and Noel, have come up with a solution for this problem. They use the fact that contourf essentially plots separate patch objects for each level of the colormap. They extract the coordinates from contourf and then manually plot each layer as a patch object with a specified color. This way, they avoid using a colormap entirely when they plot the figure. Sounds more complicated than it is. Here's an example of some code that Nick wrote. (Hopefully, this will be turned into a function soon, but for now, you can use this as inspiration.)<br />
<br />
<br />
<div style="font-family: "Courier New",Courier,monospace;">
<span style="font-size: x-small;">cvec=-.5:.5:10.5;<br />%make a "colormap"</span></div>
<div class="im" style="font-family: "Courier New",Courier,monospace;">
<span style="font-size: x-small;">tcmap=flipud(cbrewer('div', 'RdYlBu',length(cvec),'linear'</span><wbr></wbr><span style="font-size: x-small;">));<br /></span></div>
<span style="font-size: x-small;"><span style="font-family: "Courier New",Courier,monospace;">%contourf it</span></span><div class="im" style="font-family: "Courier New",Courier,monospace;">
<span style="font-size: x-small;">[con conhand]=contourf(rgrid/1000,</span><wbr></wbr><span style="font-size: x-small;">grdDepths(stind:end),TEMP_W_</span><span style="font-size: x-small;">MASK,cvec,'linecolor','none');</span><wbr></wbr><span style="font-size: x-small;">hold on</span></div>
<span style="font-size: x-small;"><span style="font-family: "Courier New",Courier,monospace;">
</span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;">%get the patch object handles:</span></span><div class="im" style="font-family: "Courier New",Courier,monospace;">
<span style="font-size: x-small;">p=get(conhand,'children');</span></div>
<div class="im" style="font-family: "Courier New",Courier,monospace;">
<span style="font-size: x-small;">thechild=get(p,'CData'); </span></div>
<div class="im" style="font-family: "Courier New",Courier,monospace;">
<span style="font-size: x-small;">cdat=cell2mat(thechild);<br /></span></div>
<span style="font-size: x-small;"><span style="font-family: "Courier New",Courier,monospace;">%loop through and manually set facecolor of each patch to the colormap you made:</span></span><div class="im" style="font-family: "Courier New",Courier,monospace;">
<span style="font-size: x-small;">
for i=1:length(cvec)<br /> set(p(cdat==cvec(i)),'</span><wbr></wbr><span style="font-size: x-small;">Facecolor',tcmap(i,:)) </span></div>
<div class="im" style="font-family: "Courier New",Courier,monospace;">
<span style="font-size: x-small;">end<br /></span></div>
<span style="font-size: x-small;"><span style="font-family: "Courier New",Courier,monospace;">%%%%%%%%%%</span><span style="font-family: "Courier New",Courier,monospace;"></span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;">%now you need to make a fake colorbar using the same trick:</span><span style="font-family: "Courier New",Courier,monospace;"> </span></span><br />
<span style="font-size: x-small;"><span style="font-family: "Courier New",Courier,monospace;">%define the colorbar axes location just above the subplot you are working with:</span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;">
lbwh=get(gca,'Position');</span><span style="font-family: "Courier New",Courier,monospace;"> </span></span><br />
<span style="font-size: x-small;"><span style="font-family: "Courier New",Courier,monospace;">Tcb=axes('Position',[lbwh(1) (lbwh(2)+lbwh(4)+.005) lbwh(3) .04]);</span><br style="font-family: "Courier New",Courier,monospace;" /><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;">%contourf your fake colorbar:</span><span style="font-family: "Courier New",Courier,monospace;"> </span></span><br />
<span style="font-size: x-small;"><span style="font-family: "Courier New",Courier,monospace;">[con conhand]=contourf(cvec',[0 1],[cvec; cvec],cvec,'linecolor','none')</span></span>;<br />
<div id=":1ty" style="font-family: "Courier New",Courier,monospace;">
<span style="font-size: x-small;"></span><div class="im">
<span style="font-size: x-small;">p=get(conhand,'children');</span></div>
<div class="im">
<span style="font-size: x-small;">thechild=get(p,'CData'); </span></div>
<div class="im">
<span style="font-size: x-small;">cdat=cell2mat(thechild);<br /></span></div>
<span style="font-size: x-small;">% AGAIN, loop through and manually set facecolor of each patch to the colormap you made (this makes a horizontal colorbar):</span><div class="im">
<span style="font-size: x-small;">for i=1:length(cvec)<br /> set(p(cdat==cvec(i)),'</span><wbr></wbr><span style="font-size: x-small;">Facecolor',tcmap(i,:)) </span></div>
<div class="im">
<span style="font-size: x-small;">end</span></div>
<span style="font-size: x-small;">%set the colorbar axes to whatever you want</span></div>
<div id=":1ty" style="font-family: "Courier New",Courier,monospace;">
<span style="font-size: x-small;">set(gca,'yticklabel',[],'</span><wbr></wbr><span style="font-size: x-small;">xaxislocation','top','xtick',[</span><wbr></wbr><span style="font-size: x-small;">0:3:9])</span></div>
<div id=":1ty" style="font-family: "Courier New",Courier,monospace;">
<span style="font-size: x-small;"> </span></div>
<div id=":1ty" style="font-family: "Courier New",Courier,monospace;">
<span style="font-size: x-small;"> </span></div>
<div id=":1ty" style="font-family: "Courier New",Courier,monospace;">
<span style="font-size: x-small;"><span style="font-size: small;"><span style="font-family: inherit;">I used a variation of this code to make some figures and it worked great. Here's an example:</span></span></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiCLrEghMSeqgKkkxkAFUnQ3LTnHh1f-otmoEpMFO2GZ0FpSocM5Bns1Rlj2efo3avD_fmSzJwHO59_defLJ4qnp0km1XwDPY6nXZWA6vJrnksTMeorgcbKR1e7ju8pXEwqWWr61EppZ_L5/s1600/pbot_vort_t244.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="158" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiCLrEghMSeqgKkkxkAFUnQ3LTnHh1f-otmoEpMFO2GZ0FpSocM5Bns1Rlj2efo3avD_fmSzJwHO59_defLJ4qnp0km1XwDPY6nXZWA6vJrnksTMeorgcbKR1e7ju8pXEwqWWr61EppZ_L5/s640/pbot_vort_t244.png" width="640" /></a></div>
<div id=":1ty" style="font-family: "Courier New",Courier,monospace;">
<span style="font-size: x-small;"><span style="font-size: small;"><span style="font-family: inherit;"> </span></span> </span></div>Sallyhttp://www.blogger.com/profile/00391077265779122872noreply@blogger.com2tag:blogger.com,1999:blog-9151144462344654555.post-19762870463782730282012-05-14T12:14:00.003-07:002012-05-14T12:23:20.931-07:00Vaughn's presentation on Dynamic FiguresThanks so much to Vaughn who gave a super informative presentation about dynamic figures! I'm really looking forward to learning some of the tools that he told us about. Click <a href="http://students.washington.edu/sally2/vaughn_dynamic_figures.svg" target="_blank">here</a> to see his presentation, which was made using the same tools one would use to make a dynamic figure. It should just display in your browser and use arrow keys to go from one "slide" to the next.<br />
<br />
His main message was to use the following tools:<br />
- JSON for data management<br />
- svg<br />
- coffeescript<br />
- Lots of frameworks such as d3.jsSallyhttp://www.blogger.com/profile/00391077265779122872noreply@blogger.com0tag:blogger.com,1999:blog-9151144462344654555.post-7886077672115274482012-05-09T11:59:00.000-07:002012-05-09T11:59:09.050-07:00Figure club meeting on 10 May: Interactive FiguresJoin us on Thursday, 10 May 2012 for our next figure club meeting. Vaughn Iverson will be talking about making interactive figures on the web and elsewhere. This should be a great session, so don't miss it. <br />
<br />
4:30 PM, OSB 410 (note different room). <br />
<br />
There will be a faculty candidate seminar immediately prior to our meeting (in a different room) and we'll wait to start until after that seminar is over. Some come to both events!<br />
<br />
<br />Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-9151144462344654555.post-86247313249198233322012-05-05T20:58:00.000-07:002012-05-05T20:58:15.164-07:00When you have a few minutes, be sure to check out <a href="http://chartsnthings.tumblr.com/">chartsnthings</a>, a fascinating blog that documents the creative process of producing New York Times charts and infographics. A typical post starts with a hand-drawn sketch of the initial idea and goes through the iterations leading to the final product that makes it into the print edition or online.Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-9151144462344654555.post-41642146013937644232012-05-02T20:03:00.001-07:002012-05-02T20:03:05.127-07:00Meeting on Thursday, May 3Hi everyone,<br />
<br />
The figure club will meet on Thursday, May 3 at 4:30pm (immediately following the faculty candidate talk) in OSB 425. <br />
<br />
We'll be doing figure critiques. Bring figures that you want to improve.
For instance, if you can't decide what colormap to use, print out the
figure with multiple colormaps and we can help you pick the best one. If
you don't have figures that need critiquing, feel free to come anyway
and to give others advice. Don't be intimidated --- the critiques are
friendly!<br />
<br />
Also, if anyone has "before" and "after" versions of figures they have made, I'd love to post them on this blog! Email them to me.<br />
<br />
The following meeting will be on Thursday, May 10 at 4:30. The topic will be poster design.<br />
<br />
See you tomorrow!Sallyhttp://www.blogger.com/profile/00391077265779122872noreply@blogger.com0tag:blogger.com,1999:blog-9151144462344654555.post-36484157269818758672012-04-25T20:34:00.003-07:002013-10-08T10:10:55.537-07:00MATLAB tricks<div dir="ltr" style="text-align: left;" trbidi="on">
The figure club met today to discuss tricks we use in MATLAB. Here's what we talked about.<br />
<br />
(I hope that this discussion can remain ongoing into the future, so if you have MATLAB frustrations, ask your question as a comment here and hopefully someone will have a solution.)<br />
<br />
<b>Saving with export_fig</b><br />
<a href="http://www.mathworks.com/matlabcentral/fileexchange/23629-exportfig" style="font-family: "Courier New",Courier,monospace;" target="_blank">export_fig</a><b> </b>is a great way to save plots. Way better than "save" or "print" because it is a lot smarter. Personally, I like that it crops my figure. More info on the matlab central file exchange website.<br />
<br />
<b>Dropbox</b><br />
Using dropbox to make matlab code the same on both a home and work computer. (Dan can you elaborate more on this?)<br />
<br />
<b>Edit Plot tip</b><br />
Don't use Edit Plot tool in matlab. It does some funky things so you're way better off to write the code that will plot the figure in its final version.<br />
<br />
<b>File types</b><br />
For vector graphics, save your figures as <b>pdf</b> or <b>eps</b>. For raster graphics, use <b>png</b> or <b>tiff</b>. Do not use jpeg because it compresses the file in a way that's only appropriate for photos and that will make the text in your figure very pixelated. I personally use pdf whenever possible because it preserves the text as text so it can be changed in a program like Illustrator. pdfs are also very robust, in other words, they will appear the same on any computer.<br />
<br />
<b>Labeling a colorbar:</b><br />
<div style="font-family: "Courier New",Courier,monospace;">
h=colorbar;</div>
<span style="font-family: "Courier New",Courier,monospace;">ylabel(h,'waterdepth, m')</span><br />
<br />
<b>Multiple colormaps:</b><br />
<a href="http://www.mathworks.com/matlabcentral/fileexchange/7943-freezecolors-unfreezecolors" style="font-family: "Courier New",Courier,monospace;" target="_blank">freezeColors</a> and <a href="http://www.mathworks.com/matlabcentral/fileexchange/24371-colormap-and-colorbar-utilities-sep-2009" style="font-family: "Courier New",Courier,monospace;" target="_blank">cbfreeze</a> are very useful tools from the file exchange. <b> </b>freezeColors will allow you to have multiple colormaps on one plot and cbfreeze allows multiple colorbars. Use the following syntax:<br />
<div style="font-family: "Courier New",Courier,monospace;">
figure</div>
<div style="font-family: "Courier New",Courier,monospace;">
subplot(121)</div>
<div style="font-family: "Courier New",Courier,monospace;">
imagesc(bathy.lon,bathy.lat,bathy.z)<br />
axis xy</div>
<div style="font-family: "Courier New",Courier,monospace;">
set(gca,'dataaspectratio',[1 cos(48*pi/180) 1]) </div>
<div style="font-family: "Courier New",Courier,monospace;">
colorbar</div>
<div style="font-family: "Courier New",Courier,monospace;">
freezeColors</div>
<div style="font-family: "Courier New",Courier,monospace;">
cbfreeze</div>
<div style="font-family: "Courier New",Courier,monospace;">
subplot(122)</div>
<div style="font-family: "Courier New",Courier,monospace;">
imagesc(bathy.lon,bathy.lat,bathy.z) </div>
<div style="font-family: "Courier New",Courier,monospace;">
axis xy</div>
<div style="font-family: "Courier New",Courier,monospace;">
set(gca,'dataaspectratio',[1 cos(48*pi/180) 1]) </div>
<div style="font-family: "Courier New",Courier,monospace;">
colorbar</div>
<div style="font-family: "Courier New",Courier,monospace;">
colormap('gray')</div>
<div style="font-family: "Courier New",Courier,monospace;">
set(gcf,'color','w')</div>
<span style="font-family: "Courier New",Courier,monospace;">export_fig test.pdf</span><br />
<br />
The end result is a figure that has two different colormaps!<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjwicwKvVIKvi9jKErzxW7CxqQIZNVCGWbV2OZqN87dF9JXfwIIcGsGblCtG1WzeBX_L1IE-iw7yf0adgraH71EIMVYQLFUHMJTLBSNFO9rfaQLc0idn84B0oxrAGQikvvR-zhY7CsP7j7l/s1600/120425_freezecolors_test.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="238" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjwicwKvVIKvi9jKErzxW7CxqQIZNVCGWbV2OZqN87dF9JXfwIIcGsGblCtG1WzeBX_L1IE-iw7yf0adgraH71EIMVYQLFUHMJTLBSNFO9rfaQLc0idn84B0oxrAGQikvvR-zhY7CsP7j7l/s400/120425_freezecolors_test.png" width="400" /></a></div>
<br />
<b>Instead of pcolor: imsc</b><br />
Dan really likes <a href="http://www.mathworks.com/matlabcentral/fileexchange/16233-sc-powerful-image-rendering" target="_blank"><span style="font-family: "Courier New",Courier,monospace;">imsc</span></a> to plot rather than pcolor or imagesc. Dan can you give more feedback as to why this function is great? Pcolor has the disadvantage that when you try to save it as a vector graphic it comes back with really weird white lines. Not only that, it cuts off a row and column of data. As of now, if you want to use pcolor, you have to save it as a tiff or png to make it appear without the bad rendering.<br />
<br />
<b>Default figure settings</b><br />
You can change the default figure settings by changing the startup file. If you haven't created one already, make a file called startup.m and put it in your matlab folder. This will be executed every time matlab opens. I have defined three things in my startup file: (1) I want the figure command to put a figure window in the upper right hand corner of my screen rather than right in the center, (2) I want the default figure background color to be white, and (3) I want the default font size to be 14 pts.<br />
<br />
Here's my <span style="font-family: "Courier New",Courier,monospace;">startup.m</span> file:<br />
<span style="font-family: "Courier New",Courier,monospace;">% set the default figure position to be in the upper right</span><br />
<span style="font-family: "Courier New",Courier,monospace;">set(0,'defaultFigurePosition',[1353 661 560 420])</span><br />
<span style="font-family: "Courier New",Courier,monospace;">% set the default figure color to be white</span><br />
<span style="font-family: "Courier New",Courier,monospace;">set(0,'defaultFigureColor',[1 1 1])</span><br />
<span style="font-family: "Courier New",Courier,monospace;">% set the default font size to be 14<br />set(0,'defaultaxesfontsize',14);<br />set(0,'defaulttextfontsize',14);</span><br />
Other things you may want to set here are the figure orientation (<span style="font-family: "Courier New",Courier,monospace;">set(0,'orient','landscape')</span>), or the default line or text color.<br />
<br />
You can see what your default settings are:<br />
<span style="font-family: "Courier New",Courier,monospace;">get(0,'default') </span><br />
<br />
<b>Structures</b><br />
If you don't already use them, structures can be a great way to organize your data. Instead of different variable names for everything, save things as structures. For instance, if I always have structures called <span style="font-family: "Courier New",Courier,monospace;">ctd</span> and <span style="font-family: "Courier New",Courier,monospace;">adcp</span> and then within those structures I'll save the variables such as <span style="font-family: "Courier New",Courier,monospace;">ctd.z, ctd.temp, ctd.salt, adcp.u, adcp.v, adcp.w</span>, etc.<br />
<br />
I always like to include a readme file in each structure (if it is data from an instrument). For instance, <span style="font-family: "Courier New",Courier,monospace;">ctd.readme</span> would tell me what all of the variables are and what their units are. I like to create readme files using the <span style="font-family: "Courier New",Courier,monospace;">strvcat</span> command:<br />
<span style="font-family: "Courier New",Courier,monospace;">ctd.readme = strvcat(...</span><br />
<span style="font-family: "Courier New",Courier,monospace;"> 'CTD data from October 2010 cruise at TTP',...</span><br />
<span style="font-family: "Courier New",Courier,monospace;"> 'salt = salinity [psu]',...</span><br />
<span style="font-family: "Courier New",Courier,monospace;"> 'temp = temperature [deg C]');</span><br />
<br />
One of the biggest advantages to a structure is that you can easily save all of the data by just saying:<br />
<span style="font-family: "Courier New",Courier,monospace;">save data.mat ctd </span><br />
<br />
However, if you don't want to save the variables that are in a structure as a structure, you can append the command:<br />
<span style="font-family: "Courier New",Courier,monospace;">save data.mat -struct ctd z temp salt</span><br />
<br />
Sometimes you may need to run through a loop that will plot a lot of data that is all saved in a structure. Let's say you have data from many different moorings called <span style="font-family: "Courier New",Courier,monospace;">moor1</span>, <span style="font-family: "Courier New",Courier,monospace;">moor2</span>, <span style="font-family: "Courier New",Courier,monospace;">moor3</span>, etc. and within each structure there are variables (<span style="font-family: "Courier New",Courier,monospace;">moor1.temp, moor1.salt, moor1.time</span>, etc). You can plot these using the eval function within a loop:<br />
<br />
<div style="font-family: "Courier New",Courier,monospace;">
for i = 1:10</div>
<div style="font-family: "Courier New",Courier,monospace;">
figure</div>
<div style="font-family: "Courier New",Courier,monospace;">
eval(['plot(moor' num2str(i) '.time,moor' num2str(i) '.salt)'])</div>
<span style="font-family: "Courier New",Courier,monospace;">end</span><br />
<br />
Dan pointed out that you could also have a giant structure, where each mooring is an element within the structure moor. Then you could plot just by:<br />
<br />
<div style="font-family: "Courier New",Courier,monospace;">
for i = 1:10</div>
<div style="font-family: "Courier New",Courier,monospace;">
figure</div>
<div style="font-family: "Courier New",Courier,monospace;">
plot(moor(1).time,moor(1).salt)</div>
<div style="font-family: "Courier New",Courier,monospace;">
end</div>
<br />
<b>nicecolor</b><br />
<a href="http://faculty.washington.edu/banasn/" target="_blank">Neil Banas</a> gave me <a href="http://people.oregonstate.edu/~warnersa/nicecolor.m"><span style="font-family: "Courier New",Courier,monospace;">nicecolor.m</span></a> ages ago and I use it all the time. Nicecolor allows you to specify colors by using the matlab abbreviations for colors (r=red, b=blue, etc) instead of specify the rgb vector. It takes an average of all of the colors you specify. So for instance, dark yellow could be <span style="font-family: "Courier New",Courier,monospace;">'yk'</span> and orange could be <span style="font-family: "Courier New",Courier,monospace;">'ryy'</span>. Use as many letters as you want until you get the color that you want. syntax:<br />
<span style="font-family: "Courier New",Courier,monospace;">plot(x,y,'color',nicecolor('yk'))</span><br />
<br />
<b>ginput</b><br />
This is a built-in matlab command that is very useful for grabbing x and y data from a plot by eye. It can be used as simply as:<br />
<b> </b><span style="font-family: "Courier New",Courier,monospace;">ginput</span><br />
or you can be more specific to get multiple variables:<br />
<span style="font-family: "Courier New",Courier,monospace;">[x,y] = ginput</span><br />
<br />
<b>gtext</b><br />
If you don't know where you will want to place text in a figure, you can use <span style="font-family: "Courier New",Courier,monospace;">gtext</span>. <b> </b><br />
<br />
<b>input</b><br />
If you want your code to ask you before doing something, the input command can be very useful. For instance you can say:<br />
<div style="font-family: "Courier New",Courier,monospace;">
year = input('What year would you like to plot? ')</div>
<br />
sometimes I use it so that I don't mistakenly overwrite data:<br />
<div style="font-family: "Courier New",Courier,monospace;">
disp('Did you really want to overwrite that .mat file?')</div>
<div style="font-family: "Courier New",Courier,monospace;">
yn = input('Say ''yes'' or ''no'' ');</div>
<div style="font-family: "Courier New",Courier,monospace;">
if strcmp(yn,'yes') == 1</div>
<div style="font-family: "Courier New",Courier,monospace;">
save data.mat</div>
<div style="font-family: "Courier New",Courier,monospace;">
else</div>
<div style="font-family: "Courier New",Courier,monospace;">
break</div>
<span style="font-family: "Courier New",Courier,monospace;">end</span><br />
<br />
<b>better subplots</b><br />
Matlab often leaves excessive space between subplots. There are two ways to deal with this. The first is easier and the second gives you more control.<br />
<br />
<span style="font-family: "Courier New",Courier,monospace;">packrows</span>, <span style="font-family: "Courier New",Courier,monospace;">packcols</span>, and <span style="font-family: "Courier New",Courier,monospace;">packboth</span> allow you to tighten up your subplots after you have already plotted them. I use this when I'm just quickly plotting data. This comes from Jonathan Lilly's plotting toolbox (<a href="http://www.jmlilly.net/jmlsoft.html" target="_blank">JLAB</a>), which contains many other useful commands besides this one. syntax:<br />
<span style="font-family: "Courier New",Courier,monospace;">packrows(2,1) </span><br />
<br />
<a href="http://www.mathworks.com/matlabcentral/fileexchange/27991-tight-subplot" target="_blank"><span style="font-family: "Courier New",Courier,monospace;">tight_subplot</span></a> comes from the matlab file exchange and allows you to specify exactly what you want.<br />
<div style="font-family: "Courier New",Courier,monospace;">
ax = tight_subplot(3,2,0.01)</div>
<div style="font-family: "Courier New",Courier,monospace;">
axes(ax(1))</div>
<div style="font-family: "Courier New",Courier,monospace;">
plot(...</div>
<div style="font-family: "Courier New",Courier,monospace;">
axes(ax(2))</div>
<span style="font-family: "Courier New",Courier,monospace;">plot(... </span><br />
<br />
<b>Good books</b><br />
T<span style="font-size: small;">he book Modeling Methods for Marine Science</span><span style="font-size: small;"><span class="med reg"> by David M. Glover, William J. Jenkins and Scott C. Doney</span> details many statistical methods. The added benefit of this book is that they tie these methods directly to the matlab code that one would use to implement the statistical analysis. This book takes a simpler approach than Emery and Thomson's Data Analysis Methods in Physical Oceanography (which I also recommend.) </span><br />
<br />
<br />
<b>Questions that still remain:</b><br />
<ol>
<li>Better alternative to plotyy and/or easier way to deal with datetick and plotyy. (Is there an easier way to do this than to specify two axes handles and using the datetick command twice?)</li>
<li>Getting a time axes to align when some subplots need a colorbar and others don't. (I always just plot colorbars that I don't need and delete them or I specify the axes limits manually.)</li>
<li>Saving a discrete colorbar (one with only a few color levels.) It's easy to plot this in matlab, but the save always screws up the colorbar and makes it continuous, even with export_fig.</li>
</ol>
</div>
Sallyhttp://www.blogger.com/profile/00391077265779122872noreply@blogger.com4tag:blogger.com,1999:blog-9151144462344654555.post-33597512657692170852012-04-23T14:13:00.000-07:002012-04-23T14:13:33.832-07:00next meeting: MATLAB TRICKSThe next meeting of the figure design club will be on Wednesday, April 25 from 4-5pm. Sorry for the change of time! It's due to the visiting faculty candidates and the oceanography honors convocation that both take place this Thursday.<br />
<br />
In preparation for that meeting, we want to know if you have any MATLAB frustrations. Are you stumped at figuring out how to make your plots look the way you want them to look? Post your questions here as a comment to this post and hopefully someone will have a cool trick to solve your problem when we meet on Wednesday.Sallyhttp://www.blogger.com/profile/00391077265779122872noreply@blogger.com0tag:blogger.com,1999:blog-9151144462344654555.post-71060418915345898742012-04-19T14:39:00.004-07:002012-04-19T14:47:18.587-07:00Some useful Matlab colormapsWe talked about several alternative colormaps at figure club last week. Here are links to a few of them on the Matlab File Exchange.<br /><br /><a href="http://www.mathworks.com/matlabcentral/fileexchange/17555-light-bartlein-color-maps">lbmap.m</a> -- four Matlab colormaps from the Light & Bartlein Eos article that <a href="http://figuredesign.blogspot.com/2012/04/meeting-recap-colors-in-figures.html">Sally wrote about</a>. These colormaps are useful for communicating color to people with colorblindess (and those without, too!).<br /><br /><a href="http://www.mathworks.com/matlabcentral/fileexchange/25690-haxby-color-map">haxby.m</a> -- a Matlab colormap to implement the Haxby scheme, often used on bathymetric charts.<br /><br /><a href="http://www.mathworks.com/matlabcentral/fileexchange/34087">cbrewer</a> -- tools to implement colormaps from colorbrewer.org (more info in <a href="http://figuredesign.blogspot.com/2012/04/meeting-recap-colors-in-figures.html">Sally's post</a>).<br /><br /><a href="http://soliton.vm.bytemark.co.uk/pub/cpt-city/index.html">cpt-city</a> -- Nick sent us this awesome site with tons of ideas for alternative colormaps and color schemes.<br /><br />Do you have any great color resources? Leave a comment!Unknownnoreply@blogger.com2tag:blogger.com,1999:blog-9151144462344654555.post-32396368726010682632012-04-18T17:08:00.001-07:002012-04-30T12:23:39.149-07:00Meeting recap: colors in figuresOn Thursday, April 12, the figure club met to talk about colors in figures. The topics we covered were: (1) when to use color, or the importance of gray, (2) colors for line plots, (3) colormaps for contour/pcolor plots, and (4) colorblindness and photocopying.<br />
<br />
<h2>
(1) When to use color, or the importance of gray</h2>
<br />
Here are two examples of figures I made that were originally in color, but I converted them to black and white because my advisor wouldn't let me have any color figures in the paper. (I'm using my own figures because I don't have before and after versions of ones made by other people. If you have an example, I'd love to post it too!)<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi7l_Hrxibu16GGws5BYb3NEGlqPf_xt4oUpqdG94YWVj9L4cure3vyI6fYrEu-hUGK_mbpwO4Y9_70-FCLqeFKc03Eb4DmJT3SNV4QQLn5D6Alc-3Z4hyphenhyphenYY_o4uGxFziMo3AgPke5tA1yS/s1600/color+and+bw+line+plot.tiff" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="412" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi7l_Hrxibu16GGws5BYb3NEGlqPf_xt4oUpqdG94YWVj9L4cure3vyI6fYrEu-hUGK_mbpwO4Y9_70-FCLqeFKc03Eb4DmJT3SNV4QQLn5D6Alc-3Z4hyphenhyphenYY_o4uGxFziMo3AgPke5tA1yS/s640/color+and+bw+line+plot.tiff" width="640" /></a></div>
Obviously, in this case, more than just the colors were changed. I think it's actually easier to see the three different line in black, gray and black dashed than in blue, green and red.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEggRVDH20KB_VUZglolOscdMO9eZE4j73VHbRBz1XfymeUVShyphenhyphenBWmS-OiBNsft89drUrhIWYPVEKQaYIsz25kzk55yMZh8BQUECkEqyD0d4ZqG9MRR_zs8lWQquD79EyuByS0q-YOYJc7JJ/s1600/080930_ssh_vel_vort_run120_forpaper_t7to12.tiff" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEggRVDH20KB_VUZglolOscdMO9eZE4j73VHbRBz1XfymeUVShyphenhyphenBWmS-OiBNsft89drUrhIWYPVEKQaYIsz25kzk55yMZh8BQUECkEqyD0d4ZqG9MRR_zs8lWQquD79EyuByS0q-YOYJc7JJ/s400/080930_ssh_vel_vort_run120_forpaper_t7to12.tiff" width="400" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi73wdtu45VH00wq9fXb9Xj7vFlbo26YTE145eUpWirSihmA-uw-mUOmRRrNGGzVKrKOvDCCX7Mw8RR9AHHlFS_5RooaXwfK8S9jL7dMXvqG7PPdkpsMD5GEUEBqqO57RwQPrtiH-T5c48x/s1600/081020_ssh_vel_vort_run120_forpaper_t7to12.tiff" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi73wdtu45VH00wq9fXb9Xj7vFlbo26YTE145eUpWirSihmA-uw-mUOmRRrNGGzVKrKOvDCCX7Mw8RR9AHHlFS_5RooaXwfK8S9jL7dMXvqG7PPdkpsMD5GEUEBqqO57RwQPrtiH-T5c48x/s400/081020_ssh_vel_vort_run120_forpaper_t7to12.tiff" width="400" /></a></div>
In this case, the black and white vorticity contours are still visible on top of the gray sea surface height contours because the grays are chosen in the middle of the spectrum.<br />
<br />
Often it's nice to use color in order to add more excitement to a figure for a presentation or poster, but when you're limited with color for print material, there are often options in black, white and gray. You may be surprised, sometimes the black and white figures look better!<br />
<br />
<br />
<h2>
(2) Colors for line plots</h2>
How many times have you been listening to a talk and the speaker has apologized that you can't see the lines in their plot? Using cyan, light green and yellow is often disastrous. Similarly, using red and magenta or dark blue and black means that the audience can't see the difference between lines.<br />
<br />
The default colors in MATLAB are often not good choices in a presentation because it is too hard to see some of the colors and some of them are too similar as seen below:<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiKYpxQSk5g1zedcekf3cXO2MnAGGvyiKDhf2qhpDv45kr45pFz35U-OSHvJjUQ75jeTyVqKPW81poVUYzLr2137-bfkxMSOT9sbZ85pLxBa11gGMT6cQX5Ie67nZ-bCJZ_Vdn4ohxf9Y6_/s1600/Standard_Line_Colors_01.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="300" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiKYpxQSk5g1zedcekf3cXO2MnAGGvyiKDhf2qhpDv45kr45pFz35U-OSHvJjUQ75jeTyVqKPW81poVUYzLr2137-bfkxMSOT9sbZ85pLxBa11gGMT6cQX5Ie67nZ-bCJZ_Vdn4ohxf9Y6_/s400/Standard_Line_Colors_01.png" width="400" /></a></div>
This really only leaves blue and red or red and black as options for colors that will show up against each other. <br />
<br />
Here an example where there are just too many colors to be able to see the difference between the lines:<br />
<span id="goog_389653231"></span><span id="goog_389653232"></span><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjHjceZ8RkaSNTFaeeqKPGzfTGSMLveCh7JdRhUw2p_tI0mpkYWafJmoGRdGkcQtcqJrQ1IhphF2B6mGrx18kHFN7kgpDWM6A_OGkwDeuEXudOkluw88_7Jip1qBMAyr4pnGpCtqws-7dps/s1600/too+many+lines.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="338" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjHjceZ8RkaSNTFaeeqKPGzfTGSMLveCh7JdRhUw2p_tI0mpkYWafJmoGRdGkcQtcqJrQ1IhphF2B6mGrx18kHFN7kgpDWM6A_OGkwDeuEXudOkluw88_7Jip1qBMAyr4pnGpCtqws-7dps/s400/too+many+lines.png" width="400" /> </a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
One of the things that can help in a line plot to make the colors more visible is simply to makes the lines thicker. Also, it helps to change the MATLAB default colors so they are darker and more distinguished from each other. </div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjikmZjqgbYslYntMCGWttNV6YT3jgPoUZYjF9p0Nq7AOmIUYybRf7hQ_cmjOrOENH1ujo2AirJBXkyqMmsKTW3jEaq3JISd0pl7lJuH9-MMg1ZBYXUtXAuT6DBWBTFnPWSif_7WvCLr2dp/s1600/line+plot+colors+sine.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="311" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjikmZjqgbYslYntMCGWttNV6YT3jgPoUZYjF9p0Nq7AOmIUYybRf7hQ_cmjOrOENH1ujo2AirJBXkyqMmsKTW3jEaq3JISd0pl7lJuH9-MMg1ZBYXUtXAuT6DBWBTFnPWSif_7WvCLr2dp/s400/line+plot+colors+sine.png" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
Here, the colors have the following RGB values:</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
1. darkred = [127.5 0 0];</div>
<div class="separator" style="clear: both; text-align: left;">
2. red = [237 28 36];</div>
<div class="separator" style="clear: both; text-align: left;">
3. orange = [241 140 34];</div>
<div class="separator" style="clear: both; text-align: left;">
4. yellow = [255 222 23]; </div>
<div class="separator" style="clear: both; text-align: left;">
5. lightgreen = [173 209 54];</div>
<div class="separator" style="clear: both; text-align: left;">
6. darkgreen = [8 135 67];</div>
<div class="separator" style="clear: both; text-align: left;">
7. lightblue = [71 195 211];</div>
<div class="separator" style="clear: both; text-align: left;">
8. darkblue = [33 64 154];</div>
<div class="separator" style="clear: both; text-align: left;">
9. purple = [150 100 155];</div>
<div class="separator" style="clear: both; text-align: left;">
10. pink = [238 132 181];</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
(Note that these need to be divided by 255 before using them in MATLAB.) The yellow is probably still not good to use because it's too light and a few people in the meeting complained that they couldn't see the difference between red and dark red. Experiment when you're making your own plots. Often good combinations can be found.</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
One really cool idea suggests picking colors that vary both the hue and the saturation across the color wheel. (Unfortunately, I lost this link.)</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjozyZ8UWjinsVZot-h-BFkTllQBejZONUbPdFqPZs5yJTJ0s030NTAi4JX2_WTL6VVeQLEAU_MDg3ywdbxoJxnRY_VApNNXla7_hv90LzI-ns0K6NJ6hdq8JGpbtP0J5PquoFuyFpv7IcT/s1600/nmeth0810-573-F2.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="476" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjozyZ8UWjinsVZot-h-BFkTllQBejZONUbPdFqPZs5yJTJ0s030NTAi4JX2_WTL6VVeQLEAU_MDg3ywdbxoJxnRY_VApNNXla7_hv90LzI-ns0K6NJ6hdq8JGpbtP0J5PquoFuyFpv7IcT/s640/nmeth0810-573-F2.jpg" width="640" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
Furthermore, if you're a real color nerd, there are numerous sites where people share their color schemes that they think go well together. These can be an interesting places to find color combos:</div>
<div class="separator" style="clear: both; text-align: left;">
www.colorschemedesigner.com</div>
<div class="separator" style="clear: both; text-align: left;">
www.colourlovers.com</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<h2 class="separator" style="clear: both; text-align: left;">
(3) Colormaps</h2>
<div class="separator" style="clear: both; text-align: left;">
A great source for colormaps: <a href="http://soliton.vm.bytemark.co.uk/pub/cpt-city/index.html" target="_blank">cpt-city</a>. Thanks Nick for showing me this! I'll definitely use it in the future when I want colormaps for... well, just about anything. </div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
Also, colorbrewer2.org is really cool. There they have both divergent and sequential colormaps. There is an accompanying <a href="http://www.mathworks.com/matlabcentral/fileexchange/34087" target="_blank">matlab file</a> from the central file exchange.</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
Here are some examples of sequential, divergent and categorical colormaps:</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjA8OMm4KHcwf-AzIFUoH8A1wIfkWBta-aCh7Y3rDdR0fKhdr6gfmt-qoU9Gz-DayphSGrQMqGMYSNfkgjahf9rJQM07rolk6SDKUaBG8k6JzZGk1gxm87PaixBxjVn6R0HI_Mq5yUvxpB4/s1600/divergent+vs+sequential.tiff" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="316" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjA8OMm4KHcwf-AzIFUoH8A1wIfkWBta-aCh7Y3rDdR0fKhdr6gfmt-qoU9Gz-DayphSGrQMqGMYSNfkgjahf9rJQM07rolk6SDKUaBG8k6JzZGk1gxm87PaixBxjVn6R0HI_Mq5yUvxpB4/s400/divergent+vs+sequential.tiff" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
Usually, anomalies are plotted with divergent colormaps and other variables plotted with sequential ones. However, sometimes it makes most sense to plot temperature with a red/blue differential colormap. Just make sure that the red color corresponds to the warmer colors! Choose a colormap wisely so that it highlights the important parts of the data.</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
Eleanor Frajka-Williams (one of my figure design gurus) has chosen colormaps that she always uses for the same variables: blue to yellow for salinity, red to blue for temperature, brown to green for oxygen, and light green to dark green for chlorophyll. Here's an example of one of her figures. All of the colormaps are from colorbrewer:</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgd5EXJuBrQmnpHpV8m1NeCwpHbaB9-ODpe0U2AWmL0QNPIrZedd4iSkXa3qr8mkXCjWjZeKwUwLrj2g1NUGyQMjvDHrbBSSZwrpYBX0bQk4BgvidwpZ5yyOYMCPsyxjKgb-Wn2rajJ3bYn/s1600/Eleanor_goodcolorbars_badsave.tiff" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgd5EXJuBrQmnpHpV8m1NeCwpHbaB9-ODpe0U2AWmL0QNPIrZedd4iSkXa3qr8mkXCjWjZeKwUwLrj2g1NUGyQMjvDHrbBSSZwrpYBX0bQk4BgvidwpZ5yyOYMCPsyxjKgb-Wn2rajJ3bYn/s400/Eleanor_goodcolorbars_badsave.tiff" width="291" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
Here's an other example that shows why the jet colormap is so bad. Look at how different it is from the gray colormap. </div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhvVEOuZzzC30PNS-jrXxodWrcbPfqsoho-_nIKsGuPabxl8F8uirEEWNQJGG2BsEKjm_kkoPtNopdzkpHW0dldys3CB9ErWIMw-0ig3XuvZUoQbDQWQTg1jx9Hoa8idLhhUdAwf2VdcD2v/s1600/different+colormaps+jet+bad+crop.tiff" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="200" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhvVEOuZzzC30PNS-jrXxodWrcbPfqsoho-_nIKsGuPabxl8F8uirEEWNQJGG2BsEKjm_kkoPtNopdzkpHW0dldys3CB9ErWIMw-0ig3XuvZUoQbDQWQTg1jx9Hoa8idLhhUdAwf2VdcD2v/s400/different+colormaps+jet+bad+crop.tiff" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
Here, we see that in the panel on the left where there is a perfectly linear gradient, the jet colormap makes it look like there are many different "levels." In the second panels, even though the gradient has a jump in the middle, it can't be seen in the jet colormap. The right two panes show other differences in the appearances of the two colormaps. This example comes from a great article by David Borland and Russell M. Taylor II called <a href="http://www.jwave.vt.edu/%7Erkriz/Projects/create_color_table/color_07.pdf" target="_blank">Rainbow Color Map (Still) Considered Harmful</a>. </div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
Another thing to consider is whether to use a discrete or continuous colormap. See how different the following two examples are even though they have the same color limits.</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEieLcTfZyxnBOUy8drgKfm_qc_tCwOniDsppO9_nBy2cFMmdW3O4ManVcavtpOhoQmzD1GciuvRITAreyScJ1J12Aga-aVl6ti60g3XspU5rE_Ro181xt_0AzY_oDJH3T6tv3ZR8MVULf4M/s1600/ttp+bathy+continuous.tiff" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEieLcTfZyxnBOUy8drgKfm_qc_tCwOniDsppO9_nBy2cFMmdW3O4ManVcavtpOhoQmzD1GciuvRITAreyScJ1J12Aga-aVl6ti60g3XspU5rE_Ro181xt_0AzY_oDJH3T6tv3ZR8MVULf4M/s320/ttp+bathy+continuous.tiff" width="291" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZT0spjv8DkVSVS3CVkNOm1UrI19_AVcYlZ62UP0cYaF20ZPC9tV-g9YY1Lnv1ldvAewOE6pesopXzwYxD4DWl1uG0K4dq5AYPnT2mUxn7FPIQkRlBC2xf6tWGUS2VTDIxEJVcdyKZc-Ft/s1600/ttp+bathy+discrete.tiff" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZT0spjv8DkVSVS3CVkNOm1UrI19_AVcYlZ62UP0cYaF20ZPC9tV-g9YY1Lnv1ldvAewOE6pesopXzwYxD4DWl1uG0K4dq5AYPnT2mUxn7FPIQkRlBC2xf6tWGUS2VTDIxEJVcdyKZc-Ft/s320/ttp+bathy+discrete.tiff" width="294" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
Finally, Eleanor gave me an example of a very different colormap that is useful for highlighting eddies and small scale variability. </div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhf3Aed14JSp9p0OFWoSVqDdsrbm1hpCEN7RjOGC7cXb2n0_JIOHRnqpHikuB2xYwhFGIDQfgvmpx0xaSQZut9ZzruwT0ywwlvLKaeT-OLySWMIIyAp3utrtId14hGn-mPQ4J4Eg9XGGARl/s1600/ostia_map3_med_000001.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="502" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhf3Aed14JSp9p0OFWoSVqDdsrbm1hpCEN7RjOGC7cXb2n0_JIOHRnqpHikuB2xYwhFGIDQfgvmpx0xaSQZut9ZzruwT0ywwlvLKaeT-OLySWMIIyAp3utrtId14hGn-mPQ4J4Eg9XGGARl/s640/ostia_map3_med_000001.png" width="640" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
(4) Colorblindness</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
When using colormaps like jet, many people who are colorblind have trouble seeing the colors. The following figure shows two colormaps and how they are seen to people with the most common type of colorblindness.</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgYQW9Sw2cgZqv0Oq8D8qIObsnp34W8fQ6Wz3mQW_2hZ502M5pjTLCkkULmfNnOFCE3Npbdbzar6kk9Xaf2iJ_LhjMiGBFSwb3WXEbo-hPFBaEqp6kecOfbK3LMKkoxUkDMefXSZQYFVezE/s1600/colorblindness.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="640" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgYQW9Sw2cgZqv0Oq8D8qIObsnp34W8fQ6Wz3mQW_2hZ502M5pjTLCkkULmfNnOFCE3Npbdbzar6kk9Xaf2iJ_LhjMiGBFSwb3WXEbo-hPFBaEqp6kecOfbK3LMKkoxUkDMefXSZQYFVezE/s640/colorblindness.png" width="454" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
Just another example of why it's good to use other colormaps besides jet. Good colorblind information can be found on the web. There are even sites where you can load in your figures and it will display what the figure will look like to colorblind people. </div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>Sallyhttp://www.blogger.com/profile/00391077265779122872noreply@blogger.com4tag:blogger.com,1999:blog-9151144462344654555.post-61497304155305461422012-04-18T15:04:00.005-07:002012-04-18T15:11:33.306-07:00Add a label to a colorbar in MatlabI find myself Googling for this one every time I need to label a colorbar in a Matlab plot.<br /><br />To add a label to your colorbar:<br /><br /><span style="font-family:lucida grande;"><span style="font-family:courier new;">h = colorbar;</span><br style="font-family:courier new;"><span style="font-family:courier new;">ylabel(h, 'Water depth, m');<br /><br /><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg1rWKfql8f2E883Z1qU7aEPny7ATJBQQdREmf2C4PwOKRYByzrBKc2jGtAmwo4wHsrw6haNIeNsY2i3fmjmeRfdKxQJs-sGF75eYkNf_cWVeIAFPfjtp2M6w0ECaS1VzcpT6agFrfxGl6i/s1600/colorbar_demo.png"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 322px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg1rWKfql8f2E883Z1qU7aEPny7ATJBQQdREmf2C4PwOKRYByzrBKc2jGtAmwo4wHsrw6haNIeNsY2i3fmjmeRfdKxQJs-sGF75eYkNf_cWVeIAFPfjtp2M6w0ECaS1VzcpT6agFrfxGl6i/s400/colorbar_demo.png" alt="" id="BLOGGER_PHOTO_ID_5732865851874355378" border="0" /></a><br style="font-family:georgia;"><span style="font-family:georgia;">We'll cover stuff like this in our next Figure Club meeting on Matlab tips and tricks.</span><br /></span></span>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-9151144462344654555.post-91432434775630047782012-04-12T20:46:00.006-07:002012-04-12T21:11:27.907-07:00Meeting recap: The Elements of Graphing DataOn 29 March, we discussed the first and second chapters of Cleveland's <i>The Elements of Graphing Data</i>, which gives much advice on graphing techniques and best practices. Some of the topics we discussed were:<div><ul><li>Visual clarity, which is the idea that when making a figure, one should strive to make the data stand out and avoid superfluity in your graph. This means things like ensuring data points aren't buried by trend lines, axes, labels, or other forms of clutter.</li><li>A clear understanding of a graph's purpose, by way of putting the conclusions from which you want the reader to draw in graphical form and making captions comprehensive and informative. A good caption should describe everything that is graphed in the figure, draw attention to the important points, and describe the conclusions to be drawn from the graph. </li><li>Aspect ratios and the idea of banking to 45 degrees. This is the idea that humans are best able to estimate rates of change in graphical data when the average slope from point to point is 45 degrees. Making your figure dimensions to bring the plotted data close to this is probably a good idea.</li><li>Scales, and the appropriate choices of tick marks and scales to compare data between graphs.</li></ul><div>Some good resources for general scientific figure creation and examples, both good and bad, include:</div></div><div><a href="http://www.biostat.wisc.edu/~kbroman/topten_worstgraphs/">http://www.biostat.wisc.edu/~kbroman/topten_worstgraphs/</a></div><div><a href="http://www.gautschy.ch/~alfred/SciIll/CraftingIll.html">http://www.gautschy.ch/~alfred/SciIll/CraftingIll.html</a></div><div><a href="http://www.doc.govt.nz/upload/documents/science-and-technical/docts32.pdf">http://www.doc.govt.nz/upload/documents/science-and-technical/docts32.pdf</a></div><div><a href="http://www.labtimes.org/labtimes/issues/lt2008/lt05/lt_2008_05_52_53.pdf">http://www.labtimes.org/labtimes/issues/lt2008/lt05/lt_2008_05_52_53.pdf</a></div><div><br /></div><div>along with classic books like Tufte's <i>The Visual Display of Quantitative Information</i> and Cleveland's <i>The Elements of Graphing Data</i>.</div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-9151144462344654555.post-37033181238844513532012-04-12T20:02:00.001-07:002012-04-12T20:02:18.603-07:00Creating good scientific figures is difficult even for the best scientists. In Spring 2012, a few oceanographers from the University of Washington decided to start talking about figure design every week with the goal of improving our scientific figures. This blog is a place for design ideas, links to helpful websites, good and bad figure examples, MATLAB tricks, and anything else that might help us design better figures.Sallyhttp://www.blogger.com/profile/00391077265779122872noreply@blogger.com0