Skip to content
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

Plot comparison in a single figure not working for plots other than barplots #1298

Open
javier-coronel-snkeos opened this issue Jul 17, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@javier-coronel-snkeos
Copy link

Describe the bug

I find very useful the comparison of experiments and I'm trying to use this as well to get meaningful comparisons across different datasets.
However, the comparison of plots for the same kind of figure (histograms, boxplots) in two different dataset is not working as expected. Currently it's working only for barplots.
I'm using plotly to add the figures to a dataset.
image

To reproduce

Here's a snippet to reproduce the creation of a dataset with two plots (the figure above).
When comparing the datasets in the UI, the barplot shows the comparison of the two datasets in a single figure, nevertheless that doesn't happen for the boxplot figures:

import random

import pandas as pd
import plotly.express as px
from clearml import Dataset

for _data_version in range(2):
    dataset = Dataset.create(dataset_name="my_dataset", dataset_project="my_project")

    data = {"sample_id": [f"id_{i+1}" for i in range(10)], "duration": [random.uniform(0, 10) for _ in range(10)]}
    df = pd.DataFrame(data)

    bar_fig = px.bar(df, x="sample_id", y="duration", title="Duration per Sample")
    bar_fig.update_layout(xaxis_title="Sample ID", yaxis_title="Duration", legend_title_text="Legend")
    dataset.get_logger().report_plotly("Bar Plot", "Duration per Sample", bar_fig)

    box_fig = px.box(df, y="duration", title="Boxplot of Duration")
    box_fig.update_layout(yaxis_title="Duration", legend_title_text="Legend")
    dataset.get_logger().report_plotly("Box Plot", "Boxplot of Duration", box_fig)

    dataset.finalize()

Expected behaviour

Here's what I would expect of a boxplot comparison of two datasets for instance:
image
I would expect that a comparison of plots with the same name and type should be displayed in a single figure (which works for bar plots) instead of in two different figures.

I've tried with different parameters in the layout and arguments for plotly, but haven't been able to solve it. I would appreciate any help.

Environment

  • Server type: self hosted
  • ClearML SDK Version: 1.16.2
  • ClearML Server Version: WebApp: 3.22.0-131 • Server: 3.22.0-1461 • API: 2.30.
  • Python 3.11.5
  • OS: WSL
@javier-coronel-snkeos javier-coronel-snkeos added the bug Something isn't working label Jul 17, 2024
@ainoam
Copy link
Collaborator

ainoam commented Jul 17, 2024

@javier-coronel-snkeos You'll note that this is the stated behaviour. That said, it seems to make a lot of sense to use overlay for box-plots - We'll look into adding it to future versions.

@javier-coronel-snkeos
Copy link
Author

Thanks @ainoam for your reply. I see, good to know this will considered for future versions, maybe also considering histograms for those overlays?

Not sure if its an expected behavior, but in the UI I can manage to compare boxplots in the same figure by doing the following:

  1. Enable the data of plot 2 in figure 1
  2. Enable the data of plot 1 in figure 2
  3. Remove one dataset from the "versions" menu at the top
    image

Then the two plots are in the same figure. For me this seems more like a UI hack given that the url only includes the id of one of the datasets, and the embedded code of the figure shows the data of one plot and not the combined figure

@ainoam
Copy link
Collaborator

ainoam commented Jul 18, 2024

@javier-coronel-snkeos Definitely a hack-enabling bug :)
Histograms make definite sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants