Created
December 6, 2014 23:09
-
-
Save tschaume/d123d56bf586276adb98 to your computer and use it in GitHub Desktop.
This gist illustrates the issue in Plotly of non-json-serializable masked constants as produced by Pandas with and without the pull request at https://github.com/plotly/python-api/pull/159) (also see http://stackoverflow.com/questions/27053729)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
from plotly.matplotlylib import Exporter, PlotlyRenderer | |
from plotly.plotly import plot | |
import matplotlib.pyplot as plt | |
data = { | |
'esN': [0, 1, 2, 3], | |
'ewe_is0': [ -398.11901997, -398.11902774, -398.11897111, -398.11882215 ], | |
'ewe_is1': [ -398.11793027, -398.11792966, -398.11786308, None ], | |
'ewe_is2': [ -398.11397008, -398.11396421, None, None ] | |
} | |
df = pd.DataFrame.from_dict(data) | |
print type(df['ewe_is2'][3]), repr(df['ewe_is2'][3]) | |
plotopts = { 'x': 'esN', 'marker': 'o' } | |
fig, ax = plt.subplots(1, 1) | |
df.plot(ax=ax, **plotopts) | |
for l in ax.get_lines(): print type(l.get_xydata()[-1][-1]) | |
# following is debug version of plotly.plot_mpl() | |
# see https://github.com/plotly/python-api/blob/e5a3b3/plotly/tools.py#L370-L371 | |
renderer = PlotlyRenderer() | |
Exporter(renderer).run(fig) | |
print type(renderer.plotly_fig['data'][1]['y'][-1]) | |
print plot(renderer.plotly_fig, filename='test0_1', auto_open=False) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment