I want to plot a function in 3D and to export as high quality

25 次查看(过去 30 天)
I have a function as follows:
I want to plot the function in 3D and then I want to export the figure with high quality (such as .eps or .pdf)
First Question: I defined the function as an anonymous function (func=@(x,t) ....) and I use command fsurf. What are the best options? (Should I use meshgrid )
Second Question: When I save the figure, I get a .eps file with a huge size (10 MB) using saveas(gcf, 'figure.eps', 'epsc');
What do you suggest to the reduce size of the figure?
close all;
clc;
clear all;
figure (1)
func=@(x,t) (16/3).*(12.*((-4)+4.*exp(1).^(8.*((-1/16)+(-2).*t+x))).^(-1)+(-4)*((-1/16)+(-2).*t+x));
fsurf(@(x,t) func(x,t),[-1 1 0 1],'ShowContours','on');
set(gcf,'renderer','Painters');
set(gcf, 'PaperPositionMode', 'auto')
saveas(gcf, 'figure.eps', 'epsc');

回答(1 个)

Sulaymon Eshkabilov
(1) To have a better resolution of the plotted data and control over the calc resolution, it is better to employ meshgrid()
(2) To have a compact exported image, it is better to employ exportgraphics for about 73 times more efficient.
func=@(x,t)(16/3).*(12.*((-4)+4.*exp(1).^(8.*((-1/16)+(-2).*t+x))).^(-1)+(-4)*((-1/16)+(-2).*t+x));
[X, T] = meshgrid(linspace(-1,1), linspace(0,1));
F=func(X,T);
meshc(X,T,F);
set(gcf,'renderer','Painters');
set(gcf, 'PaperPositionMode', 'auto')
saveas(gcf, 'Fig1.eps', 'epsc');
S1=dir('Fig1.eps');
S1_Size=S1.bytes;
H = figure;
meshc(X,T,F);
exportgraphics(H,'Fig2.eps')
S2=dir('Fig2.eps');
S2_Size=S2.bytes;
fprintf('The size compactness: %d times \n', round(S1_Size/S2_Size))
The size compactness: 73 times
  2 个评论
student_md
student_md 2022-1-2
编辑:student_md 2022-1-2
Thank you.
In your suggestions, Fig.1 has high quality, but Fig2 doesn't have high quality. When I zoom in, it is pixelated such as bitmap format. Please see the result of Fig2 as follows.
I expect the file to be high quality and with as low file size as possible. How can we achieve this? Could you share some alternatives? (may be we export .pdf file)

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Colormaps 的更多信息

产品


版本

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by