8000 [Q] How to compare multiple lines on the same plot? · Issue #3035 · wandb/wandb · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[Q] How to compare multiple lines on the same plot? #3035

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Ynjxsjmh opened this issue Dec 13, 2021 · 15 comments
Closed

[Q] How to compare multiple lines on the same plot? #3035

Ynjxsjmh opened this issue Dec 13, 2021 · 15 comments

Comments

@Ynjxsjmh
Copy link

In the document of Line Plot - Documentation, it says

Visualize metrics, customize axes, and compare multiple lines on the same plot

But how to do these? There is not even one line of code to show this matter.

@vanpelt
Copy link
Contributor
vanpelt commented Dec 13, 2021

You just call wandb.log: https://docs.wandb.ai/guides/track/log

@Ynjxsjmh
Copy link
Author

@vanpelt Thanks for your reply, I have tried the code following:

import wandb
import numpy as np


wandb.init(project="test", entity="xxxx")

wandb.log({"my_custom_id":
           wandb.plot.line_series(
               xs=range(100),
               ys=[range(100), np.random.randint(100, size=100)],
               keys=["y1", "y2"],
               title="Multiline",
               xname="steps"
           )})

The picture I get after choosing Edit Panel is following:

image

The picture I want to get is like

image

Difference between with these pictures are

  • Mine doesn’t have Data, Group etc tabs.
  • There are two types of legend name and lineKey in mine rather than one type.

@vanpelt
Copy link
Contributor
vanpelt commented Dec 14, 2021

Hey @Ynjxsjmh you likely don't want to use our custom plot functionality but instead just log the raw data, i.e.

import random
import wandb

wandb.init(project="test", entity="xxxx")
for i in range(100):
    wandb.log({"y1": random.random(), "y2": random.random(), "x": i})

Then you can edit any chart in your workspace to show both y1 and y2 plotted against "x":

image

@Ynjxsjmh
Copy link
Author
Ynjxsjmh commented Dec 14, 2021

@vanpelt Thanks you for letting me know I should manually select y on Data tab to compare multiple lines on the same plot. I start to know that the Line Plot - Documentation is talking about how to use the web interface to customize the plot rather than with code.

My confusion is that is it possible to customize the plot with code like matplotlib? For example, in matplotlib

  • With plt.plot(x, y, c=(0.25, 0.25, 1.00), lw=2, label="Blue signal", zorder=10), I could plot a line with color (0.25, 0.25, 1.00), line width 2, zorder 10 and legend name Blue signal
  • With plt.legend(), I could show the legend.
  • With plt.title(), I could set the plot title.
  • With plt.fill_between(), I could fill the area between two horizontal curves.

However in wandb, it seems I need to manually set them through web interface:

image

It would be inconvenient if I want to compare y1, y2 etc. through Experiment1, Experiment2 etc.

It's possible to log Matplotlib and Plotly Plots | Log Plots - Documentation directly but it lacks some wandb features like Smoothing(Exponential Moving Average, Gaussian, Running Average) and loses the original fill_between().

import wandb

import numpy as np
import matplotlib.pyplot as plt


wandb.init(project="test", entity="xxx")

figure, ax = plt.subplots()
y1 = np.random.randint(100, size=100)
ax.plot(range(100), y1, label='y1', color='blue')
ax.fill_between(range(100), y1-10, y1+10, alpha=.5)
ax.plot(range(100), np.random.randint(100, size=100), label='y2', color='red')
ax.set_title("Experiment")

ax.legend()
plt.tight_layout()

wandb.log({'chart': plt})

image

@vanpelt
Copy link
Contributor
vanpelt commented Dec 14, 2021

@Ynjxsjmh yep, when logging matplot lib objects you lose the ability to compare and we're just rendering with Plotly so you can only do what Plotly allows. The only other alternative if you want full control over how a chart looks is our custom plots which you were using initially. You can modify the vega spec and make it do anything that vega can do but it's a steep learning curve and can be pretty complicated. You can learn more about custom charts here.

< 8000 include-fragment loading="lazy" src="/wandb/wandb/issue_comments/994034296/edit_form?textarea_id=issuecomment-994034296-body&comment_context=" data-nonce="v2:a9d89b5b-eb95-de6a-8cc7-fddd19cd2356" data-view-component="true" class="previewable-comment-form js-comment-edit-form-deferred-include-fragment">

@Ynjxsjmh
Copy link
Author

Thank you for your generosity!

@ArikVoronov
Copy link

Hi, I'm in need of the same feature (multi line plots) and the proposed solutions aren't really working in my case -

Uploading line_series or matplotlib plots can't be done incrementally per epoch which is how other metrics are done (am I correct here?) and is very time consuming at the end of the training session. It also removes many helpful features from the plot, such as changing the x axis and smoothing.

The other option requires manual intervention which just isn't realistic for many training sessions (I'm running a large sweep)

Are there any plans to add this feature?

@ArturPrzybysz
Copy link

@vanpelt Came here to mention that it is indeed a need functionality and it is a pain to have to either collect the plot data and access it only after the session is done, or have configure the plot manually each time.

Is there any plan to revisit this?

Same with 1 level of nested planes like wandb.log({"level1": {"level2": {"value": 1.0}}}.

@flavioschenker
Copy link

@ArturPrzybysz agree! Demand is still there. Especially the simplest case, where you want to compare training with validation loss on the same plot. This is still not possible without manually configure the plot each time.

@spfrommer
Copy link

Bump. This is basic functionality in tensorboard via the "custom_scalars" feature and it's frustrating that there is nothing comparable in wandb.

@ugurbolat
Copy link

Any updates on this feature?

@JirkoRu
Copy link
JirkoRu commented Oct 27, 2023

I also would love this feature!

@ezhang7423
Copy link

Bump! It seems that being able to configure the panel programmatically similar to how one can currently edit a report programmatically would be the easiest way to do this..

@assafbk
Copy link
assafbk commented Mar 12, 2024

Any updates on this feature?

@vaibhav-entrupy
Copy link

I would like to see this feature as well. I have several groups of line plots to show on the separate graphs. doing them all on the UI is too much work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0