Skip to content

Commit

Permalink
fix bug in plotly, fixes #76
Browse files Browse the repository at this point in the history
  • Loading branch information
timkpaine committed Sep 19, 2018
1 parent 6736530 commit 26157aa
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 14 deletions.
39 changes: 33 additions & 6 deletions examples/plotly.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -12,7 +12,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -21,7 +21,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -32,19 +32,19 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "e353ff58bd9445db8737f62a0d027db0",
"model_id": "2a318d4266684c66a40e93c9d39a368a",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"FigureWidget({\n",
" 'data': [{'line': {'color': 'rgba(202, 81, 253, 1.0)', 'dash': 'solid', 'shape': 'linear', …"
" 'data': [{'line': {'color': 'rgba(60, 178, 63, 1.0)', 'dash': 'solid', 'shape': 'linear', '"
]
},
"metadata": {},
Expand All @@ -59,6 +59,33 @@
"f.show()"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "7634ddb3097a4eddaf4e89c2fb50031f",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"FigureWidget({\n",
" 'data': [{'marker': {'color': '#041FA4'},\n",
" 'mode': 'markers',\n",
" 'n…"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"l.plot(df, 'scatter', 'cufflinks')"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down
8 changes: 2 additions & 6 deletions lantern/plotting/plot_matplotlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,6 @@ def show(self, title='', xlabel='', ylabel='', xaxis=True, yaxis=True, xticks=Tr

lines = []
labels = []
# plt.legend([])
# leg = set(ax.legend for ax in self._axes)

# FIXME these rescale the axis
# plt.axhline(0, color='black')
# plt.axvline(0, color='black')

to_delete = []
for ax in self._axes:
Expand Down Expand Up @@ -204,10 +198,12 @@ def _bar(self):
if d[2] == 'right':
x = ax2.bar(d[0].index+count*((d[0].index[1]-d[0].index[0])/(left_count+right_count)), d[0][col], width=width, color=d[1], **d[4])
self._legend.append((col, x, d[2]))
x.set_label(col)
count += 1
else:
x = ax.bar(d[0].index+count*((d[0].index[1]-d[0].index[0])/(left_count+right_count)), d[0][col], width=width, color=d[1], **d[4])
self._legend.append((col, x, d[2]))
x.set_label(col)
count += 1

def _hist(self):
Expand Down
4 changes: 2 additions & 2 deletions lantern/plotting/plot_plotly.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ def show(self, title='', xlabel='', ylabel='', xaxis=True, yaxis=True, xticks=Tr
y2_count = sum([1 for (_, _, a, _) in self.figures if a == 'right'])

y2s = 2
y2p = .05/y2_count
y2_base = .95
y2p = .05/y2_count if y2_count > 0 else 0
y2_base = .95 if y2_count > 0 else 1.0

for col, figure, axis, color in self.figures:
for trace in figure['data']:
Expand Down

0 comments on commit 26157aa

Please sign in to comment.