def test_bar_list_pick_color_palette(self): fig = plotly_bar(y=["b", "c", "d"], data=self.data, palette="RdBu") self.assert_valid_plotly_figure(fig, num_renderers=3) with self.assertRaises(ValueError): plotly_bar(y=["b", "c", "d"], data=self.data, palette="NON-EXISTENT")
def test_bar_against_index(self): fig = plotly_bar(y="b", data=self.data) self.assert_valid_plotly_figure(fig, num_renderers=1) fig = plotly_bar(x="index", y="b", data=self.data) self.assert_valid_plotly_figure(fig, num_renderers=1) fig = plotly_bar(x=DATA.index.name, y="b", data=self.data) self.assert_valid_plotly_figure(fig, num_renderers=1)
def test_bar_plot_silly_x_scale(self): # In the case of bar plots, x_scale is overwritten if the x_axis is # made of strings, so this doesn't break: fig = plotly_bar(y=["b"], data=self.data, x_scale="BLAH BLAH") self.assert_valid_plotly_figure(fig)
def test_bar_list_pick_color_bad_length(self): with self.assertRaises(ValueError): plotly_bar(y=["b", "c", "d"], data=self.data, hue=[BLUE, GREEN])
def test_bar_list_pick_color_as_palette(self): # Same as above but the list of colors is passed as the palette fig = plotly_bar(y=["b", "c", "d"], data=self.data, palette=[BLUE, GREEN, RED]) self.assert_valid_plotly_figure(fig, num_renderers=3)
def test_bar_list_pick_color(self): fig = plotly_bar(y=["b", "c", "d"], data=self.data, hue=[BLUE, GREEN, RED]) self.assert_valid_plotly_figure(fig, num_renderers=3)
def test_bar_pick_color(self): fig = plotly_bar(y="b", data=self.data, hue="rgb(122, 120, 120)") self.assert_valid_plotly_figure(fig, num_renderers=1) fig = plotly_bar(y="b", data=self.data, hue=RED) self.assert_valid_plotly_figure(fig, num_renderers=1)
def test_stacked_bar_list(self): fig = plotly_bar(y=["b", "c"], data=self.data, barmode="stack") self.assert_valid_plotly_figure(fig, num_renderers=2) fig = plotly_bar(x="a", y=["b", "c"], data=self.data, barmode="stack") self.assert_valid_plotly_figure(fig, num_renderers=2)
def test_bar_list(self): fig = plotly_bar(y=["b", "c"], data=self.data) self.assert_valid_plotly_figure(fig, num_renderers=2)
def test_bar_against_float_col(self): fig = plotly_bar(x="c", y="b", data=self.data) self.assert_valid_plotly_figure(fig, num_renderers=1)
def test_bar_all_columns(self): # If you don't specify what to plot along y, all columns are plotted: data2 = DATA[list("bcd")] fig = plotly_bar(data=data2) self.assert_valid_plotly_figure(fig, num_renderers=3)
def test_missing_data(self): with self.assertRaises(ValueError): plotly_bar()