Giter Site home page Giter Site logo

export_fig's People

Contributors

ahurlbatt avatar altmany avatar erihe251 avatar hyiltiz avatar jdonley avatar jonasstein avatar ojwoodford avatar readmecritic avatar scottclowe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

export_fig's Issues

Using export_fig with FaceAlpha on Unix through SSH connection

Hello,
I am new to GitHub and I hope I submit this issue in the right way.

Here is a description of my problem : I am running MATLAB 2012a on a Unix distant computer through a SSH connection. I am trying to execute a script which produces figures with patches including transparency (set with the FaceAlpha patch property) and exports the figures with export_fig. When I call export_fig, I get the following errors :

Error using print>LocalPrint (line 295)
Bad data returned by HARDCOPY. Not calling IMWRITE.
Error in print (line 237)
LocalPrint(pj);
Error in print2array (line 140)
print(fig, renderer, res_str, '-dtiff', tmp_nam);
Error in export_fig (line 334)
[A, tcol] = print2array(fig, magnify, renderer);

I use the default renderer (OpengGL), which is supposed to support transparency.
The problem does not occur when I set the FaceAlpha of the patch to 1.
The problem also doesn't occur when I run the script on my Windows machine.
If the information may be useful : the X11 forwarding seems to work OK since I can see MATLAB's desktop (graphical interface).

Any ideas?

Errors with export_fig on R2014b, Yosemite, GS 9.15

Hi Oliver,

The following and similar errors appear to be common on the mathworks thread:

Error using eps2pdf (line 107)
Error: /undefined in bdef
Operand stack:
dom --nostringval--
Execution stack:
%interp_exit .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- --nostringval--
--nostringval-- false 1 %stopped_push 1951 1 3 %oparray_pop 1950 1 3 %oparray_pop 1934 1 3 %oparray_pop 1820 1 3
%oparray_pop --nostringval-- %errorexec_pop .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval--
Dictionary stack:
--dict:1188/1684(ro)(G)-- --dict:0/20(G)-- --dict:77/200(L)--
Current allocation mode is local
Last OS error: Invalid argument
Current file position is 64
GPL Ghostscript 9.15: Unrecoverable error, exit code 1

Error in export_fig (line 433)
eps2pdf(tmp_nam, pdf_nam, 1, options.append, options.colourspace==2, options.quality);

Lines on Patch-Objects after *.EPS/PDF export - e.g. with contourf

I know that there are plenty of comments on strange lines appearing in exported matlab output, still I didn't really find out if there is already a solution to my specific problem.

About 3 years ago I exported a MATLAB contourf plot to *.eps with export_fig of ojwoodford. I guess it was MATLAB R2012a or b and the present version of export_fig those days. It worked perfectly and there were no strange atrifacts, whatsorever.
Yesterday I did the same with MATLAB R2014b and the current release of export_fig. Now I have strange artifacts when exporting to *.eps or *.pdf.

See the attached image (left: 3 years ago, right: yesterday - it's a different colormap and a different matrix of data, but this shouldn't be the problem...)
lines_in_contourf

Unfortunately those white lines are really present --> When I import the *.eps e.g. to Corel Technical Designer and further edit the image to do some tweaks for my presentation, these lines remain visible. After doing some editing and exporting from Corel Technical Designer to *.png or *.eps - I have the lines in both output formats...

Is there any solution to this problem?
Is it a bug or a feature?
Why did it work 3 years ago and now it doesn't anymore?

