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

Legend incostistency of report plot and experiment plot #1344

Open
Komatxu opened this issue Oct 23, 2024 · 3 comments
Open

Legend incostistency of report plot and experiment plot #1344

Komatxu opened this issue Oct 23, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@Komatxu
Copy link

Komatxu commented Oct 23, 2024

Describe the bug

Plot artifact in the experiment has different legend labels compared to the same plot in the report.

The plot logged in the experiment has the following legend
image

But when inserted into a report the legend becomes this
image

The added string corresponds to experiment id

To reproduce

Log plotly Scatter3d with legend and compare the artifact with the report

Expected behaviour

Consistent plots between experiment and report

Environment

app.clear.ml
ClearML SDK Version : 1.16.4
Python Version: 3.8.20
OSWindows

@Komatxu Komatxu added the bug Something isn't working label Oct 23, 2024
@ainoam
Copy link
Collaborator

ainoam commented Oct 30, 2024

@Komatxu How is your plot created and captured by ClearML?

@Komatxu
Copy link
Author

Komatxu commented Nov 6, 2024

I'm drawing this using plotly add_trace in 3 steps: draw the centroid, draw points and draw connections.

import plotly.express as px
import plotly.graph_objects as go

# init figure
# centroids is a dict with cluster labels as keys and x,y,z as values
fig = go.Figure()

# Setting exact colors for local show(). Colors aren't loged - i assume this is expected behavior and clearML sets colors based on names
plotly_colors = px.colors.qualitative.Light24
color_dict = {cluster_i: plotly_colors[i] for i, cluster_i in enumerate(centroids.keys())}

# add centroids to the plot
for cluster_label, centroid in centroids.items():
    centroid_x, centroid_y, centroid_z = centroid
    fig.add_trace(go.Scatter3d(x=[centroid_x], y=[centroid_y], z=[centroid_z], mode='markers', marker=dict(size=7, color=color_dict[cluster_label]), name=f'Cluster {cluster_label}', legendgroup=str(cluster_label)))

    # Connect centroids to corresponding cluster points
    # sorted_influence contains information on the n closest points to each centroid
    cluster_points = sorted_influence[sorted_influence['Cluster'] == cluster_label]
    for index, row in cluster_points.iterrows():
        x, y, z = row['x'], row['y'], row['z']
        fig.add_trace(go.Scatter3d(x=[centroid_x, x], y=[centroid_y, y], z=[centroid_z, z], mode='lines', line=dict(color=color_dict[cluster_label], width=2), name=f'Cluster {cluster_label}', showlegend=False, legendgroup=str(cluster_label)))
        fig.add_trace(go.Scatter3d(x=[x], y=[y], z=[z], mode='markers', marker=dict(size=5, color=color_dict[cluster_label]), showlegend=False, name=f'Cluster {cluster_label}', legendgroup=str(cluster_label)))

# show the plot
fig.show()

I log it using this:

logger.report_plotly(title='Clusters and centroids', series = 'Clusters and centroids', figure = fig)

@ainoam
Copy link
Collaborator

ainoam commented Nov 6, 2024

Thanks for the detailed information @Komatxu - Task id is appended to identical legend items when comparing series from different tasks, and apparently this has leaked over not taking into account that there's only a single visible item for each legend entry.

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