This page was generated from
doc/gallery/multiple-outputs.ipynb.
Interactive online version:
.
Download notebook.
Choosing from Multiple Outputs¶
By default, the last output of the selected cell is used as a thumbnail. If that’s what you want, you can simply use the nbsphinx-thumbnail cell tag.
If you want to specify one of multiple outputs, you can add a (zero-based) "output-index" to your "nbsphinx-thumbnail" cell metadata.
The following cell has this metadata, selecting the third output to be used as thumbnail in the gallery.
{
"nbsphinx-thumbnail": {
"output-index": 2
}
}
[1]:
from IPython.display import Image
display(Image(url='https://jupyter.org/assets/homepage/main-logo.svg'))
print('Hello!')
display(Image(filename='../images/notebook_icon.png'))
display(Image(url='https://www.python.org/static/img/python-logo-large.png', embed=True))
Hello!
---------------------------------------------------------------------------
gaierror Traceback (most recent call last)
File /usr/lib64/python3.15/urllib/request.py:1323, in AbstractHTTPHandler.do_open(self, http_class, req, **http_conn_args)
1322 try:
-> 1323 h.request(req.get_method(), req.selector, req.data, headers,
1324 encode_chunked=req.has_header('Transfer-encoding'))
1325 except OSError as err: # timeout error
File /usr/lib64/python3.15/http/client.py:1371, in HTTPConnection.request(self, method, url, body, headers, encode_chunked)
1370 """Send a complete request to the server."""
-> 1371 self._send_request(method, url, body, headers, encode_chunked)
File /usr/lib64/python3.15/http/client.py:1417, in HTTPConnection._send_request(self, method, url, body, headers, encode_chunked)
1416 body = _encode(body, 'body')
-> 1417 self.endheaders(body, encode_chunked=encode_chunked)
File /usr/lib64/python3.15/http/client.py:1366, in HTTPConnection.endheaders(self, message_body, encode_chunked)
1365 raise CannotSendHeader()
-> 1366 self._send_output(message_body, encode_chunked=encode_chunked)
File /usr/lib64/python3.15/http/client.py:1126, in HTTPConnection._send_output(self, message_body, encode_chunked)
1125 del self._buffer[:]
-> 1126 self.send(msg)
1128 if message_body is not None:
1129
1130 # create a consistent interface to message_body
File /usr/lib64/python3.15/http/client.py:1070, in HTTPConnection.send(self, data)
1069 if self.auto_open:
-> 1070 self.connect()
1071 else:
File /usr/lib64/python3.15/http/client.py:1509, in HTTPSConnection.connect(self)
1507 "Connect to a host on a given (SSL) port."
-> 1509 super().connect()
1511 if self._tunnel_host:
File /usr/lib64/python3.15/http/client.py:1036, in HTTPConnection.connect(self)
1035 sys.audit("http.client.connect", self, self.host, self.port)
-> 1036 self.sock = self._create_connection(
1037 (self.host,self.port), self.timeout, self.source_address)
1038 # Might fail in OSs that don't implement TCP_NODELAY
File /usr/lib64/python3.15/socket.py:859, in create_connection(address, timeout, source_address, all_errors)
858 exceptions = []
--> 859 for res in getaddrinfo(host, port, 0, SOCK_STREAM):
860 af, socktype, proto, canonname, sa = res
File /usr/lib64/python3.15/socket.py:996, in getaddrinfo(host, port, family, type, proto, flags)
995 addrlist = []
--> 996 for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
997 af, socktype, proto, canonname, sa = res
gaierror: [Errno -3] Temporary failure in name resolution
During handling of the above exception, another exception occurred:
URLError Traceback (most recent call last)
Cell In[1], line 6
2
3 display(Image(url='https://jupyter.org/assets/homepage/main-logo.svg'))
4 print('Hello!')
5 display(Image(filename='../images/notebook_icon.png'))
----> 6 display(Image(url='https://www.python.org/static/img/python-logo-large.png', embed=True))
File /usr/lib64/python3.15/urllib/request.py:187, in urlopen(url, data, timeout, context)
185 else:
186 opener = _opener
--> 187 return opener.open(url, data, timeout)
File /usr/lib64/python3.15/urllib/request.py:489, in OpenerDirector.open(self, fullurl, data, timeout)
486 req = meth(req)
488 sys.audit('urllib.Request', req.full_url, req.data, req.headers, req.get_method())
--> 489 response = self._open(req, data)
491 # post-process response
492 meth_name = protocol+"_response"
File /usr/lib64/python3.15/urllib/request.py:506, in OpenerDirector._open(self, req, data)
503 return result
505 protocol = req.type
--> 506 result = self._call_chain(self.handle_open, protocol, protocol +
507 '_open', req)
508 if result:
509 return result
File /usr/lib64/python3.15/urllib/request.py:466, in OpenerDirector._call_chain(self, chain, kind, meth_name, *args)
464 for handler in handlers:
465 func = getattr(handler, meth_name)
--> 466 result = func(*args)
467 if result is not None:
468 return result
File /usr/lib64/python3.15/urllib/request.py:1371, in HTTPSHandler.https_open(self, req)
1370 def https_open(self, req):
-> 1371 return self.do_open(http.client.HTTPSConnection, req,
1372 context=self._context)
File /usr/lib64/python3.15/urllib/request.py:1326, in AbstractHTTPHandler.do_open(self, http_class, req, **http_conn_args)
1323 h.request(req.get_method(), req.selector, req.data, headers,
1324 encode_chunked=req.has_header('Transfer-encoding'))
1325 except OSError as err: # timeout error
-> 1326 raise URLError(err)
1327 r = h.getresponse()
1328 except:
URLError: <urlopen error [Errno -3] Temporary failure in name resolution>