Wednesday, November 25, 2009

Matlab script for figure with background color

This is the Matlab script to make a white circle with dark background.

The figure1 creates a figure with dark background as indicated by the color attribute.
patch is a built in function which creates a light patch (which is a circle).

I tried the built in function "whitebg" which did not work except that it created another color background (viz: whitebg('green') gives me green background without solving the problem).
set(subplot(2,2,1),'Color','Red') actually sets the color for the subplot but I could not make it work for single figure.
Listed in Matlab file exchange:
http://www.mathworks.com/matlabcentral/fileexchange/25935
Here is the code:

The file gives a circle of given radius with dark background.
generate x and y vectors for circle.

figure1 = figure('Color',[0 0 0]);

axes1 = axes('Parent',figure1,'PlotBoxAspectRatio',...
[1 1 1],'Color',[0 0 0]);
% box('on');
patch(x,y,[1,1,1])
axis square


Note that the point here is not to generate shape, it can be done with conversion into polar co-ordinates (x,y) into (r,theta). My aim was to have different background for figure.

No comments: