Skip to content

theme helpers: improve bokeh background #14

Description

@gordonwoodhull

On a whim, I asked Claude if it could fix the missing background color problems in theme_colors_bokeh()

It only hallucinated one key:

AttributeError: unexpected attribute 'text_color' to Legend, similar attributes are title_text_color, label_text_color or inactive_hatch_color

Here is the code with Claude's recommended fixes, and that key fixed as suggested in the error.

Seems to do it!

def theme_colors_bokeh(bg, fg):
  from bokeh.io import curdoc
  from bokeh.themes import Theme

  curdoc().theme = Theme(
    json={
      "attrs": {
        "figure": {
          "background_fill_color": bg,  # plot area
          "border_fill_color": bg,      # area between plot and outer edge
          "outline_line_color": fg,     # border around the plot
        },
        "Grid": {
          "grid_line_color": fg,
          "grid_line_alpha": 0.2,       # make grid lines subtle
        },
        "Title": {
          "background_fill_color": bg,
          "text_color": fg,
        },
        "Axis": {
          "background_fill_color": bg,
          "axis_label_text_color": fg,
          "major_label_text_color": fg,
          "axis_line_color": fg,        # axis line color
          "major_tick_line_color": fg,  # tick marks
          "minor_tick_line_color": fg,
        },
        "Legend": {
          "background_fill_color": bg,
          "title_text_color": fg,
          "label_text_color": fg,
          "border_line_color": fg,
          "border_line_alpha": 0.2,
        }
      }
    }
  )

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions