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

26 visualizaciones (últimos 30 días)
student_md
student_md el 1 de En. de 2022
Comentada: Torsten el 2 de En. de 2022
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');

Respuestas (1)

Sulaymon Eshkabilov
Sulaymon Eshkabilov el 1 de En. de 2022
(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 comentarios
student_md
student_md el 2 de En. de 2022
Editada: student_md el 2 de En. de 2022
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)

Iniciar sesión para comentar.

Categorías

Más información sobre Colormaps en Help Center y File Exchange.

Productos


Versión

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by