diff --git a/examples/plotly.ipynb b/examples/plotly.ipynb index c2fb004..b57417d 100644 --- a/examples/plotly.ipynb +++ b/examples/plotly.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "code", - "execution_count": 4, + "execution_count": 1, "metadata": {}, "outputs": [], "source": [ @@ -12,7 +12,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 2, "metadata": {}, "outputs": [], "source": [ @@ -21,7 +21,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 3, "metadata": {}, "outputs": [], "source": [ @@ -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": {}, @@ -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, diff --git a/lantern/plotting/plot_matplotlib.py b/lantern/plotting/plot_matplotlib.py index a74d493..9d103cd 100644 --- a/lantern/plotting/plot_matplotlib.py +++ b/lantern/plotting/plot_matplotlib.py @@ -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: @@ -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): diff --git a/lantern/plotting/plot_plotly.py b/lantern/plotting/plot_plotly.py index b33d4bb..21be15e 100644 --- a/lantern/plotting/plot_plotly.py +++ b/lantern/plotting/plot_plotly.py @@ -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']: