Why I am logging same plot all over again?

Hi,

I am trying to log plt plot as wandb.Image in my sweep, but I have an issue. Wandb.log will log only one first one and then it logs it all over again. Can you help me guys? Pasting my log plot code.

        for name, index in zip(names, indexes):
            print(index)
            pca_values = PCA().fit_transform(np.append(y_pred[:,index], y_valid[:,index],0))
            c_map = ["red"] * y_pred.shape[0] + ["green"] * y_valid.shape[0]


            plt.scatter(pca_values[:,0], pca_values[:,1],c=c_map, s=400,alpha=0.3)
            for i in range(pca_values.shape[0]):
                label = f"P-{i}" if i < y_pred.shape[0] else str(i - y_pred.shape[0])
                plt.text(pca_values[i,0], pca_values[i,1], label, ha="center", va="center", color='black')
            plt.grid('minor')
            plt.title(name)

            wandb.log(
                {
                    f"{name}_plot" : wandb.Image(plt)
                }
            )

Can someone help me? It is possible that I have an issue not understanding plt correctly…

Hi William!

When you are talking about plt, are you talking about the matplotlib library?

Cheers,
Artsiom

yes, I am using matplotlib.

Hi William!
Although maltplotlib does create an image of the graph, we do have an integration with their library to where you should be able to log it directly like this from our documentation:

import matplotlib.pyplot as pltplt.plot([1, 2, 3, 4])plt.ylabel("some interesting numbers")wandb.log({"chart": plt})

Also, I would advise you to check if your step/global step is going up if you are running into an issue with your plot being overwritten.

Hi William,

We wanted to follow up with you regarding your support request as we have not heard back from you. Please let us know if we can be of further assistance or if your issue has been resolved.

Best,
Weights & Biases

Hi William, since we have not heard back from you we are going to close this request. If you would like to re-open the conversation, please let us know!

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.