Need to make a festive graph? Today we look at putting a background graphic in your plot.
close all; clear all
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')
Let's add a background image, use a festive plot color, and a festive font.
[X,MAP] = imread('8happy-thanksgiving-day.gif');
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)
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')
this makes the graph look like what you want! Much more festive.
set(gca,'ydir','normal'); % categories: plotting % tags: whimsical