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

Tick vertical alignment#6200

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

Merged
efiring merged 2 commits intomatplotlib:masterfrommdboom:tick-vertical-alignment
Apr 13, 2016

Conversation

mdboom
Copy link
Member

Fixes#2527. Align y-ticks without accounting for descenders

@mdboommdboom added this to the2.0 (style change major release) milestoneMar 21, 2016
@tacaswell
Copy link
Member

Seems to have broken all of the pgf tests.

That makes me a bit worried about other backends that we do not control....

@mdboom
Copy link
MemberAuthor

Sorry -- I have a new box and I think I don't have all the pgf reqs installed yet. I can probably regenerate those.

As for other backends we don't control, I think we'll just be seeing better tick text alignment in all of them -- this approach is delibrately rather narrow and shouldn't affect other kinds of text. But, yes, we will be breaking those other backends image comparison tests, if any.

@tacaswell
Copy link
Member

======================================================================ERROR:matplotlib.tests.test_backend_pgf.test_bbox_inches----------------------------------------------------------------------Traceback (mostrecentcalllast):File"/home/travis/build/matplotlib/matplotlib/venv/lib/python3.5/site-packages/nose/case.py",line198,inrunTestself.test(*self.arg)File"/home/travis/build/matplotlib/matplotlib/lib/matplotlib/testing/decorators.py",line422,inbackend_switcherresult=func(*args,**kwargs)File"/home/travis/build/matplotlib/matplotlib/lib/matplotlib/tests/test_backend_pgf.py",line193,intest_bbox_inchestol=0)File"/home/travis/build/matplotlib/matplotlib/lib/matplotlib/tests/test_backend_pgf.py",line46,incompare_figureplt.savefig(actual,**savefig_kwargs)File"/home/travis/build/matplotlib/matplotlib/lib/matplotlib/pyplot.py",line686,insavefigres=fig.savefig(*args,**kwargs)File"/home/travis/build/matplotlib/matplotlib/lib/matplotlib/figure.py",line1666,insavefigself.canvas.print_figure(*args,**kwargs)File"/home/travis/build/matplotlib/matplotlib/lib/matplotlib/backend_bases.py",line2232,inprint_figure**kwargs)File"/home/travis/build/matplotlib/matplotlib/lib/matplotlib/backends/backend_pgf.py",line894,inprint_pdfself._print_pdf_to_fh(fh,*args,**kwargs)File"/home/travis/build/matplotlib/matplotlib/lib/matplotlib/backends/backend_pgf.py",line848,in_print_pdf_to_fhself.print_pgf(fname_pgf,*args,**kwargs)File"/home/travis/build/matplotlib/matplotlib/lib/matplotlib/backends/backend_pgf.py",line830,inprint_pgfself._print_pgf_to_fh(fh,*args,**kwargs)File"/home/travis/build/matplotlib/matplotlib/lib/matplotlib/backends/backend_pgf.py",line811,in_print_pgf_to_fhself.figure.draw(renderer)File"/home/travis/build/matplotlib/matplotlib/lib/matplotlib/artist.py",line63,indraw_wrapperdraw(artist,renderer,*args,**kwargs)File"/home/travis/build/matplotlib/matplotlib/lib/matplotlib/figure.py",line1262,indrawrenderer,self,dsu,self.suppressComposite)File"/home/travis/build/matplotlib/matplotlib/lib/matplotlib/image.py",line139,in_draw_list_compositing_imagesa.draw(renderer)File"/home/travis/build/matplotlib/matplotlib/lib/matplotlib/artist.py",line63,indraw_wrapperdraw(artist,renderer,*args,**kwargs)File"/home/travis/build/matplotlib/matplotlib/lib/matplotlib/axes/_base.py",line2355,indrawmimage._draw_list_compositing_images(renderer,self,dsu)File"/home/travis/build/matplotlib/matplotlib/lib/matplotlib/image.py",line139,in_draw_list_compositing_imagesa.draw(renderer)File"/home/travis/build/matplotlib/matplotlib/lib/matplotlib/artist.py",line63,indraw_wrapperdraw(artist,renderer,*args,**kwargs)File"/home/travis/build/matplotlib/matplotlib/lib/matplotlib/axis.py",line1133,indrawtick.draw(renderer)File"/home/travis/build/matplotlib/matplotlib/lib/matplotlib/artist.py",line63,indraw_wrapperdraw(artist,renderer,*args,**kwargs)File"/home/travis/build/matplotlib/matplotlib/lib/matplotlib/axis.py",line268,indrawself.label1.draw(renderer)File"/home/travis/build/matplotlib/matplotlib/lib/matplotlib/artist.py",line63,indraw_wrapperdraw(artist,renderer,*args,**kwargs)File"/home/travis/build/matplotlib/matplotlib/lib/matplotlib/text.py",line800,indrawismath=ismath,mtext=mtext)File"/home/travis/build/matplotlib/matplotlib/lib/matplotlib/backends/backend_pgf.py",line667,indraw_texttext_args.append(valign[mtext.get_va()])KeyError:'center_baseline'

