diff --git a/examples/baseball.py b/examples/baseball.py index 67dcfc0..c0d7946 100644 --- a/examples/baseball.py +++ b/examples/baseball.py @@ -3,7 +3,9 @@ from collections import OrderedDict from flask import Flask from wtforms import fields -from ggplot import (aes, stat_smooth, geom_point, geom_text, ggtitle, ggplot, +from plotnine import (aes, stat_smooth, geom_point, geom_text, ggtitle, ggplot, xlab, ylab) import numpy as np import pandas as pd diff --git a/src/gleam/__init__.py b/src/gleam/__init__.py index d10829a..ea43218 100644 --- a/src/gleam/__init__.py +++ b/src/gleam/__init__.py @@ -4,7 +4,8 @@ Gleam: interactive visualizations in Python import os import json -import urlparse +import urllib.parse from collections import namedtuple from flask import Flask, request, send_from_directory diff --git a/src/gleam/panels.py b/src/gleam/panels.py index bc0c494..d870627 100644 --- a/src/gleam/panels.py +++ b/src/gleam/panels.py @@ -44,7 +44,7 @@ class InputPanel(Panel): extra = wtforms.fields.HiddenField() # get the fields - for name, obj in self.__class__.__dict__.iteritems(): + for name, obj in self.__class__.__dict__.items(): if isinstance(obj, UnboundField): setattr(InputForm, name, obj) @@ -94,8 +94,8 @@ class PlotPanel(Panel): 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 + h = hashlib.md5(str(data.__dict__).encode('utf-8')).hexdigest() + print(h) outfile = os.path.join(self.plot_dir, h + "." + self.extension) @@ -117,8 +117,9 @@ class PlotPanel(Panel): if self.plotter == "matplotlib": plt.savefig(outfile) elif self.plotter == "ggplot": - from ggplot.utils import ggsave - ggsave(outfile, ret) + ret.save(outfile) # turn into a URL, add a dummy param to avoid browser caching url = outfile.replace(os.path.sep, "/")