Skip to content

Prevent image outputs from being wider than their container. - #7721

Merged
jdfreder merged 2 commits into
ipython:masterfrom
jdfreder:widecontents2
Feb 12, 2015
Merged

jdfreder merged 2 commits into
ipython:masterfrom
jdfreder:widecontents2

Conversation

@jdfreder

@jdfreder jdfreder commented Feb 9, 2015

Copy link
Copy Markdown
Contributor

closes #7701
alternative to #7718

@takluyver

@takluyver

Copy link
Copy Markdown
Member

Does this work? It seems like a nicer solution than scrollbars if it works, but I don't know our CSS well enough to know if it makes sense.

@jdfreder

jdfreder commented Feb 9, 2015

Copy link
Copy Markdown
Contributor Author

Does this work? It seems like a nicer solution than scrollbars if it works, but I don't know our CSS well enough to know if it makes sense.

Yes it works. I too think this is a better solution. We can wait and see if someone else wants to weigh in before closing the other PR.

@jdfreder

Copy link
Copy Markdown
Contributor Author

TODO: Test with ctrl-p print.

@minrk

minrk commented Feb 11, 2015

Copy link
Copy Markdown
Member

👍 once you've checked print output

@jdfreder

Copy link
Copy Markdown
Contributor Author

Checked and it works with print output.

jdfreder added a commit that referenced this pull request Feb 12, 2015
Prevent image outputs from being wider than their container.
@jdfreder
jdfreder merged commit 0fc9bb0 into ipython:master Feb 12, 2015
@jdfreder

Copy link
Copy Markdown
Contributor Author

@erccarls and @Carreau see #7718 which was an alternative to this PR. It may be a better fit.

@takluyver

Copy link
Copy Markdown
Member

There are two distinct concerns with this

  1. It can distort the aspect ratio. I hope this can just be fixed somehow.
  2. In some circumstances, people may prefer a wider, scrollable area. I think this depends whether you're deliberately plotting something large, as @erccarls is, or whether you've accidentally created an image larger than the pixel width of the notebook, as was the case in Image overflow in IPython Notebook 3 (beta) #7701. The latter is very easy to do, since the notebook isn't a fixed width, and I think in that case it's far nicer UI to resize the image than to cut it off and show a scrollbar.

@jdfreder

Copy link
Copy Markdown
Contributor Author

Well, shall we revert this merge and try #7718 ?

@takluyver

Copy link
Copy Markdown
Member

I think this solution (assuming the aspect ratio thing can be fixed) is greatly preferable if you unintentionally make an image larger than the notebook div (which is easy to do). Cutting off the right hand edge and showing a scrollbar is horrible UI in that case.

Perhaps we can tie this in with the collapse/expand behaviour for when there's lots of output? i.e. initially display the image resized to fit within the notebook, and when you click something, it expands to the image's 100% size in a scrollable div.

@jdfreder

Copy link
Copy Markdown
Contributor Author

That doesn't solve the problem of "I want my figure to be larger than the page area."

@jdfreder

Copy link
Copy Markdown
Contributor Author

Perhaps we can tie this in with the collapse/expand behaviour for when there's lots of output? i.e. initially display the image resized to fit within the notebook, and when you click something, it expands to the image's 100% size in a scrollable div.

That could work, but I think that's not as simple of a solution, which is unfortunate.

@takluyver

Copy link
Copy Markdown
Member

I think we've identified two different use cases (deliberately big images vs accidentally big images), so anything which tries to cater to both probably won't be as simple as when we were only thinking about one of them.

@minrk

minrk commented Feb 19, 2015

Copy link
Copy Markdown
Member

We could also revert the patch, and let images be the size they are. It can result in less than pretty output, but at least images are always displayed at the requested size.

@takluyver

Copy link
Copy Markdown
Member

Yeah, I've just realised that that is actually what happens in 2.x (screenshots in #7701 made me think that this PR was effectively fixing a regression from 2.x, but I was wrong).

@minrk

minrk commented Feb 19, 2015

Copy link
Copy Markdown
Member

+1 from me to restoring 2.x behavior, then.

@takluyver

Copy link
Copy Markdown
Member

#7818 reverts this.

@erccarls

Copy link
Copy Markdown

Admittedly, my use case (deliberately large) is rarer than the other. Could you add UI to expand the picture to actual size? Like clicking or double clicking the image? Otherwise, maybe one could make this a notebook config setting.

minrk added a commit that referenced this pull request Mar 28, 2015
A scrollbar will appear when the output is too wide.

closes #7701
alternative to #7721
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Image overflow in IPython Notebook 3 (beta)

5 participants