Skip to content

Revise coloring in transcript widget #421

Description

@jwrth

Currently the colors are assigned when loading the transcript viewer, which lowers performance and can lead to duplicate colors when displaying multiple transcripts. It might make more sense to predefine a large set of optimized colors and use those. The glasbey package does this for large number of colors. One could once generate a list of hexcolors and save them somewhere in the package instead of generating them in situ.

Glasbey default:

import glasbey
import matplotlib.pyplot as plt
import matplotlib.patches as mpatches

colors = glasbey.create_palette(palette_size=20)

fig, ax = plt.subplots(figsize=(10, 1))
for i, c in enumerate(colors):
    ax.add_patch(mpatches.Rectangle((i, 0), 1, 1, color=c))
ax.set_xlim(0, len(colors))
ax.set_ylim(0, 1)
ax.axis('off')
plt.tight_layout()
plt.show()

Shiny colors:

import glasbey
import matplotlib.pyplot as plt
import matplotlib.patches as mpatches

colors = glasbey.create_palette(
    palette_size=20,
    lightness_bounds=(30, 70),
    chroma_bounds=(60, 100),
)

fig, ax = plt.subplots(figsize=(10, 1))
for i, c in enumerate(colors):
    ax.add_patch(mpatches.Rectangle((i, 0), 1, 1, color=c))
ax.set_xlim(0, len(colors))
ax.set_ylim(0, 1)
ax.axis('off')
plt.tight_layout()
plt.show()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions