Clear Filters
Clear Filters

Background transparency is not supported for surf plots

12 views (last 30 days)
Whereas the
close all
[X,Y] = meshgrid(1:0.5:10,1:20);
x=[0 10];y=2*x;
hf1=figure;plot(x,y);set(gca, 'color', 'none')
Z = sin(X) + cos(Y);hf2=figure;surf(X,Y,Z);
set(gca, 'color', 'none');
hf3=figure;[X,Y] = meshgrid(-8:.5:8);R = sqrt(X.^2 + Y.^2) + eps;
Z = sin(R)./R;C = X.*Y;mesh(X,Y,Z,C)
set(gca, 'color', 'none');
I do get indeed transparent figures, but wih the folloing arning
Warning: Background transparency is not supported; using white instead
However, once I insert the pdf in my latex file, the background is white.
WIll appreciate any help.

Accepted Answer

Jaswanth on 2 May 2024
Hi Victor,
To address the issue of exporting figures to .pdf files from MATLAB while ensuring a transparent background, it's necessary to include a Name-Value Argument, ContentType, as vector in your calls to the exportgraphics function.
Kindly refer to the modified code snippet below, where ContentType has been added for clarity.
Please go through the following MathWorks documentations to learn more about Name-Value Arguments in exportgraphics function mentioned above.
  1. ContentType:,ContentType
  2. BackgroundColor:,BackgroundColor
I hope the information provided above is helpful in accomplishing your task.

More Answers (0)


Find more on Printing and Saving in Help Center and File Exchange




Community Treasure Hunt

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

Start Hunting!