Turkeyfy your plots

| categories: plotting | View Comments

turkeyfy

Contents

Turkeyfy your plots

John Kitchin

Need to make a festive graph? Today we look at putting a background graphic in your plot.

close all; clear all

Boring plot for thanksgiving

After a plateful of turkey you won't be able to keep your eyes open looking at this graph!

x = linspace(0,400,10);
y = x.^2;
plot(x,y)
title('Happy Thanksgiving')
xlabel('x')
ylabel('y')

Spice it up!

Let's add a background image, use a festive plot color, and a festive font.

Read the figure in

[X,MAP] = imread('8happy-thanksgiving-day.gif');

Plot the figure

note we have to flip it over so it comes out right,and set the colormap. the image is scaled by the xy data we have above. The image will be upside down for now, and the y-axis will be going in the wrong direction. we will fix that later.

image([min(x) max(x)], [min(y) max(y)], flipud(X));
colormap(MAP)

Plot data over the image

Hint: use the listfonts command to see what fonts are available on your machine.

hold on
plot(x,y,'o-','color',cmu.colors('Crimson glory'),'linewidth',2,...
    'markerfacecolor',cmu.colors('Crimson glory'))

title('Happy Thanksgiving','FontName','Lucida Handwriting')
xlabel('x','FontName','Lucida Handwriting')
ylabel('y','FontName','Lucida Handwriting')

Finally fix the y-axis

this makes the graph look like what you want! Much more festive.

set(gca,'ydir','normal');

% categories: plotting
% tags: whimsical
blog comments powered by Disqus