Is it the same issue that was already reported (#28) and ojwoodford responded that it is a bug, which will be fixed in the next MATLAB release: #28 ?? --> Because I just updated to MATLAB R2015a and to the latest export_fig release. The problem got not fixed...
Thanks for your help!

PS: In between I believe it is actually the anti aliasing... in adobe reader I can set a property (2D graphics accelaration) --> if switched on: the lines disappear. If turned off --> the lines reappear. But in most of the other programs (including GS viewer) I didn't manage to get rid of those lines. Actually the lines obstruct further editing in some third party software outside of MATLAB... and I don't get why I did not have those lines when exporting three years ago... I checked my *.eps files from then: no lines at all in none of the figures I exported then (neither in GS viewer nor in third party software...) --> So why do those lines appear now??

bad export of box-less legend

Reported by Durga Lal Shrestha on Feb 9, 2015:

I have the legend at the Southoutside with horizontal orientation. When the box of the legend is set to 'off', a little bit bottom part of the legend is also cropped when exporting figure to eps and pdf (no problem with png). There is a no problem with box outline. The problem persists in MATLAB R2014b.

plot(1:10); 
h=legend('line','location','Southoutside');
set(h,'Box','off');
export_fig test.eps; 
winopen test.eps

Grey boxes instead of text

Great tool. Small bug report. When exporting, sometimes text within the figure is replaced by grey boxes. Changing the resolution from 600 dpi to 300 dpi often fixes the problem (but not always). Using Matlab R2014b Pre-release.
pagerankscatter

Legends cause problems with HG2

If there is a legend in a figure and HG2 is enabled, the following error pops up:

Error using hg2.Group/get
There is no XLimMode property on the Legend class.
Error in export_fig (line 215)
    Xlims = make_cell(get(Hlims, 'XLimMode'));

Ghostscript Installation on Network Drive Option

It would be nice if Ghostscript.m would allow you to specify an alternate location for a ghostview executable. This could be an optional variable, such as "gs_exec" that could get sent to export_fig. It would be preferable if the variable could be a vector or list of strings so that you could provide it multiple locations. This is required when different users have access to different network drives depending on their location in your company. The idea is that if a user doesn't have ghostview installed, we could install ghostview on a network drive and point export_fig to this executable instead of forcing all users to install ghostview. This approach would be preferrable over a file-selection dialog window (such as pdftops) that informs the user if they don't have ghostview installed because in that scenario the user must know exactly where the ghostview installation is located on a network drive and they must keep answering this same question every time they use software which uses export_fig.

Figure is uncropped when exporting to pdf in MatlabR2014b (with the latest export_fig)

Hi,

First thanks a lot for providing such a wonderful toolbox!

However, here I've found a bug when I switch to Matlab 2014b. In Matlab R2014b, when I was using the toolbox to generate pdf figure as:

export_fig test -pdf -transparent

The margin of the figure is not cropped as desired. Could you have a look at it?

Thanks!

Example code:
figure(1)
plot(1:100,1:100)
xlabel('Frequency (Hz)')
ylabel('attenuation (Neper/m)')
set(gca,'fontsize',16)
export_fig test -pdf -transparent

capture

Annotation units

I have found a minor bug when the units of a figure annotation are set to 'pixels' instead of 'normalized'.

Consider this working example:

set(gcf,'position',[0 0 280 280])
set(gca,'position',[0.1 0.1 0.8 0.8])

% circle at origin
plot(0,0,'ko','markersize',60)

% cross centered at origin
hAn(1) = annotation('line',[0.4 0.6],[0.4 0.6]);
hAn(2) = annotation('line',[0.4 0.6],[0.6 0.4]);
export_fig('fig1-units-normalized.png')

% change annotation units (this does not actually alter the appearance of the figure)
set(hAn,'units','pixels')
export_fig('fig2-units-pixels.png')

% restore annotation units
set(hAn,'units','normalized')
export_fig('fig3-units-normalized.png')

Bug with PDF export in R2014b on MAC 10.10 Yosemite

Dear Oliver,
Would be great to have export_fig function properly on Matlab2014b.
I got the following response from Mathworks.

"The "export_fig.m" function was developed using the graphics system in MATLAB R2014a and earlier releases. The graphics in MATLAB R2014b was fundamentally rebuilt, which produces some incompatibilities with program written for earlier releases. The "Comments and Ratings" section in MATLAB Central for the "export_fig" function have already made note of this incompatibility; this can be seen in the following link:

http://www.mathworks.com/matlabcentral/fileexchange/23629-export-fig

Problem with 'color','none' in R2014b and with whitespace at top of graph

Hi. I noticed export_fig crashes when a line with color set to 'none' is used in R2014b.
export_fig and ghostscript are up-to-date and my computer is Windows 7 64 bit.

Here is the error message:

Warning: File 'C:\Users\Brian\AppData\Local\Temp\tpbe560a33_bda5_4bee_8219_3c3eb53f6202.eps' not found.
In export_fig at 445
In testcase at 10
Error using cell2mat (line 45)
All contents of the input cell array must be of the same data type.

Error in print2eps (line 161)
M = cell2mat(M);

Error in export_fig (line 428)
print2eps(tmp_nam, fig, options.bb_padding, p2eArgs{:});

Error in testcase (line 10)
export_fig .pdf

The following code will generate the error:

line(nan,nan)
line(nan,nan,'color','none')
export_fig .pdf

Looking at print2eps.m, the line M = get(white_line_handles, 'Color'); creates a cell containing both doubles and the string 'none', causing the cell2mat error.
Placing M(strcmp('none',M))={[]}; prior to the cell2mat call seems to solve the problem.

The second issue is that when the ylabel is a long string with large fontsize, the whitespace at the top is not correctly cropped, though it is fine on the other sides.

Here's the code:

plot(sin(0:1:10))
ylabel('aaaaaaaaaaaaaaaaaaa','fontsize',50)
export_fig .pdf

Thanks so much for writing such a helpful script!

Line joins are spikey in vector output using R2014b

I am plotting country borders from a shapefile with the default LineWidth. In Matlab 2014a, export_fig outputs these at the correct width, but it doesn't work properly in 2014b. I use exactly the same code in the two different versions. In the Figure window, these are plotted exactly the same; the differences only occur in the exported figure. These images show the difference between the two:
2014a:
2014a

2014b:
2014b

Problem with white lines when exporting a figure containing multiple subplots

Hello,

When exporting a figure containing multiple subplots with white lines, only the white lines of the first subplot are exported in the correct color.
This is related to the Matlab bug when printing white lines : when commenting line 165 of of print2eps code, none of the line in the figure are white.
This happens irrespective of the output format (vectorized or bitmap), or of the renderer.
ssttom15trials_sample1_recurrent_cmaps

eps and pdf export not working in Matlab R2014b on Ubuntu 14.04

png export is wortking properly. When I try to export to pdf or eps, I get the following error message:

>> export_fig 'filename' '-pdf'
Error using eps2pdf (line 107)
Error: /undefined in bdef
Operand stack:
   dom   --nostringval--
Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1
   %stopped_push   1916   1   3   %oparray_pop   1915   1   3   %oparray_pop   1899   1   3   %oparray_pop   1787   1   3   %oparray_pop   --nostringval--   %errorexec_pop
   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--
Dictionary stack:
   --dict:1184/1684(ro)(G)--   --dict:0/20(G)--   --dict:77/200(L)--
Current allocation mode is local
Current file position is 64
GPL Ghostscript 9.10: Unrecoverable error, exit code 1


Error in export_fig (line 431)
        eps2pdf(tmp_nam, pdf_nam, 1, options.append, options.colourspace==2, options.quality);


>> export_fig 'filename' '-eps'
Error using eps2pdf (line 107)
Error: /undefined in bdef
Operand stack:
   dom   --nostringval--
Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1
   %stopped_push   1916   1   3   %oparray_pop   1915   1   3   %oparray_pop   1899   1   3   %oparray_pop   1787   1   3   %oparray_pop   --nostringval--   %errorexec_pop
   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--
Dictionary stack:
   --dict:1184/1684(ro)(G)--   --dict:0/20(G)--   --dict:77/200(L)--
Current allocation mode is local
Current file position is 64
GPL Ghostscript 9.10: Unrecoverable error, exit code 1


Error in export_fig (line 431)
        eps2pdf(tmp_nam, pdf_nam, 1, options.append, options.colourspace==2, options.quality);

Error: 'Units' is not an accessible property

Recently updated export_fig, using version 27/03/15. Simple call to export_fig, now getting the following error:

Can supply .fig file if that's helpful.

from calling:
export_fig('figures\strouhal\bat1.pdf','-pdf')

    Error using hg.hggroup/get
    The name 'Units' is not an accessible property
    for an instance of class 'hggroup'.

    Error in export_fig (line 282)
                            originalUnits =
                            get(annotationHandles,'Units');

Add option to disable/enable figure output

I really like export_fig, and I use it at as no-hassle solution to export figures from my scripts.
Currently I simply comment all export_fig calls when I just want to run my code without having to wait for Matlab to save all the figures – if export_fig took an optional boolean argument which determined whether to export the figure, or just ignore the call, this could be set using a single variable in the script.

I know this could be achieved putting if statements around all calls to export_fig, but it does clutter the otherwise minimalistic coding style which export_fig allows.
Albeit being considered really bad coding style, this could also be done using a global variable, which would make it even easier to temporarily disable export_fig.

I hope you'll consider my suggestions.

A totally same code, Why I didn't get so smooth figure?

I copy the code:
plot(cos(linspace(0, 7, 1000)));
set(gcf, 'Position', [100 100 150 150]);
saveas(gcf, 'test.png');
export_fig test2.png

But I get the figure not smooth as you get.
we get the figure like in this link:
(https://github.com/altmany/export_fig)
in this link, there are "example", there are 3 figures, Figure, test.png, test2.png you made.
Our figure was like the first Figure, Although I copy your code totally the same, but I can't get so smooth figure. Why? What's the reason?

problems with eps2pdf in export_fig

I tried your code under Ubunutu 14.04 with Matlab2014R and get permanently the same error:

'Error using eps2pdf (line 107)
gs:
/usr/local/MATLAB/R2014a/bin/glnxa64/libtiff.so.5:
no version information available (required
by /usr/lib/libgs.so.9)
Error: /undefined in /findfont
Operand stack:
120 Times-Roman ISOLatin1Encoding
Times-Roman Times-Roman
Execution stack:
%interp_exit .runexec2
--nostringval-- --nostringval--
--nostringval-- 2 %stopped_push
--nostringval-- --nostringval--
--nostringval-- false 1
%stopped_push 1916 1 3
%oparray_pop 1915 1 3
%oparray_pop --nostringval-- 1899 1
3 %oparray_pop 1787 1 3
%oparray_pop --nostringval--
%errorexec_pop .runexec2
--nostringval-- --nostringval--
--nostringval-- 2 %stopped_push
--nostringval-- --nostringval--
--nostringval-- 1868 5 5
%oparray_pop
Dictionary stack:
--dict:1184/1684(ro)(G)--
--dict:0/20(G)-- --dict:82/200(L)--
--dict:97/160(L)-- --dict:8/85(L)--
Current allocation mode is local
Current file position is 7064
GPL Ghostscript 9.10: Unrecoverable error,
exit code 1

Error in export_fig (line 406)
eps2pdf(tmp_nam, pdf_nam, 1,
options.append,
options.colourspace==2,
options.quality);
'

I dont know where the problem is located but i hope you can help me.

Best wishes

Tobi1986

R2014b - Assignment has fewer non-singleton rhs dimensions than non-singleton subscripts

The following code is working:
export_fig([savepath,'bw',savefilename,'_BW_XL_cropped'],...
'-png', '-q101', '-GRAY', '-m3');
while this code is not:
export_fig([savepath,'bw',savefilename,'_BW_XL_cropped'],...
'-png', '-transparent', '-q101', '-GRAY', '-m3');

it results in the following error:

export_fig error. Please ensure:
[...] If the problem persists, then please report a new issue.

Assignment has fewer non-singleton rhs dimensions than non-singleton subscripts
Error in export_fig (line 353)
B(vB(1):vB(2), vB(3):vB(4), :) = A(vA(1):vA(2), vA(3):vA(4), :); %
ADDED BY OH

Independent of the path: The only difference is the transparent option --> why is that a problem?

Ghostscript error when calling eps2pdf

Export_fig has been a life saver. Thank you so much for posting it! I am sorry I accidently posted this bug report as a comment on the mathworks file exchange and am not sure how to take it down...Unfortunately, I now get the following error:
Error using eps2pdf (line 107)
Error: /undefined in bdef
Operand stack:
dom --nostringval--
Execution stack:
%interp_exit .runexec2 --nostringval-- --nostringval--
--nostringval-- 2 %stopped_push --nostringval-- --nostringval--
--nostringval-- false 1 %stopped_push 1932 1 3
%oparray_pop 1931 1 3 %oparray_pop 1915 1 3
%oparray_pop 1803 1 3 %oparray_pop --nostringval--
%errorexec_pop .runexec2 --nostringval-- --nostringval--
--nostringval-- 2 %stopped_push --nostringval--
Dictionary stack:
--dict:1189/1684(ro)(G)-- --dict:0/20(G)-- --dict:77/200(L)--
Current allocation mode is local
Current file position is 64
GPL Ghostscript 9.09: Unrecoverable error, exit code 1
Error in export_fig (line 424)
eps2pdf(tmp_nam, pdf_nam, 1, options.append,
options.colourspace==2, options.quality);

any ideas?

Another Yosemite error

I'm running Mac OS X 10.10.1, MATLAB R2014b, the latest version of export_fig (the one from a few days ago), Ghostscript 9.15, and xpdf 3.04. Here's what happens for me:

>> figure ; plot([0 100],[0 100],'-b')
>> export_fig ~/Desktop/test3.eps
Warning: File '/private/tmp/tpc9226e7e_20fb_4c28_a3f8_3a30467a05f3.eps' not found. 
> In export_fig at 445 
Error using checkArgsForHandleToPrint>LocalCheckHandles (line 88)
MATLAB Graphics handle must be a figure.

Error in checkArgsForHandleToPrint (line 30)



Error in print>LocalCreatePrintJob (line 336)
    handles = checkArgsForHandleToPrint(0, varargin{:});

Error in print (line 153)
    [pj, inputargs] = LocalCreatePrintJob(varargin{:});

Error in print2eps (line 144)
print(fig, options{:}, name);


Error in export_fig (line 428)
        print2eps(tmp_nam, fig, options.bb_padding, p2eArgs{:});

When I print using MATLAB's built-in function, it works (even with the modification you suggested to someone else):

>> print -depsc2 ~/Desktop/test.eps
>> set(gcf, 'PaperPositionMode', 'auto', 'InvertHardcopy', 'off');
>> print -depsc2 ~/Desktop/test2.eps

That warning is pretty weird. Any ideas? I know you are basically unable to support this, but I can try any suggestions you might have.

eps & pdf export not working on Mac 10.10.2 and Matlab R2014b

when I try to export a figure to eps, ps or pdf I get the following error:

>> plot([0 100]*1e10,[0 100]*1e10,'-b')
>> export_fig test.eps
Error: /undefined in Infinity
Operand stack:
   --nostringval--   560   0   0
Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push   1951   1   3   %oparray_pop   1950   1   3   %oparray_pop   --nostringval--   1934   1   3   %oparray_pop   1820   1   3   %oparray_pop   --nostringval--   %errorexec_pop   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--
Dictionary stack:
   --dict:1179/1684(ro)(G)--   --dict:0/20(G)--   --dict:121/200(L)--
Current allocation mode is local
Last OS error: Invalid argument
Current file position is 9496
GPL Ghostscript 9.15: Unrecoverable error, exit code 1
Ghostscript error: perhaps /private/tmp/tp0576f1d3_2479_440d_ac55_425c20a76e9c.pdf is open by some other application
export_fig error. Please ensure:
  that you are using the latest version of export_fig
  and that you have Ghostscript installed
  and that you have pdftops installed
  and that you do not have multiple versions of export_fig installed by mistake
  and that you did not made a mistake in the expected input arguments

If the problem persists, then please report a new issue.

Error using eps2pdf (line 149)
Error: /undefined in Infinity
Operand stack:
   --nostringval--   560   0   0
Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1
   %stopped_push   1951   1   3   %oparray_pop   1950   1   3   %oparray_pop   --nostringval--   1934   1   3   %oparray_pop   1820   1   3   %oparray_pop   --nostringval--
   %errorexec_pop   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--
Dictionary stack:
   --dict:1188/1684(ro)(G)--   --dict:0/20(G)--   --dict:121/200(L)--
Current allocation mode is local
Last OS error: Invalid argument
Current file position is 9496
GPL Ghostscript 9.15: Unrecoverable error, exit code 1


Error in export_fig (line 512)
                eps2pdf(tmp_nam, pdf_nam, 1, options.append, options.colourspace==2, options.quality, options.gs_options);

Graph is cut into when exported as pdf

Since the update of 2014b the exported figures are cut into which looks like this:

matlab

The command I use is:

export_fig -pdf

Am I the only one experiencing this?
[I also had to reinstall some stuff, ghostscript included, so maybe that's the source of error]

(working on Mac OS X 10.8.5)

bad export of transparent rectangle annotation

Reported by Kai Shi on FEX page on Feb 3, 2015:

I added a rectangle box in the figure and change the transparency of the box to 0.3. However, when I export the figure into latex. The transparency of the box is still 100%. With and without the -transparent option shows the same results. The code of generating the box is shown below:

annotation(hCCs, 'rectangle',rectSize, 'FaceColor','r', 'FaceAlpha',0.3, 'LineStyle','none');

axes grid lines disappear when using -cmyk

I have a figure with a semilogy axis. I enable grid lines and things look good in matlab, but the grid lines do not appear in the exported PDF. I am using the command "export_fig ccdf.pdf -p2 -cmyk -transparent". I've attached an output image (converted to PNG from PDF)---note the lack of grid lines.

Here is a link to my fig file (warning ~20MB): http://cs.unc.edu/~gelliott/ccdf.fig.zip

I am using OS X Yosemite with matlab 2014b.

ccdf

Greek letters in axis title. exporting to pdf.

When exporting figures with Greek letters (only with lowercase Lambda so far) in an axis title to PDF, the Greek letters do not display properly in the resulting PDF. Lowercase Lambda is showing up as the number 6. Using MATLAB 2014b and Ghostscript 9.15.

Plot markers on axis are missing in EPS output (R2014B, win7, GS9.15)

working eps via 'print':
working eps
broken eps via 'export_fig':
broken eps

%steps to reproduce:
x=[ 0 NaN NaN NaN NaN 0.5283 NaN NaN NaN NaN];
y = [ 1 NaN NaN NaN NaN 0 NaN NaN NaN NaN ];
%plot graph which has 2 markers on the axes
figure, plot(x,y,'marker','o')
%generate a working eps file which has markers on the x- and y- axes at the appropriate points
print -depsc2 -r864 -painters working.eps
% export_fig's eps file has no markers shown on the axes.
export_fig broken.eps
%expected behaviour: both EPS files should show 2 points on the graph
%actual behaviour: export_fig's EPS file shows no points on the graph

This occurs under MATLAB R2014 b on windows, 64bit , ghostscript 9.15, using latest export_fig from github.
I think this is related to the bug where objects on axes in 3D plots are not printed:
https://www.mathworks.com/support/bugreports/946762
However this is a 2D plot and "print" on its own works. (Is export_fig converting figures to 3D?)

Error in 2014b with OS X Yosemite

I recently upgraded to 2014b after upgrading to OS X Yosemite. When I try to save a figure, I get the following error:

Error using eps2pdf (line 107)
Error: /undefined in bdef
Operand stack:
   dom   --nostringval--
Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2
   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1
   %stopped_push   1900   1   3   %oparray_pop   1899   1   3   %oparray_pop   1883   1
   3   %oparray_pop   1771   1   3   %oparray_pop   --nostringval--   %errorexec_pop
   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push
   --nostringval--
Dictionary stack:
   --dict:1172/1684(ro)(G)--   --dict:0/20(G)--   --dict:77/200(L)--
Current allocation mode is local
Current file position is 64
GPL Ghostscript 9.07: Unrecoverable error, exit code 1


Error in export_fig (line 433)
        eps2pdf(tmp_nam, pdf_nam, 1, options.append, options.colourspace==2,
        options.quality);

Do you have any ideas about what the problem is? Anyway, thanks for all your great work! I have been using export_fig for quite some time now and find it super duper helpful!!

2014b and area graphs

Hi,

since 2014b area graphs look strange ("striped") when exporting with the default renderer. Opengl works, but creates very large files. (Also the clipping of is different.) Any way out of this?

See example below. /Paul Söderlind

ha = figure;
x = linspace(-pi,pi,101)';
area(x,cos(x),'FaceColor',[1,0.2,0.2]);
title('my title')
ylabel('y')
xlabel('x')
export_fig('-pdf',ha,'areaTest2a.pdf');
export_fig('-pdf','-opengl',ha,'areaTest2b.pdf');

Problem with imagesc when exporting to PDF/EPS

Hello, I am happy and frequent user of export_fig for several years, but I have encountered a problem when exporting figures created using the imagesc command to PDF or EPS (vector graphics). I can reproduce the problem using the following code:

x = 0.025:0.025:(1-0.025);
y = (1:25)_128/3228;
Z = rand(length(y),length(x));
figure
imagesc(x,y,Z)
colormap gray
axis xy
axis([0,1,0,1])
hold on
xx = linspace(0,1,1001);
yy = min(y)_ones(size(xx));
dy = diff(y);
dy = dy(1);
plot(xx,yy+dy/2,'-r')
export_fig('fig.pdf')

The figure in Matlab (attached) is looking as I would expect: the red line is exactly between rows of pixels. But after exporting to PDF (also attached) the red line is no longer between rows of pixels and the bottom row of pixels seems truncated/cropped from below. It seems that the the image has been moved down relative to the red line and truncated/cropped. Any ideas what goes wrong?

Thanks,
Jakob

figure_in_matlab
figure_exported_to_pdf

tex symbols

Hi,
I'm still a bit puzzled how to display tex symbols. For instance, one of my titles is
title('\pi^w')
and is properly displayed in the figure, but not the printed pdf (there, I get a colon to the power of w). I'm using the latest version of texshop 3.49.
Thanks!

Error appending to pdf

When I try to append to a pdf (with code that worked in before upgrade to 2014b) I get the following error (the first plot works, this is for the appended one).

Error using eps2pdf (line 107)
Error: /undefined in definefont
Operand stack:
CMSY10 --dict:14/15(L)-- Font
Execution stack:
%interp_exit .runexec2 --nostringval-- --nostringval-- --nostringval-- 2
%stopped_push --nostringval-- --nostringval-- --nostringval-- false 1
%stopped_push 1951 1 3 %oparray_pop 1950 1 3 %oparray_pop
--nostringval-- 1934 1 3 %oparray_pop 1820 1 3 %oparray_pop
--nostringval-- %errorexec_pop .runexec2 --nostringval-- --nostringval--
--nostringval-- 2 %stopped_push --nostringval-- 1901 2 3 %oparray_pop
Dictionary stack:
--dict:1188/1684(ro)(G)-- --dict:1/20(G)-- --dict:121/200(L)--
Current allocation mode is local
Last OS error: Invalid argument
Current file position is 150864
GPL Ghostscript 9.15: Unrecoverable error, exit code 1

Error in export_fig (line 435)
eps2pdf(tmp_nam, pdf_nam, 1, options.append, options.colourspace==2,
options.quality);

Error in rayToemRealAD (line 469)
export_fig(oemFile, '-pdf', '-append', '-nocrop')

Exporting bold TeX symbols to EPS/PDF in R2014b

Before I upgraded to 2014b, I could save figures with TeX symbols (e.g., \gamma or \beta) in the labels of figures and the output figure would contain the symbols as I expected. However, since I've upgraded to 2014b and then upgraded my export_fig package, I am now getting dots in place of the TeX symbols in the output figure files. Does anyone know why this is happening and how to fix it?

Thanks so much!

Possible problem with '-transparent' option when exporting resized figure in latest version

I've been using your script for years with my same code, no troubles with MATLAB v2009b, but I got a new PC with MATLAB v2012b, and that's when troubles began.
I downloaded the latest version on 11/4/2014. The first error I had went away, but now I have this other error.

First, I am creating a figure and resizing it to fit the screen with the following code:
h=figure;
set(h, 'Position', get(0,'ScreenSize'));

Then, later in my code, I call the export_fig function as such:
export_fig(strcat(dirname,'',sn,fname,'.png'),'-png','-transparent',h);

And, this is the error I receive:

Array dimensions must match for binary array op.

Error in export_fig (line 283)
alpha = round(sum(B - A, 3)) / (255 * 3) + 1;

Error in SavePlotsFnc (line 3)
export_fig(strcat(dirname,'',sn,fname,'.png'),'-png','-transparent',h);

Let me know if you require any additional information.
Thank you in advance for your help.

Using path variable when export_fig?

Is there any way to use path variable when export_fig? Consider this as a feature request if not. Thanks.

To be clear, I want to do like this:

path = sprintf('%s/%03d', folder, idx);
export_fig path -png

Ghostscript error: /rangecheck in definefont

Reported by Jean on Feb 24, 2015:

I have the same issue as James Rankin in Matlab R2014b:

Error using eps2pdf (line 107) 
Error: /rangecheck in definefont 
Operand stack: 
   CMMI10 --dict:14/15(L)-- Font 
Execution stack: 
   %interp_exit .runexec2 --nostringval-- --nostringval-- 
   --nostringval-- 2 %stopped_push --nostringval-- 
   --nostringval-- --nostringval-- false 1 %stopped_push 
   1951 1 3 %oparray_pop 1950 1 3 %oparray_pop 
   --nostringval-- 1934 1 3 %oparray_pop 1820 1 3 
   %oparray_pop --nostringval-- %errorexec_pop .runexec2 
   --nostringval-- --nostringval-- --nostringval-- 2 
   %stopped_push --nostringval-- 1901 2 3 %oparray_pop 
Dictionary stack: 
   --dict:1188/1684(ro)(G)-- --dict:0/20(G)-- --dict:121/200(L)-- 
Current allocation mode is local 
Last OS error: Invalid argument 
Current file position is 90501 
GPL Ghostscript 9.15: Unrecoverable error, exit code 1

Error in export_fig (line 442) 
        eps2pdf(tmp_nam, pdf_nam, 1, options.append, 
        options.colourspace==2, options.quality);

Error in fit_ramsey (line 210) 
export_fig(['fit_' filename], '-pdf');

Unfortunately, his fix is not working for me... It was working well with 2012b, I don't understand, as I am working with standard fonts...

NaN's error when using the -p option

Using either an integer or a percentage with the -p option, getting the following error on r2013b

    NaN's cannot be converted to logicals.

    Error in export_fig>parse_args (line 740)
            if options.bb_padding

    Error in export_fig (line 210)
                    [fig, options] = parse_args(nargout,
                    varargin{:});

Exported figure in PDF too much cropped from original figure

test_figure
Hello,

Thanks a lot for providing your code. My issue could be similar to the one posted in #32. However, unlike the author of that post, my exported figure in PDF is getting too much cropped. That means, the exported PDF figure is somewhat smaller than original .fig or .png file.

I am using Matlab R2014a and latest export_fig code of http://www.mathworks.com/matlabcentral/fileexchange/23629-export-fig

I tried with the following simple code and this issue persisted:

figure(1)
plot(1:100,1:100)
xlabel('Frequency (Hz)')
ylabel('attenuation (Neper/m)')
set(gca,'fontsize',16)
export_fig test -pdf -transparent

Attached figure shows how the exported pdf figure looks like.

Your feedback will be very appreciated.

Thanks,

Nazmul

Feature request: Convert embedded font in PDF to curves

Strange things happen, if the user wants to postprocess a PDF with embedded fonts and the system can not find the right font.

Ghostscript 9.15 supports converting text to curves with
gs -o curves.pdf -dNoOutputFonts -sDEVICE=embedded.pdf

I suggest to add this as option for pdf export.

ps: Thanks a lot for export_fig.

Unable to perform post-processing due to index out of bounds

I pulled the latest version of export_fig today, I get the following warning if I export to pdf or eps:

Warning: Loading EPS file failed, so unable to perform post-processing. This is usually because the figure contains a large number of patch objects. Consider exporting to a bitmap format in this case.
In print2eps at 229
In export_fig at 480

The result is a pdf file with a lot of useless whitespace (probably because of failure of the post-processing). If I step through 'print2eps.m' with the MATLAB Debugger, I get an 'Index exceeds matrix dimensions' error in line 192. Is this a newly introduced bug? I never saw this warning before.

Export_Fig trouble with .eps and 'FaceAlpha'

First off, I love your toolbox and use it constantly. I have recently run into an issue exporting .eps files that have 'FaceAlpha' values. These boxes just seem to disappear and it seems that the title is not lined up. The image exports fine under .jpg.

Here is the .eps file: https://www.dropbox.com/s/dbdr9u8gh69h5x8/Boxes3.eps?dl=0
Here is the .jpg file: https://www.dropbox.com/s/yaxi3b5oto7hzf3/Boxes.jpg?dl=0
Here is the .m file: https://www.dropbox.com/s/wqew64a9h6aufvp/Object_Step_Size_Changes.m?dl=0

All commands in the MATLAB .m file should be native to any version. The only toolbox added is yours.

I tried to add the -painters just in case and it does not seem to make a difference. Also tried print2eps as well as export_fig.

Any help is greatly appreciated.

Best
Corbin

Font issue on Yosemite / Matlab 2014b, 2015a

Hi Oliver,

Thanks for this great cotribution. Export_fig is super important to me. Unfortunately, it seems the font problem is back under Yosemite and Matlab 2014b. I use the newest version of your routines.

I run into problems whenever I try to export a plot that extend to large numbers such that "10^5" or similar is shown on the axis. I hope the example below helps tracking down the problem. Can you please look into this?

Do you know when you can have a look at this? Export_fig is crucial for my work.

Thanks,
Björn

Example:

plot(1,1); export_fig('test.eps',gcf);

---> Works fine

plot(100000,100000); export_fig('test.pdf',gcf);

---> gives the following error message

Error using eps2pdf (line 107)
Error: /undefined in definefont
Operand stack:
CMSY10 --dict:14/15(L)-- Font
Execution stack:
%interp_exit .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push
--nostringval-- --nostringval-- --nostringval-- false 1 %stopped_push 1951 1 3
%oparray_pop 1950 1 3 %oparray_pop --nostringval-- 1934 1 3 %oparray_pop 1820
1 3 %oparray_pop --nostringval-- %errorexec_pop .runexec2 --nostringval--
--nostringval-- --nostringval-- 2 %stopped_push --nostringval-- 1901 2 3
%oparray_pop
Dictionary stack:
--dict:1188/1684(ro)(G)-- --dict:0/20(G)-- --dict:121/200(L)--
Current allocation mode is local
Last OS error: Invalid argument
Current file position is 71147
GPL Ghostscript 9.15: Unrecoverable error, exit code 1

Error in export_fig (line 442)
eps2pdf(tmp_nam, pdf_nam, 1, options.append, options.colourspace==2, options.quality);

Error in savefigure (line 40)
export_fig([filename '.eps'],hfig);

R2014b, ghostscript 9.15, mac

FYI export_fig crashes matlab on Yosemite, gs 9.15, latest export_fig. Similar result for export as png. Simple xy plot with 2 vectors of 62 elements.

pdf export:

load O3data2.mat
plot(O3den,zO3den)
export_fig ~./Desktop/aplot


   Segmentation violation detected at Mon Oct 27 11:15:21 2014

Configuration:
Crash Decoding : Disabled
Current Visual : Quartz
Default Encoding : ISO-8859-1
MATLAB Architecture: maci64
MATLAB Root : /Applications/MATLAB_R2014b.app
MATLAB Version : 8.4.0.150421 (R2014b)
Operating System : Darwin 14.0.0 Darwin Kernel Version 14.0.0: Fri Sep 19 00:26:44 PDT 2014; root:xnu-2782.1.97~2/RELEASE_X86_64 x86_64
Processor ID : x86 Family 6 Model 69 Stepping 1, GenuineIntel
Software OpenGL : 0
Virtual Machine : Java 1.7.0_55-b13 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
Window System : Quartz

Fault Count: 1

Abnormal termination:
Segmentation violation

painters renderer not being recognized

On Matlab r2015a:

Very slow performance (or stuck in loop, not sure, wasn't patient enough) writing a figure to pdf. Looks like it's getting stuck in a while loop in print2eps.m around line 225, as it reads in the entire eps file line by line?

Figure has many lines (about 127 separate lines), looking in the temp folder, the eps file is about 6.6 MB.

I do not experience this issue on r2013b (I guess because of the thin line widths workaround you are doing in >=r2014b).

command:
export_fig(fname,'-pdf','-nocrop');

Attached figure file:
https://dl.dropboxusercontent.com/u/29498615/untitled.fig

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.