Borrar filtros
Borrar filtros

I would like to copy a matlab figure to my clipboard so I can paste it in Powerpoint as a vector graphic

83 visualizaciones (últimos 30 días)
I would like to copy a matlab figure to my clipboard so I can paste it in Powerpoint as a vector graphic. This is usually very simple, I just choose "metafile" in the cop options. More recently I tried the same thing getting this error message:
Error using print (line 82)
Unable to copy the figure to the clipboard. Increasing the Java Heap Size setting in the MATLAB preferences may
help; otherwise try saving to a file or choose a different clipboard format.
Error in matlab.graphics.internal.copyFigureHelper (line 158)
print(argsToPrint{:});
Error in editmenufcn (line 69)
matlab.graphics.internal.copyFigureHelper(hfig)
Error while evaluating Menu Callback.
I followed the suggestion and increased the Java thingy, up to 4 GB, still same problem. The weird thing is, it's actually a rather simple image of only 7 MB. I'd be happy to upload the .fig file here if possible.
I also met this problem in MATLAB 2021b.
But the problem is gone when I copy the same figure in MATLAB 2018b. But I want to know how to solve this problem in MATLAB 2021b.
Any hints what the problem might be?
Thanks,
Toby
  6 comentarios
Anton Kogios
Anton Kogios el 21 de Feb. de 2023
I think there may be issues with importing svg formats in PPT 2016, but I guess if it works with other less complex figures then maybe not (see https://stackoverflow.com/questions/44098870/microsoft-office-2016-how-to-import-svg and https://answers.microsoft.com/en-us/msoffice/forum/all/powerpoint-2016-svg-fails-to-import-correctly/20d2dd54-e15e-4b80-bbf0-ce5dda8f8636). Either way, I would suggest trying to update PPT if possible.
If you want vector graphics in PPT, you can also try saving as an .eps file and then importing to PPT. This works for me. To save as .eps, you can go to Save As like before, or use this command:
exportgraphics(gcf,'poor.eps','ContentType','vector')

Iniciar sesión para comentar.

Respuestas (2)

Ravi
Ravi el 21 de Feb. de 2023
I understand that you are trying to export your plots in svg format and add that image to your ppt.
Below steps may help you save your plots as svg.
  1. Click on save button from your plot.
2. Select svg from the drop down menu in save-as pane.
3. Drag and drop this file to your ppt file.

Image Analyst
Image Analyst el 22 de Feb. de 2023
Did you try copygraphics?
help copygraphics
COPYGRAPHICS Copy plot or graphics content to clipboard COPYGRAPHICS(OBJ) copies the specified graphics to the clipboard OBJ is the handle of any type of an axes, a figure, a chart that can be a child of the figure, a tiled chart layout, or a container within the figure. COPYGRAPHICS(___, OPTIONS) copies the graphics to the clipboard, applying the specified OPTIONS. OPTIONS is one or more of the following name-value pairs. 'ContentType', CONTENTTYPE how to generate content when copying in vector format CONTENTTYPE can be one of the following values - 'vector' to generate vectorized (scalable) output - 'image' to generate rasterized output (embed image) - 'auto' allow MATLAB heuristic to decide The default value is 'auto' 'Resolution', DPI specifies output resolution for images. DPI must be a positive whole number. The default value is 150 'BackgroundColor', COLORSPEC specifies the color to use as the background COLORSPEC can be one of the following values - a color name, such as 'red', or 'w' - an RGB triplet, such as [1 0 0] or [1 1 1] - a hexadecimal color code, such as '#FFF' or '#FFFFFF') - 'none' to use either a white or transparent background, depending on what the output format supports - 'current' to use the graphic's current background color The default value is 'white' 'Colorspace', COLORSPACE the color space to use when generating output COLORSPACE can be one of the following values - 'rgb' generates RGB true color output - 'gray' generates grayscale output The default value is 'rgb' Example: Copy a plot to clipboard plot(rand(3)); copygraphics(gca); Example: Copy a plot to the clipboard and ensure output is vectorized/scalable plot(rand(3)); copygraphics(gca, 'ContentType', 'vector'); Example: Copy a plot to the clipboard as an image plot(rand(3)); copygraphics(gca, 'ContentType', 'image'); Example: Copy a specific plot from figure to the clipboard fig = figure; ax1 = subplot(2,1,1); bar(magic(4)); ax2 = subplot(2,1,2); plot(rand(4)); copygraphics(ax2); Example: Copy all plots from figure to the clipboard fig = figure; subplot(2,1,1); bar(magic(4)); subplot(2,1,2); plot(rand(4)); copygraphics(fig); Example: Copy a plot to the clipboard using grayscale colors plot(rand(3)); copygraphics(gca, 'Colorspace', 'gray'); See also EXPORTGRAPHICS, EXPORTAPP Documentation for copygraphics doc copygraphics
  4 comentarios
Fanyun
Fanyun el 22 de Feb. de 2023
Yes, the full-screen resolution can meet my needs. What I'm puzzled about now is that Matlab 2018 can easily copy vector pictures into PPT by using copyfigure, but Matlab 2021 will prompt that the same figure can't be copied, and it needs increase the Java heap size. At present, it can only be solved by saving it as eps and then importing a file in eps format, but the saved eps file size is very large.
Fanyun
Fanyun el 22 de Feb. de 2023
Indeed, if the full screen size is not used, this error will not occur and the vector diagram can be copied smoothly.

Iniciar sesión para comentar.

Categorías

Más información sobre Data Import and Export en Help Center y File Exchange.

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by