Borrar filtros
Borrar filtros

Remove white border when "Copy figure"

8 visualizaciones (últimos 30 días)
Chris Poffel
Chris Poffel el 18 de En. de 2017
Respondida: Benjamin Kraus el 23 de En. de 2017
Hello, using Matlab 2016b, how can I (simply) remove the white border around my subplot group? It is a real waste if I copy a picture in an email from clipboard. Is it possible without using a complicated function from the FileExchange?
I do not have access to the image processing toolbox.
Best Regards
  2 comentarios
Jan
Jan el 18 de En. de 2017
Please provide the important detail, how you "copy" the figure to the email: As screenshot? Using saveas or print? Through a command from the menu bar or programmatically?
Chris Poffel
Chris Poffel el 19 de En. de 2017
I click on "Copy Figure" (copies to clipboard) (only works with bitmap option in copy options)

Iniciar sesión para comentar.

Respuestas (1)

Benjamin Kraus
Benjamin Kraus el 23 de En. de 2017
If you are referring to the margins surrounding your axes in the figure, the size of those margins are hard-coded within subplot, so there is no easy way to change them while still using subplot. One option you can consider is to manually create the subplot by specifying your axes position, for example:
Instead of this:
subplot(2,3,1)
plot(1:10)
subplot(2,3,2)
plot(1:10)
subplot(2,3,3)
plot(1:10)
subplot(2,3,4:6)
plot(1:10)
You can do this:
ax1 = axes('OuterPosition',[0/3 1/2 1/3 1/2]);
plot(1:10)
ax2 = axes('OuterPosition',[1/3 1/2 1/3 1/2]);
plot(1:10)
ax3 = axes('OuterPosition',[2/3 1/2 1/3 1/2]);
plot(1:10)
ax4 = axes('OuterPosition',[0/3 0/2 3/3 1/2]);
plot(1:10)
OuterPosition is specified as [left bottom width height].
The problem you will find with that approach is that the bottom axes doesn't line up with the top three. That is because the margin is in normalized units, so the wider the axes the wider the space.
There are two ways you could try to fix that:
Option 1 - Switch to non-normalized units:
ax4.OuterPosition(3) = 1/3; % Reduce the width temporarily.
ax4.Units = 'pixels'; % Switch to a non-normalized unit will "lock-in" the size of margin.
ax4.OuterPosition(3) = ax4.OuterPosition(3)*3; % Restore the width.
ax4.Units = 'normalized'; % This will allow axes to resize with figure again.
Option 2 - Set the Position of the bottom axes to match top axes.
ax4.Units = 'normalized'; % Restore the units if you tried option 1.
ax4.Position(1) = ax1.Position(1); % Align the left edge.
ax4.Position(3) = ax3.Position(1)+ax3.Position(3)-ax1.Position(1);
- Ben

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by