I know that I can use the following commands to create an opaque cylinder in matlab:


I want to plot an arrow inside the cylinder to denote the direction of the flow of a fluid. But I'm not sure how to make the cylinder's color transparent enough to see the arrow within.


The command surf could be set as an object, following code snippets should do the trick:

R=[1 1];
[X,Y,Z] = cylinder(R,N);
testsubject = surf(X,Y,Z); 

wherein the last number, here I used 0.5, is the alpha value you wanna set, it is between zero and one, in which if set as one the cylinder will be opaque. For example, the cylinder shall look more fancy if you do something like this:


The final output should look like this if playing with the camera angle a little more:

In the MATLAB help browser, simply look for Figure Properties and Patch Properties, all the adjustable parameters of the specific object you just draw are included.

Also I wanna point out something extra with respect to the transparency in MATLAB, in MATLAB there are three renderers, the default renderer for outputting the graph on your screen should be OpenGL, while for the print command, the default renderer is painter, and the painter renderer can not handle the transparency, so be sure to switch to zbuffer or openGL being the renderer when you wanna use the print command for some eps output.

| cite | improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.