quick question: I’m creating “random” polygons using either the patch() or the fill() function in Matlab. This works quite good and it is plotted correctly.
However, I need to at least save a few hundres polygons as images to my hard drive for working with them later – so I’m looking for a way to directly save the image in my function rather than saving each polygon myself using the file-menu.
Is there any way to do this?
Thanks in advance!
You can indeed use the
printfunction, but I would not use thejpegdevice. JPEG is never the right format for plots (you will get a lot of artifacts near all your lines).If you need a bitmap image, try the
pngortiffdevice. If you don’t need a bitmap, use the appropriate vector image format:figis the native MATLAB format (which allows you to edit the plot afterwards), so this is the best one if you stick with MATLAB for all your operations. For exporting to other software, I would recommendpdf(works almost anywhere),epsc(EPS with color, great for LaTeX or inkscape),wmf/emf(Windows Metafile, so Windows only, but great for including the images in MS Office). Or you could of course use any of the other formats mentioned in theprintdocumentation.Sometimes it’s a pain in the neck to get the format of your image all right (especially with PDF output). Just take a look at the different properties of your figure and more specifically the
PaperSize,PaperUnitsandPaperPosition.The easiest way, and I guess the best solution, is to save as a
.figfile. You can do this by usingsaveas:Afterwards, you can reload the image with the
openfigfunction: