Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't work properly with last vers. of ggplot #3

Closed
puhoshville opened this issue Apr 18, 2017 · 1 comment
Closed

Doesn't work properly with last vers. of ggplot #3

puhoshville opened this issue Apr 18, 2017 · 1 comment

Comments

@puhoshville
Copy link

For solving this problem I'm reinstall to ggplot v. 0.6.8:
pip remove ggplot
pip install ggplot==0.6.8

Problem is in the lack of ggsave function in last versions.

@tensorstrings
Copy link

tensorstrings commented Jun 21, 2017

Fix by changing the function, refresh, into:

def refresh(self, data):
    """Generate a new image, then tell the page to change the src"""
    h = hashlib.md5(str(data.__dict__)).hexdigest()
    print h

    outfile = os.path.join(self.plot_dir, h + "." + self.extension)

    if not os.path.exists(outfile):

        if self.plotter == "custom":
            kwargs["__outfile"] = outfile

        if self.plotter == "matplotlib":
            from matplotlib import pyplot as plt
            plt.clf()

        ret = self.plot(data)
        if ret is None:
            # don't change the plot at all
            return {self.name: {}}

        # after
        if self.plotter == "matplotlib":
            plt.savefig(outfile)
        elif self.plotter == "ggplot":
            ret.save(outfile)                        ## fixed to updated ggplot save function instead of phased out ggsave function

    # turn into a URL, add a dummy param to avoid browser caching
    url = outfile.replace(os.path.sep, "/")
    url = url + "?dummy=" + str(random.random())

    return {self.name: {"src": url}}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants