Skip to content

How to use PyGnuplot with Jupyter notebook! #21

@benschneider

Description

@benschneider

The easiest way I found is the following:

from PyGnuplot import gp
from IPython.display import Image

def set_jpeg(g0, out_file):
    g0.default_term = 'jpeg'
    g0.file = out_file
    g0.c('set out "' + str(g0.file) + '"')
    g0.c('set term ' + g0.default_term)
    return g0.a()

g1 = gp()
set_jpeg(g1, 'g1.jpeg')

g1.a('plot sin(x)')  # gnuplot writes plot to 'g1.jpeg'
Image(g1.file)  # shows the plot for g1 (g1.jpeg)

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions