import nglview as nv
view = nv.show_structure_file(nv.datafiles.PDB)
view
A Jupyter Widget
# Clear all representations to try new ones
view.clear_representations()
# add licorice without hydrogen
view.add_licorice('not hydrogen')
# add licorice without hydrogen and use 'blue' for color
view.clear_representations()
view.add_licorice('not hydrogen', color='blue')
# add surface for CA atoms
view.clear_representations()
view.add_surface('.CA', opacity=0.3)
# combine different representations
view.clear_representations()
view.add_surface('.CA', opacity=0.3)
view.add_licorice('not hydrogen')
# change to cartoon representation to have nicer view
view.clear_representations()
view.add_cartoon()
view.add_surface(opacity=0.3)
# make sure to call render_image in seperate cell
view.render_image()
# then call _display_image
# If you save this notebook to html file, you will see the display image
view._display_image()