Hi Mortain,
I understand that you are encountering an issue where a surface does not appear in a PNG image when using the print command in MATLAB R2014b.
Since you did not provide the specific data used to create the figure in the code snippet, I created some dummy variables to try to reproduce the issue. The code I used is shown below:
N = 15; t = linspace(0,1,N); wg = linspace(0,1,N); D = rand(N,2); XX = rand(N); YY = rand(N); PPDF2 = rand(N); city = 'boston'; figure plot(t,wg,'b') hold on stem3(D(:,1),D(:,2),zeros(N,1),'b.'); s1 = surf(XX,YY,PPDF2,'EdgeColor','none','LineStyle','none'); shading flat;alpha(s1,'color'); sub1=gca; view(2) saveas(gcf,[city '.fig']) print('-dpng','-r600',[city,'.png'])
I have also included the PNG output from the code snippet above:
The example code does not produce the same issue that you are experiencing. In the image, you can see the line running diagonally across the figure, the surface with the specified transparency visible throughout the figure, and various points from the stem plot on the right side of the figure.
This issue might be related to the renderer being used. The two renderer options are OpenGL and Painters. Each renderer displays and sorts objects in different ways. To check the current renderer, you can use the command "get(gcf,'renderer')" while the figure is open. It is likely using OpenGL for this. You could try setting the renderer to Painters ("set(gcf,'renderer','painters')") or including the '-painters' flag in the "print" command. Additionally, you could try entering the command "opengl software" before running the code and seeing if this possibly changes the output. To help further, though, I would need to be able to work with your figure. You can attach a .fig file to a question or comment in MATLAB Answers.
If none of this helps resolve your issue, you could consider using the function "export_fig", which can be found at the following link:
http://www.mathworks.com/matlabcentral/fileexchange/23629-export-fig
Note that this is a MATLAB File Exchange submission from a user, so it is not directly supported by MathWorks. However, it is a popular tool for exporting figures and has proven to be successful in creating a wide variety of exported images and files.
I hope this helps.
Matt Cohen