This looks like the render is breaking.

@mdboom
Copy link
MemberAuthor

Oh, and I should have read the error message first. It seems that PGF, unlike all other backends in the core, handles the text alignment itself -- or, more specifically, delgates it to the TeX engine. That seems like a corner case to me that most third-party backends won't face, but point taken that it could break them. However, we are bumping the major version number for the first time in years, if not now, when? :)

@tacaswell
Copy link
Member

fair point.

@tacaswell
Copy link
Member

I am 👍 on this, but given how many tests it touches someone else should agree as well.

@@ -436,6 +436,8 @@ def _get_layout(self, renderer):
offsety = (ymin + height)
elif valign == 'baseline':
offsety = (ymin + height) - baseline
elif valign == 'center_baseline':
offsety = (ymin + (height + (height - baseline)) / 2.0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

In other words,ymin + height - baseline / 2. This is the same as 'top' minusbaseline / 2 which makes sense, since baseline is the height starting from the baseline rather than the descender. Right?

@efiring
Copy link
Member

I think it is OK. The relevant part of the text code was already not so easy to understand, so I made a couple of suggestions for comments and simplification. I don't understand why the anchored rotation case is handled as it is.

@mdboom
Copy link
MemberAuthor

I've hopefully addressed@efiring's comments.

@tacaswell
Copy link
Member

@mdboom Now you get to rebase this one 👿

@mdboommdboomforce-pushed thetick-vertical-alignment branch from7293734 to697d8e1CompareApril 11, 2016 22:29
@mdboom
Copy link
MemberAuthor

Rebased.

@mdboom
Copy link
MemberAuthor

I'll need to rerun tests and squash -- stay tuned...

@mdboommdboomforce-pushed thetick-vertical-alignment branch 3 times, most recently fromc967de5 to7e4d26aCompareApril 12, 2016 12:50
@mdboommdboomforce-pushed thetick-vertical-alignment branch fromc434aa1 tof9d695cCompareApril 12, 2016 13:08
@mdboom
Copy link
MemberAuthor

Passsing the tests! Let's merge this before I have to rebase and rebuild all the tests again :)

@efiringefiring merged commit6b22bfc intomatplotlib:masterApr 13, 2016
@mdboom
Copy link
MemberAuthor

I'm backporting this to 2.x now, but there's some conflicts, so it might take a while...

mdboom pushed a commit to mdboom/matplotlib that referenced this pull requestApr 13, 2016
@mdboom
Copy link
MemberAuthor

Backported to 2.x as5fb9d9e

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

Successfully merging this pull request may close these issues.

3 participants
@mdboom@tacaswell@efiring

[8]ページ先頭

©2009-2025 Movatter.jp