def test_plot_linear(x, expected_linear_plot): title = "My linear plot" plt_str = plot( x=x, y=x, figsize=(19, 10), xlim=(0, 9), ylim=(0, 9), xlabel="x", ylabel="y", return_type="str", title=title, ) assert plt_str == expected_linear_plot fig = figure(figsize=(19, 10), xlim=(0, 9), ylim=(0, 9), xlabel="x", ylabel="y") fig.plot(x, x) fig.set_title(title) assert fig.draw() == expected_linear_plot fig.clear() plot(x, x, fig=fig) fig.set_title(title) assert fig.draw() == expected_linear_plot
def test_plot_linear_color(x, color, expected_linear_plot_color): plt_str = plot( x=x, y=x, color=color, figsize=(19, 10), return_type="str", ) assert plt_str == expected_linear_plot_color
def _series_line(data, **kwargs): x_col = kwargs.pop("x") y_col = kwargs.pop("y") # why do we get both x and y here? if x_col is not None: data = data[x_col] if y_col is not None: data = data[y_col] return plt.plot(x=data.index, y=data, **kwargs)
def test_plot_interp(x, y, expected_interp_plot): plt_str = plot( x=x, y=y, figsize=(19, 10), xlim=(0, 9), ylim=(0, 9), line=True, marker=None, return_type="str", ) assert plt_str == expected_interp_plot
def test_plot_linear_line(x, expected_linear_line_plot): plt_str = plot( x=x, y=x, line=True, figsize=(10, 10), xlim=(0, 9), ylim=(0, 9), xlabel="x", ylabel="y", return_type="str", ) assert plt_str == expected_linear_line_plot
def test_plot_linear_pd_labels(expected_linear_plot): x = pd.Series(np.arange(0, 10, 1), name="x") y = pd.Series(np.arange(0, 10, 1), name="y") plt_str = plot( x=x, y=y, figsize=(19, 10), xlim=(0, 9), ylim=(0, 9), xlabel="x", ylabel="y", title="My linear plot", return_type="str", ) assert plt_str == expected_linear_plot
def test_plot_multi_linear(x, y, expected_linear_multi_plot): if isinstance(x, np.ndarray): label = ["up", "down"] else: label = None plt_str = plot( x=x, y=y, figsize=(19, 10), xlim=(0, 9), ylim=(0, 9), label=label, return_type="str", ) assert plt_str == expected_linear_multi_plot
def _frame_line(data, **kwargs): x_col = kwargs.pop("x") y_col = kwargs.pop("y") color = kwargs.pop("color", None) if x_col is None and y_col is None: x = pd.concat([data.index.to_frame()] * data.shape[1], axis=1) y = data else: if x_col is None or y_col is None: raise ValueError("Please provide both x, y column names") x = data[x_col] y = data[y_col] if color in data.columns: color = data[color] return plt.plot(x=x, y=y, color=color, **kwargs)