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

Fix tutorial pyplot scales (issue #6775)#6779

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

Conversation

afvincent
Copy link
Contributor

Fix#6775.

The issue reports among other things a poor choice of x-ticks. However, this seems to be OK in the devdocs version (http://matplotlib.org/devdocs/users/pyplot_tutorial.html)

I suppressed the minor y tick labels in the case of the logit scale, to keep only the major ones. To do so, I used aNullFormatter:is it OK for a pyplot tutorial? First I wanted to simply useplt.minorticks_off but it hides the nice feature of the logit scale, which is to be log in some range and linear in another range.

Furthermore, I slightly tweaked thelinthreshy value in the case of the symlog case, to avoid overlapping some of the y tick labels.

The current PR should produce things similar to
example_with_plt_subplots_adjust
I precise “similar” because depending on the random samples, the tick range of the axes may be different.

PS: I got weird crashes when trying to useplt.tight_layout to adjust the subplots. I'll see if it comes from my machine or is a real issue, and I will open report another issue in the latter case. And for the moment, I have simply defined by hand some correct values inplt.subplots_adjust.

@afvincent
Copy link
ContributorAuthor

Definitively, if I remove theplt.subplots_adjust and try to rely onplt.tight_layout instead, I get this traceback (with Python 2.7 in a conda env, Linux, mpl 2.0.0b3.post1796+gd527799):

QGtkStyle could not resolve GTK. Make sure you have installed the proper libraries./home/adrien/matplotlib/lib/matplotlib/transforms.py:380: RuntimeWarning: invalid value encountered in double_scalars  return points[1, 0] - points[0, 0]/home/adrien/matplotlib/lib/matplotlib/tight_layout.py:199: RuntimeWarning: invalid value encountered in double_scalars  kwargs["wspace"] = hspace / h_axes/home/adrien/matplotlib/lib/matplotlib/axis.py:1008: UserWarning: Unable to find pixel distance along axis for interval padding of ticks; assuming no interval padding needed.  warnings.warn("Unable to find pixel distance along axis "/home/adrien/matplotlib/lib/matplotlib/axis.py:1018: UserWarning: Unable to find pixel distance along axis for interval padding of ticks; assuming no interval padding needed.  warnings.warn("Unable to find pixel distance along axis "Traceback (most recent call last):  File "/home/adrien/matplotlib/lib/matplotlib/backends/backend_qt5agg.py", line 182, in __draw_idle_agg    FigureCanvasAgg.draw(self)  File "/home/adrien/matplotlib/lib/matplotlib/backends/backend_agg.py", line 464, in draw    self.figure.draw(self.renderer)  File "/home/adrien/matplotlib/lib/matplotlib/artist.py", line 68, in draw_wrapper    return draw(artist, renderer, *args, **kwargs)  File "/home/adrien/matplotlib/lib/matplotlib/figure.py", line 1262, in draw    renderer, self, dsu, self.suppressComposite)  File "/home/adrien/matplotlib/lib/matplotlib/image.py", line 139, in _draw_list_compositing_images    a.draw(renderer)  File "/home/adrien/matplotlib/lib/matplotlib/artist.py", line 68, in draw_wrapper    return draw(artist, renderer, *args, **kwargs)  File "/home/adrien/matplotlib/lib/matplotlib/axes/_base.py", line 2383, in draw    mimage._draw_list_compositing_images(renderer, self, dsu)  File "/home/adrien/matplotlib/lib/matplotlib/image.py", line 139, in _draw_list_compositing_images    a.draw(renderer)  File "/home/adrien/matplotlib/lib/matplotlib/artist.py", line 68, in draw_wrapper    return draw(artist, renderer, *args, **kwargs)  File "/home/adrien/matplotlib/lib/matplotlib/axis.py", line 1109, in draw    ticks_to_draw = self._update_ticks(renderer)  File "/home/adrien/matplotlib/lib/matplotlib/axis.py", line 942, in _update_ticks    tick_tups = [t for t in self.iter_ticks()]  File "/home/adrien/matplotlib/lib/matplotlib/axis.py", line 885, in iter_ticks    majorLocs = self.major.locator()  File "/home/adrien/matplotlib/lib/matplotlib/ticker.py", line 1721, in __call__    return self.tick_values(vmin, vmax)  File "/home/adrien/matplotlib/lib/matplotlib/ticker.py", line 1726, in tick_values    locs = self._raw_ticks(vmin, vmax)  File "/home/adrien/matplotlib/lib/matplotlib/ticker.py", line 1674, in _raw_ticks    nbins = max(min(self.axis.get_tick_space(), 9),  File "/home/adrien/matplotlib/lib/matplotlib/axis.py", line 2008, in get_tick_space    return int(np.floor(length / size))ValueError: cannot convert float NaN to integer

I don't understand everything, but it looks likeplt.tight_layout has difficulties to place some ticks.

@jenshnielsen
Copy link
Member

Looks good. I think the tight_layout issue is something that we should investigate further. Will you create an issue for that so we can merge this without it?

@tacaswelltacaswell added this to the2.0 (style change major release) milestoneJul 17, 2016
@tacaswelltacaswell merged commita4fdd60 intomatplotlib:masterJul 18, 2016
tacaswell added a commit that referenced this pull requestJul 18, 2016
@tacaswell
Copy link
Member

tacaswell commentedJul 18, 2016
edited by QuLogic
Loading

backported to v2.x ase2b1184

@afvincent
Copy link
ContributorAuthor

@jenshnielsen I've just created a dedicated issue (#6789) as you suggested.

@jenshnielsen
Copy link
Member

Thanks@afvincent thats great and a very detailed issue :)

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.0.0
Development

Successfully merging this pull request may close these issues.

5 participants
@afvincent@jenshnielsen@tacaswell@mdboom@QuLogic

[8]ページ先頭

©2009-2025 Movatter.jp