如何在 MATLAB 中栅格化曲面图,同时将轴保持为矢量图形?
我正在 MATLAB 中制作 3D 曲面图,我想光栅化曲面图(以节省图像大小和加载速度),同时将图形的其余部分(例如,轴、标签、标题等)保留为矢量图形。我该怎么做?现在我有以下内容:
x = linspace(-2, 2, 201);
y = linspace(-2, 2, 201);
[X, Y] = meshgrid(x, y);
Z = sin(sqrt(X.^2 + Y.^2));
fig = figure;
colormap parula
surf(X, Y, Z, 'FaceColor', 'interp', 'EdgeColor', 'none', 'FaceLighting', 'gouraud')
daspect([4 4 1])
axis tight
view(-50, 30)
camlight left
exportgraphics(fig, 'test_matlab_02.pdf', 'ContentType', 'vector')
如果我将 ContentType
设置为 vector
,那么整个图形就是矢量图形。如果我将 ContentType
设置为 image
,那么整个图形就会被光栅化。如何为图中的其余特征绘制带有矢量图形的栅格化曲面图?
I am making a 3D surface plot in MATLAB, and I want to rasterize the surface plot (to save image size and loading speed) while keeping the rest of the figure (e.g., axes, labels, titles, etc.) as vector graphics. How can I do this? Right now I have the following:
x = linspace(-2, 2, 201);
y = linspace(-2, 2, 201);
[X, Y] = meshgrid(x, y);
Z = sin(sqrt(X.^2 + Y.^2));
fig = figure;
colormap parula
surf(X, Y, Z, 'FaceColor', 'interp', 'EdgeColor', 'none', 'FaceLighting', 'gouraud')
daspect([4 4 1])
axis tight
view(-50, 30)
camlight left
exportgraphics(fig, 'test_matlab_02.pdf', 'ContentType', 'vector')
If I set ContentType
to vector
, then the whole figure is vector graphics. If I set ContentType
to image
, then the whole figure becomes rasterized. How can I have a rasterized surface plot with vector graphics for the remaining features in the figure?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
File Exchange 提供 vecrast,在这种情况下可能有效。它应该能够结合光栅化和矢量格式。
从
vecrast
函数的描述来看:该函数能够处理 2D 和 3D 绘图,如注释中所述:
File Exchange offers vecrast, which might work in this case. It’s supposed to be able to combine rasterized and vector formats.
From the description of the
vecrast
function:The function is able to handle both 2D and 3D plots, as specified in the notes: