在 Matlab 中绘图
Matlab中如何同时绘制两个图形?每次我使用 surf() 时,它都会在旧的上绘制。另外,如何保存图像以便将它们导出到 MS Word 或 Powerpoint 等?
How do you plot two figures at the same time in Matlab? Every time I use surf() it plots over the old one. Also, how do you save the images so you can export them to MS word or powerpoint or something?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
您可以在单独的窗口中绘制两个图形:
或在子图中:
有关详细信息,您可以查看图形和子图函数的 MATLAB 文档(在帮助菜单中)。
要将图像打印到文件,请参阅打印功能的文档。或者直接转到文件 ->另存为,然后选择您想要的图像类型。
You can plot two figures in separate windows:
or in subplots:
For more info, you can see the MATLAB docs for the figure and subplot functions (in the help menu).
For printing the images to a file, see the documentation for the print function. Or just go to File -> Save As, and pick the image type you want.
在每个绘图/冲浪/网格之前使用命令图形。
例子
Use the command figure before each plot/surf/mesh.
example
在调用
surf
之前调用figure
。figure
打开一个新的图形窗口。当您调用surf
时,它将绘制到当前选定的图形中。您可以使用图形窗口中的菜单“编辑”->“复制图形”将图形复制粘贴到 Word 或 Powerpoint 中。如果在 Word 中,单击粘贴的图形并选择“取消分组”,您甚至可以去编辑该图形。
要保存,请在图形窗口的文件菜单中选择“另存为...”。对于 Adobe Illustrator,另存为 .eps(比 .ai 效果更好)。
Call
figure
before callingsurf
.figure
opens a new figure window. When you callsurf
, it will plot into the currently selected figure.You can copy-paste figures into Word or Powerpoint by using, in the figure window, the menu Edit->Copy Figure. If in, say Word, you click on the pasted figure and select 'ungroup', you can even go and edit the figure.
To save, you select 'Save as...' in the File-menu in the figure window. For Adobe Illustrator, save as .eps (works better than .ai).
作为对先前响应的另一个小补充,您可以使用
print -dmeta
命令将图形直接打印到剪贴板。然后只需粘贴到 Word 或 PowerPoint 文档即可。我发现它非常整洁。As another small addition to previous responses, you can print a figure directly to clipboard using
print -dmeta
command. Then just paste to Word or PowerPoint document. I found it very neat.@kwatford如果您使用
hold all
而不是hold on
,那么Matlab将使用该图的下一个定义的颜色和线条样式。查看和之间的区别
@kwatford If you use
hold all
rather thanhold on
then Matlab will use the next defined colour and linestyle for that plot. check out the difference betweenand
要在单独的窗口中创建新图形,只需说出
figure
。要导出为图像文件,请使用print
命令和相应的-d
选项来选择文件格式。就像这样:To create a new figure in a separate window, just say
figure
. To export as an image file, use theprint
command with the appropriate-d
option to select the file format. Like so:执行
hold on
以保持当前图形。新的地块将被添加到现有的地块中。使用hold off
将其改回之前的行为。除了
print
命令(参见Drew Hall的回复)之外,您还可以通过“文件”菜单导出为其他格式,或使用编辑菜单的“复制图形”功能。如果您想将其粘贴到Word或Powerpoint中,使用“选择性粘贴”而不是普通粘贴可能会得到更好的结果。Execute
hold on
to hold the current figure. New plots will be added to the existing plots. Usehold off
to change it back to the previous behavior.In addition to the
print
command (see Drew Hall's response), you can export to other formats via the File menu, or use the Copy Figure function of the edit menu. If you want to paste it into Word or Powerpoint, you might get a better result if you use "Paste Special" instead of normal Paste.