Home > MATLAB > Welcome!

## Welcome!

Anyone who knows anything about presenting data will tell you that pie charts are rubbish.  Even their idiot cousins will tell you that 3D pie charts are even worse.  That got me thinking, “how bad can it get?”.  Sure you can choose garish colour schemes and glossy reflective coatings and transparency, but that has been done before.  By almost every two-bit data-viz charlatan in existence, judging by a Google Image search.  To break new ground in awfulness, we need to enter (cue atmospheric intro)… a new dimension!  In fact, we’re going to make the pie chart travel through time (woo!) with an animation.

The MathWorks, to their eternal shame, include a 3D pie chart function, `pie3`.  By combining it with their `rotate` function, we can enter into new levels of crappiness.

First, we draw the pie chart.  This code is tweaked from the example on the `pie3` help page.

``` colormap(hsv(6)) x = [1 0.25 3 2.5 2 1]; explode = [0 1 0 0 0 1]; h = pie3(x, explode, repmat({''}, size(x))); ```

Now we animate it.

``` n = 180; mov(n) = getframe; for i = 1:n    rotate(h, [20 20], 360 / n);    mov(i) = getframe; end ```

MATLAB ships with the functions `movie`, to play back your animation, and `movie2avi` to export it to video.  For more web-friendlyness, we’re going to create an animated gif using `movie2gif` on the FEX.

``` movie2gif(mov, 'pie4.gif', 'DelayTime', 0.5 / n); ```

And there we have it.  (Click to see it in all its animated glory.)

Now, having set the bar suitably low, I promise all future mosts will be more useful than this.