pygmt.set_display

pygmt.set_display(method=None)[source]

Set the display method when calling pygmt.Figure.show.

Parameters:

method (str or None) –

The method to display an image preview. Choose from:

  • "external": External PDF preview using the default PDF viewer

  • "notebook": Inline PNG preview in the current notebook

  • "none": Disable image preview

  • None: Reset to the default display method

The default display method is "external" in Python consoles or "notebook" in Jupyter notebooks.

Examples

Let’s assume that you’re using a Jupyter Notebook:

>>> import pygmt
>>> fig = pygmt.Figure()
>>> fig.basemap(region=[0, 10, 0, 10], projection="X10c/5c", frame=True)
>>> fig.show()  # will display a PNG image in the current notebook
>>>
>>> # set the display method to "external"
>>> pygmt.set_display(method="external")  
>>> fig.show()  # will display a PDF image using the default PDF viewer
>>>
>>> # set the display method to "none"
>>> pygmt.set_display(method="none")
>>> fig.show()  # will not show any image
>>>
>>> # reset to the default display method
>>> pygmt.set_display(method=None)
>>> fig.show()  # again, will show a PNG image in the current notebook