Have surfaces in powerpoint

Not sure if my question is too relevant for this forum. I am using Matlab to create 3d surfaces. However, I am trying to find a way to put these surfaces in powerpoint. Is there a better alternative out there which generates visually appealing surfaces?
It would be excellent if I am able to show these surfaces as 'rotating'?
Thanks

 Accepted Answer

Chad Greene
Chad Greene on 9 Nov 2014
You wrote: "Is there a better alternative..." Better than what? What exactly do you find visually unappealing about the surfaces you're generating?
If you mean Matlab's built-in options for saving images make low quality graphics, try export_fig.
If you want a video of a rotating surface, try videoWriter.
If you want a .gif of a moving surface, the export_fig package includes a function called im2gif.

15 Comments

It is a fantastic tool and does exactly what I want it to do. But I feel MatLab's 'graphics' are a bit 90s. I just need a way to generate more visually appealing graphs.
Is there a Matlab 'add-on' that can do that for me? Or perhaps any other resource?
This is for a powerpoint presentation, so graphs don't necessarily need to be 'accurate'. They just need to be a 'representation'.
Can you upload a picture of the 90s-looking graph? That might help us with suggestions. If you can upload code to create the graph too, folks on the forum might enjoy tinkering with making a pretty version.
A
A on 10 Nov 2014
Thank you for your response. It essentially looks like this: http://i.stack.imgur.com/I7T3G.png
But I doubt there is a way to improve on this?
Thank you
Yuck indeed. It's similar to the results you get when you type
surf(peaks)
A few tricks that are good to have up your sleeve:
1. If you don't need edge lines, turn them off. You can do this a number of ways. Here's one way:
h = surf(peaks);
set(h,'edgecolor','none')
Or you can mute the edges by adjusting their transparency:
h = surf(peaks);
set(h,'edgealpha',.3)
Or you can turn edges off with shading flat or shading interp
surf(peaks)
shading interp
2. Matlab's default color maps only use 64 colors, making any color gradient look like low-res junk. I always change color maps to 256 colors.
3. Matlab's default options for saving figures are lousy. export_fig is much better. You can manually prevent Matlab from saving the gray space around the axes, but export_fig sets the background color to white by default. It also performs anti-aliasing, which makes text and lines less jagged. export_fig also makes changing resolution easy--e.g., add the -m3 option to save the figure at 3 times the resolution shown on the screen.
4. Toy with lighting if you want to get fancy. Note that Matlab's documentation uses their own lousy methods of saving figures, so even though Matlab can make fancy-looking graphics, default settings will not show great-looking graphics in the figure window, nor can Matlab save great-looking graphics easily using default settings. Again, use export_fig.
Below is an image I made with the following script:
surf(peaks)
axis tight
camlight
shading interp
colormap(jet(256))
lighting phong
export_fig better.png -m3 -q101
A
A on 11 Nov 2014
Absolutely beautiful. Thank you, that is exactly what I wanted.
Just one question --> how do I change the color of the surface so that it is a shade of blue and it just becomes darker or lighter based on the Z-axis?
Thank you
You can
- use colormapeditor if you want to create such a figure only occasionally
- use any RGB array as colormap. E.g. use
>> colormap([zeros(256,2) linspace(0,1,256)'])
after the above code.
A
A on 11 Nov 2014
Awesome. Lastly, what do you guys think of other alternatives:
Plenty alternatives to Matlab do exist. Each have their own strengths and weaknesses. You'll find just as many zealots who tout the supremacy of their favorite program, but in the end, if it does what you want it to do nothing else matters. Unfortunately, popularity is an asset when it comes to portability, long-term support, and being able to share your code with colleagues.
Regarding colormaps, you could also use rgbmap. The syntax would be simply,
rgbmap('light blue','dark blue')
A
A on 17 Nov 2014
Edited: A on 18 Nov 2014
Dear Chad - Not sure if you can see this, but I have a quick follow-up.
Here is the code and results I have so far:
h = surf(peaks);
axis tight
camlight
shading interp
colormap(winter)
lighting phong
shading interp
set(h,'edgecolor',[0 0 0.4]);
set(h,'meshstyle','both');
set(h,'linewidth',2);
export_fig better.png -m7 -q101
1) When I use the export_fig line in your code, it includes the gray space around? It doesn't set it as white?
2) Also, is there a way to add some 'padding' around the surface so that it looks nicer when it is pasted into a word document? It feels like some of the axis numbers being cut off.
3) Lastly, when I add the following piece of code to reduce the transperency of the blue edges, it changes the 'gridlines' into 'dotted' lines. This is clearly different from the image above? I like the gridlines in the above generated image.
set(h,'edgealpha',.15);
Thank you very much for all your help. This is such a massive improvement over the default surfaces.

1. Yes, among a few of my personal preferences I change the background color of all my figures to white by default. Here's what I have in my startup.m file:

 set(0,'DefaultFigureColor','White',...
     'DefaultTextFontSize',14,...
     'defaultaxesfontsize',14,...
     'DefaultAxesFontname','Times',...
     'DefaultTextFontName','Times')

2. If you want some padding, use the -nocrop option when you use export_fig.

3. I suspect that adding edgealpha is changing your figure renderer to OpenGL, because OpenGL is the only renderer that can handle transparency. Instead of making the lines transparent, you can turn them off entirely, or make them very thin. Above, you specified a linewidth of 2. Let's make it quite a bite smaller:

h = surf(peaks);
axis tight
camlight
colormap(winter(256)) 
lighting phong
shading interp
set(h,'edgecolor',[0 0 0.4],'meshstyle','both',...
    'linewidth',.0001);
export_fig test -png -nocrop -m7 -q101
A
A on 18 Nov 2014
Edited: A on 18 Nov 2014
So shiny and beautiful! Thank you so much again, you clearly know your MatLab.
A
A on 18 Nov 2014
Actually - is there not a way to add padding? Because when I add 'axis title' they go 'out of the view' and are cropped out. Any suggestions?
Thank you
Can you clarify? Did you try -nocrop?
A
A on 19 Nov 2014
The axes title still creeps out. Is there a way to pad?
Strange. Can you show an example?

Sign in to comment.

More Answers (0)

Asked:

A
A
on 9 Nov 2014

Commented:

on 19 Nov 2014

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!