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

Despined figure is cropped #6084

Closed
Phyks opened this issue Mar 1, 2016 · 6 comments
Closed

Despined figure is cropped #6084

Phyks opened this issue Mar 1, 2016 · 6 comments

Comments

@Phyks
Copy link

Phyks commented Mar 1, 2016

Hi,

When removing frame from a figure (as seaborn use to do for instance), the figure is cropped at extrema (see below).

  • Matplotlib version: 1.5.1
  • How did you install Matplotlib and Python (pip, anaconda, from source ...) : pip
  • SSCE:

Note that I increased the linewidth just to enhance the effect and that it could be well noticed. However, there is a similar issue with the default linewidth.

import matplotlib.pyplot as plt
import numpy as np

x = np.linspace(-10, 10, 10000)
fig, ax = plt.subplots()
ax.plot(x, [np.sin(i) for i in x], linewidth=3)
ax.axis('off')
fig.show()
  • If this is an image generation bug attach a screenshot demonstrating the issue.

2016-03-01-103743

Thanks

@WeatherGod
Copy link
Member

Sigh... I think this is more of an issue with ipython notebooks than
anything else. By default, they do bbox_inches='tight' for their figures,
which will effectively crop to only what is visible. What makes this looks
bad, in my opinion is that the tight bbox doesn't take into account the
width of the line, so it makes the cropping very apparent. Most of the
time, line widths are 1, so we don't really notice it. Not entirely sure it
is a bug, though.

On Tue, Mar 1, 2016 at 4:39 AM, Lucas Verney notifications@github.com
wrote:

Hi,

When removing frame from a figure (as seaborn use to do for instance),
the figure is cropped at extrema (see below).

  • Matplotlib version, Python version and Platform (Windows, OSX, Linux
    ...) : 1.5.1
  • How did you install Matplotlib and Python (pip, anaconda, from
    source ...) : pip
  • If possible please supply a Short, Self Contained, Correct, Example
    http://sscce.org/ that demonstrates the issue i.e a small piece of
    code which reproduces the issue and can be run with out any other (or as
    few as possible) external dependencies. Note that I increased the linewidth
    just to enhance the effect and that it could be well noticed. However,
    there is a similar issue with the default linewidth.

import matplotlib.pyplot as pltimport numpy as np

x = np.linspace(-10, 10, 10000)
fig, ax = plt.subplots()
ax.plot(x, [np.sin(i) for i in x], linewidth=3)
ax.axis('off')
fig.show()

If this is an image generation bug attach a screenshot demonstrating
the issue.
[image: 2016-03-01-103743]
https://cloud.githubusercontent.com/assets/3856586/13423167/a5fafcb6-df99-11e5-8f06-7ba7216ef1f6.png

If this is a regression (Used to work in an earlier version of
Matplotlib), please
note where it used to work.

Thanks


Reply to this email directly or view it on GitHub
#6084.

@Phyks
Copy link
Author

Phyks commented Mar 1, 2016

@WeatherGod Just to be sure, I ran it in the above code in a Python shell, and got same result. It seems to be independant of ipython notebooks.

Screenshot:
2016-03-01-155925

Savefig result:
3

@jenshnielsen
Copy link
Member

@WeatherGod The original example is in the notebook/nbagg backend. The bbox_inches='tight' issue only applies to the inline backend

@WeatherGod
Copy link
Member

Ok, so, I think the whole despining aspect of this is a red herring. The
line isn't getting cropped by accident. It is cropped because it is at the
view limits of the axes, I believe. I am not sure there is a bug here at
all, as this is the intended behavior.

On Tue, Mar 1, 2016 at 10:13 AM, Jens Hedegaard Nielsen <
notifications@github.com> wrote:

@WeatherGod https://github.com/WeatherGod The original example is in
the notebook/nbagg backend. The bbox_inches='tight' issue only applies to
the inline backend


Reply to this email directly or view it on GitHub
#6084 (comment)
.

@tacaswell
Copy link
Member

This is intended behavior, the line is clipped at the axes boundaries If you want to disable clipping on the line use

ln.set_clip_on(False)

@Phyks
Copy link
Author

Phyks commented Mar 1, 2016

@tacaswell Ok, I was not sure it was intended behaviour. Disabling line clipping works though, I just have to not forget to call it :)

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