Skip to content
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

“Bachelor's degrees…” picture in the gallery is cropped #6668

Closed
2 tasks done
afvincent opened this issue Jun 30, 2016 · 5 comments
Closed
2 tasks done

“Bachelor's degrees…” picture in the gallery is cropped #6668

afvincent opened this issue Jun 30, 2016 · 5 comments
Milestone

Comments

@afvincent
Copy link
Contributor

The showcase picture “bachelors_degrees_by_gender” in the gallery is cropped on the right side : the text labels are cut. It is the case in the 3 exports (PNG, HR PNG and PDF).

I ran the code of the example locally and the output PNG picture in not cropped as in the web gallery : might it be related to the website rather than MPL?

  • Matplotlib version, Python version and Platform (Windows, OSX, Linux ...)
    v1.5.1 and v2.0.0b1.post1628+g1aba7c3, both on Linux (CentOs 7) with Python 2.7.
  • How did you install Matplotlib and Python (pip, anaconda, from source ...)
    anaconda for v1.5.1 and github for v2.x.

NB: with v2.x, even with plt.style.use('default') or plt.style.use('classic'), the x-ticklabels are still formatted with an offset: [-30, -20, -10, 0, 10] + 2e3 instead of [1970, 1980, 1990, 2000, 2010]…

@afvincent afvincent changed the title “Bachelor's degre…” picture in the gallery is cropped “Bachelor's degrees…” picture in the gallery is cropped Jun 30, 2016
@jenshnielsen
Copy link
Member

I'm a bit puzzled by the 2.x issue. On Master http://matplotlib.org/devdocs/examples/showcase/bachelors_degrees_by_gender.html it's much better

@afvincent
Copy link
Contributor Author

afvincent commented Jun 30, 2016

A diff between between the source code in the current gallery and the “devdocs” one returns:

29a30
> fig.subplots_adjust(left=.06, right=.75, bottom=.02, top=.94)
32,33c33,35
< plt.xlim(1968.5, 2011.1)
< plt.ylim(-0.25, 90)
---
> ax.set_xlim(1968.5, 2011.1)
> ax.set_ylim(-0.25, 90)
> ax.get_xaxis().get_major_formatter().set_useOffset(False)
94,95c96,97
< plt.title('Percentage of Bachelor\'s degrees conferred to women in '
<           'the U.S.A. by major (1970-2011)\n', fontsize=18, ha='center')
---
> fig.suptitle('Percentage of Bachelor\'s degrees conferred to women in '
>              'the U.S.A. by major (1970-2011)\n', fontsize=18, ha='center')
100c102
< plt.savefig('percent-bachelors-degrees-women-usa.png', bbox_inches='tight')
---
> # plt.savefig('percent-bachelors-degrees-women-usa.png', bbox_inches='tight')

The x-axis formatter in the new version has been changed to not use an offset text.

Besides the new line fig.subplots_adjust(left=.06, right=.75, bottom=.02, top=.94) seems to prevent the devdocs version from being cropped. Indeed, the code in the current gallery produces (with a v2.x MPL):
current_gallery
⇒ the export (on the right) isn't cropped but the picture in the interactive window (on the left) is (is it not a bit weird btw?). Edit: I failed my screenshot but the interactive windows effectively crops labels on the right side, like “Health Prof…”

While with the code in the devdocs gallery, with the new fig.subplot… line, produces:
devdocs_gallery
where everything seems to be fine, both in the interactive window and the PNG export.

I simply hadn't check in the example source code master repo but apparently @tacaswell already noticed the cropping issue and solve it with f649739.

As the picture in the “devdocs” gallery is OK and should replace in the end the one from the current gallery, I guess I should close this issue, shouldn't I?

@tacaswell tacaswell added this to the 2.0 (style change major release) milestone Jun 30, 2016
@tacaswell
Copy link
Member

The cropping issue is due to the use of bbox_inches='tight' which effectively 'shirk wraps' the figure. I suspect the intention of that feature was to shrink the output by removing whitespace, but it will also increase the size of the figure.

I am a bit concerned that on 2.x the tick labels are still offset.

@WeatherGod
Copy link
Member

The intention of bbox_inches='tight' is to automatically determine the
bounding box that will tightly encompass all of the visible artists by
cropping or growing the figure.

On Thu, Jun 30, 2016 at 8:50 AM, Thomas A Caswell notifications@github.com
wrote:

The cropping issue is due to the use of bbox_inches='tight' which
effectively 'shirk wraps' the figure. I suspect the intention of that
feature was to shrink the output by removing whitespace, but it will also
increase the size of the figure.

I am a bit concerned that on 2.x the tick labels are still offset.


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

@tacaswell
Copy link
Member

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

No branches or pull requests

4 participants