Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

BUG: % crashes saving figure with tex enabled#6886

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed

Conversation

madphysicist
Copy link
Contributor

This PR changes the default symbol used bympl.ticker.PercentFormatter ifmpl.rcParams['text.usetex'] == True. There is room for improvement, as evidenced by this question:http://stackoverflow.com/q/38731201/2988730.

Tests coming soon.

@Kojoley
Copy link
Member

I cannot reproducesavefig crash, but you have found a more deeper problem.% in latex is used for comments, so withusetex=True it should not crash, but percent symbol would not appear too; and the issue is not only inPercentFormatter, but in the test suite too.


usetex=True image

usetex=False image

importmatplotlibimportmatplotlib.pyplotaspltfrommatplotlib.tickerimportPercentFormattermatplotlib.rc('text',usetex=True)x,y= [1,2,3], [64,128,256]fig,ax=plt.subplots()ax.yaxis.set_major_formatter(PercentFormatter(xmax=512))ax.bar(x,y)fig.suptitle('usetex=True')#fig.savefig('test_usetex-percentformatter.png')plt.show()

@tacaswelltacaswell added this to the2.1 (next point release) milestoneSep 8, 2016
@WeatherGod
Copy link
Member

I could have sworn we have code that escapes all percent signs before
passing to latex, don't we?

On Thu, Sep 8, 2016 at 11:15 AM, Nikita Kniazevnotifications@github.com
wrote:

I cannot reproduce savefig crash, but you have found a more deeper
problem. % in latex is used for comments, so with usetex=True it should
not crash, but percent symbol would not appear too; and the issue is not

only in PercentFormatter, but in the test suite too.

[image: usetex=True image]
https://cloud.githubusercontent.com/assets/2743474/18354317/c0d5b2b6-75ed-11e6-9318-bfd73847074b.png

[image: usetex=False image]
https://cloud.githubusercontent.com/assets/2743474/18354341/d409b8b4-75ed-11e6-8b8f-b5a56acde7c6.png

import matplotlibimport matplotlib.pyplot as pltfrom matplotlib.ticker import PercentFormatter

matplotlib.rc('text', usetex=True)

x, y = [1, 2, 3], [64, 128, 256]

fig, ax = plt.subplots()
ax.yaxis.set_major_formatter(PercentFormatter(xmax=512))
ax.bar(x, y)
fig.suptitle('usetex=True')#fig.savefig('test_usetex-percentformatter.png')
plt.show()


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#6886 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AARy-ISVRGajISmHkAQurd9rx_-ScCZ1ks5qoCapgaJpZM4JbGY7
.

@madphysicist
Copy link
ContributorAuthor

Nope. As my SO question states, I can't even find a list of characters that need to be escaped anywhere in matplotlib.

@madphysicist
Copy link
ContributorAuthor

@Kojoley The savefig issue is caused by the version of LaTeX on my machine, which barfs on non-escaped percent symbols. It is basically the exact same issue you are having, but with a different backend.

Another problem here is that symbols should not be escaped in__init__ but rather in__call__. In theory, the value ofrcParams['text.usetex'] can change between those two calls. Either way, we probably need a latex-escaping routine somewhere.

In the meantime, you can always pass in your own custom symbol (liker'\%') if you are planning on usingPercentFormatter on a latex-enabled axis.

@Kojoley
Copy link
Member

I could have sworn we have code that escapes all percent signs before
passing to latex, don't we?

I have crawled all the way with a debugger and there was onlyfix_minus call related to escaping.
image

Here you can see a rendering cache.PercentFormatter strings are not escaped.

@madphysicist
Copy link
ContributorAuthor

This PR has been superseded and significantly improved on by#7965. Closing.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Projects
None yet
Milestone
v2.1
Development

Successfully merging this pull request may close these issues.

6 participants
@madphysicist@Kojoley@WeatherGod@mdboom@tacaswell@QuLogic

[8]ページ先頭

©2009-2025 Movatter.jp