Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Make PDF backend work when usetex is True #628

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 5, 2012

Conversation

mdboom
Copy link
Member

@mdboom mdboom commented Dec 14, 2011

Some parts of the PDF backend related to usetex did not get converted to the new Python 3 way.

@Carreau
Copy link
Contributor

Carreau commented Dec 14, 2011

@mdboom,
Thanks for linking me to it from #626, I can't take a look/test right know but will try.
don't hesitate to ping me if you wan't some test.

@jkseppan
Copy link
Member

Looks good to me, too busy to run any tests.

@Carreau
Copy link
Contributor

Carreau commented Dec 15, 2011

seem to work for me, but only on basics example.
I've a complex figure which raise at least 2 errors :

/usr/local/Cellar/python/2.7.2/lib/python2.7/site-packages/matplotlib-1.2.x-py2.7-macosx-10.4-x86_64.egg/matplotlib/type1font.pyc in transform(self, effects)
    305                                            slant=effects.get('slant', 0.0),
    306                                            extend=effects.get('extend', 1.0)):
--> 307                 buffer.write(value)
    308             result = buffer.getvalue()
    309         finally:

TypeError: string argument expected, got 'str'
/usr/local/Cellar/python/2.7.2/lib/python2.7/site-packages/matplotlib-1.2.x-py2.7-macosx-10.4-x86_64.egg/matplotlib/backend_bases.pyc in print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, **kwargs)
   1955         format = format.lower()
   1956 
-> 1957         print_method = self._get_print_method(format)
   1958 
   1959         if dpi is None:

/usr/local/Cellar/python/2.7.2/lib/python2.7/site-packages/matplotlib-1.2.x-py2.7-macosx-10.4-x86_64.egg/matplotlib/backend_bases.pyc in _get_print_method(self, format)
   1895                 'Format "%s" is not supported.\n'
   1896                 'Supported formats: '
-> 1897                 '%s.' % (format, ', '.join(formats)))
   1898 
   1899         return getattr(self, method_name)

ValueError: Format "png" is not supported.
Supported formats: pdf.

(I'm not asking for png anywhere)

...also in stderr

ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (73, 0))

I wont past the whole code which is really long and need 300Mb of data to work as is, but I'll try to make a working minimal example.
works with eps.

@Carreau
Copy link
Contributor

Carreau commented Dec 15, 2011

Minimum working example,
seem to be a combinaison of usetex , some font like Times (Palatino/Stix behave allright) and some latex caracter (\alpha, \phi,\varphi) crash, not \int , x
As it is on mac, I thought of dfont/ttf/otf but it seem not to be it.

rcParams['font.serif']='Times'
rcParams['text.usetex']=True
fig=figure(1)
xlabel(r'$\alpha$')
savefig('test.pdf')  #, bbox_inches='tight' );#value error due to bbox=tight, but only on IPythonNotebook

putting buffer.write(unicode(value)) seem to work

@efiring
Copy link
Member

efiring commented Jan 1, 2012

I can reproduce the error with that example on linux, python 2.7.1 (ubuntu 11.04).

@mdboom
Copy link
Member Author

mdboom commented Jan 3, 2012

I have updated this pull request to hopefully fix this issue. @Carreau, @efiring: can you please test?

@Carreau
Copy link
Contributor

Carreau commented Jan 3, 2012

Seem to work for me. Thanks.
Question : Is there any way to get, at run time, the sha of the commit used to build matplotlib ?

--
Matthias
(PS: And Happy new year)

@leejjoon
Copy link
Contributor

leejjoon commented Jan 5, 2012

I also tested this PR and it worked fine. Please go ahead and merge it.

mdboom added a commit that referenced this pull request Jan 5, 2012
Make PDF backend work when usetex is True
@mdboom mdboom merged commit beb4821 into matplotlib:master Jan 5, 2012
@mdboom mdboom deleted the pdf-usetex-crash branch March 3, 2015 18:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants