Exporting MATLAB Plots with No Whitespace

In summary, to remove the whitespace around your MATLAB plot when exporting it, you can use the "tight" option in the "print" function. You can also adjust the size of your exported plot without changing the size of your actual plot by using the "Position" property. To export your MATLAB plot without losing its quality, you can increase the resolution of your exported image with the "-r" option. It is also possible to export your plot as a vector image by using the "-deps" or "-dpdf" options. Lastly, to export your MATLAB plot with a transparent background, you can use the "Alpha" property to specify the transparency of your plot elements.
  • #1
Niles
1,866
0
Hi guys

I have been spending a lot of time trying to figure out how to export a plot in MATLAB (to pdf), where the graph fills most of the pdf page, i.e. no whitespace. I can't seem to find the property. Can you give me a hint?


Niles.
 
Physics news on Phys.org
  • #2
Ok, I think I solved it; take a look here: http://www.mathworks.com/matlabcentral/newsreader/view_thread/261315.
 

1. How do I remove the whitespace around my MATLAB plot when exporting it?

To remove the whitespace around your MATLAB plot when exporting it, you can use the "tight" option in the "print" function. For example, you can use the command "print(gcf, 'myplot.png', '-dpng', '-r300', '-tight')" to export your plot with no whitespace.

2. Can I adjust the size of my exported plot without changing the size of my actual plot?

Yes, you can adjust the size of your exported plot without changing the size of your actual plot by using the "Position" property. This allows you to specify the size and position of your plot within the exported image. For example, you can use the command "set(gcf, 'Position', [0, 0, 800, 600])" to set the exported plot size to 800x600 pixels.

3. How can I export my MATLAB plot without losing its quality?

To export your MATLAB plot without losing its quality, you can increase the resolution of your exported image by using the "-r" option in the "print" function. For example, you can use the command "print(gcf, 'myplot.png', '-dpng', '-r600')" to export your plot with a resolution of 600 dots per inch (dpi).

4. Is it possible to export my MATLAB plot as a vector image?

Yes, it is possible to export your MATLAB plot as a vector image by using the "-deps" option in the "print" function. This will export your plot as an Encapsulated PostScript (EPS) file, which is a vector image format. You can also use the "-dpdf" option to export your plot as a PDF file.

5. How can I export my MATLAB plot with a transparent background?

To export your MATLAB plot with a transparent background, you can use the "Alpha" property to specify the transparency of your plot elements. For example, you can use the command "set(gca, 'Color', 'none')" to set the background of your plot to be transparent. Then, when you export your plot, the background will be transparent as well.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
10
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
804
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
4K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
4K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
3K
Back
Top