When saving a shape as an eps file, Matlab disables color shortcuts.

I have a shape generated using an outline with a color bar. Most of my graphs are beautiful, but when the values โ€‹โ€‹on the color bar are of the order of 10^{-3} , or the numbers 0.005 , etc. They are recorded with a color bar, or x10^{-3} recorded at the top.

In both cases, part of the label is disabled - either 3 at x10^{-3} , or half 5 at 0.005 .

I can fix it using

 set(gca, 'ActivePositionProperty', 'OuterPosition') 

for the picture on the screen, but I need to save it in eps format. When I do this, 3 (or 5 ) will turn off again!

I can also fix this by manually pulling out the lower right corner of the picture window to enlarge it. But this changes the dimensions of the axis labels, etc. Compared to the plot itself, so that they are different from all my other figures, that is, numbers that I do not change.

Any suggestions?

+4
source share
3 answers

Matlab uses two sizes for drawings: screen size ( Position property of the shape) and PaperSize . The first is used to display on the screen, and the second is used to print or export to image formats other than .fig . I suspect this is the source of your problem.

Here is what you can try:

 size = get(gcf,'Position'); size = size(3:4); % the last two elements are width and height of the figure set(gcf,'PaperUnit','points'); % unit for the property PaperSize set(gcf,'PaperSize',size); 

This sets the โ€œpaperโ€ size for export to .eps to the size of the number displayed on the screen.

If this does not work, you can play a little with PaperSize or other paper related properties. The Figure Properties page contains additional information about the properties.

Hope this helps!

+2
source

The previous sentence is partly true. Here is what I did:

  • set both curly and paper units to the same measure (the picture has pixels, not dots!)

     set(gcf,'Units','points') set(gcf,'PaperUnits','points') 
  • do the same as suggested earlier:

     size = get(gcf,'Position'); size = size(3:4); set(gcf,'PaperSize',size) 
  • the thing now is that it can be offset from paper, as in my case, so put it back on

     set(gcf,'PaperPosition',[0,0,size(1),size(2)]) 

I'm not sure about the offset [0,0], but what is disabled by one point :)

+2
source

Try saving the file to filename.eps :

 set(gcf,'Units','points') set(gcf,'PaperUnits','points') size = get(gcf,'Position'); size = size(3:4); set(gcf,'PaperSize',size) set(gcf,'PaperPosition',[0,0,size(1),size(2)]) print(gcf,'filename','-depsc','-loose'); % Save figure as .eps file 
0
source

Source: https://habr.com/ru/post/1389117/


All Articles