Question on using ax.vspan when plotting


Does wandb plotting support the use of matplotlib’s axvspan? I’m trying to shade an area and it works locally, but it doesn’t pop up in my plot in wandb.

    fig, ax = plt.subplots()
    ax.plot(x_train, y_train, 'ro', label='data')

    if len(x_test) > 0:
        ax.plot(x_test, y_test, 'bo', label='unseen data')
        ax.axvspan(np.min(x_test), np.max(x_test), alpha=0.3, color='blue')
    wandb.log({"plot": plt})


HI @inwaves could you share a link to your workspace?

This may be a bug. We should support it if it is part of the Matplotlib library. I’ll try to reproduce as well.

@inwaves I was able to test and replicate this issue. I’ll report this as a bug and follow up if we are able to create a solution.

1 Like

Hey @nathank, thanks for replicating! Until the solution arrives, using Plotly directly seems to work just fine, something like:

fig.add_vrect(x0=np.min(x_test), x1=np.max(x_test), line_width=0, fillcolor="red", opacity=0.2)