Skip to content

Publication quality bars example#6772

Open
MarcSkovMadsen wants to merge 4 commits intomainfrom
enhancement/publication-quality-bars
Open

Publication quality bars example#6772
MarcSkovMadsen wants to merge 4 commits intomainfrom
enhancement/publication-quality-bars

Conversation

@MarcSkovMadsen
Copy link
Collaborator

@MarcSkovMadsen MarcSkovMadsen commented Dec 25, 2025

I was struggling trying to create the most basic publication quality business like chart - a bar chart. So I would like to add a new category and an example to the gallery.

What I see very often in a business context is that people give up on bokeh/ holoviews because it does not look at pretty as alternative libraries. That is a shame because they are very powerful libraries that provides something unique.

I hope a "Business Quality" gallery category can help users and maybe inspire HoloViews/ Bokeh to provide more business friendly defaults and easy to use methods.

image

Inspired by https://www.atlassian.com/data/charts/bar-chart-complete-guide.

For inspiration andrew also created https://medium.com/@pYdeas/create-publication-styled-figures-with-hvplot-using-the-bokeh-backend-b623ab48a5d2.

ACCENT_COLOR = '#007ACC' # Professional blue
FONT_FAMILY = 'Roboto'

def create_bokeh_theme(font_family=FONT_FAMILY, accent_color=ACCENT_COLOR):
Copy link
Collaborator Author

@MarcSkovMadsen MarcSkovMadsen Dec 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wish there was a better font default in HoloViews/ Bokeh. Or a very easy way to change it.

'Axis': {
'axis_label_text_font': font_family,
'axis_label_text_font_size': '12pt',
'axis_label_text_font_style': 'bold',
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the default italic style is readable or modern. bold is much better in my opinion.

'major_label_text_font': font_family,
'major_label_text_font_size': '10pt',
'major_tick_line_color': "black", # Remove tick marks
'minor_tick_line_color': None
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the minor lines should be removed in a business setting. They add too much complexity.

'label_text_font_size': '10pt'
},
'Toolbar': {
"autohide": True,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wish that autohide=True by default. This is a huge simplification for users to look at. Especially for panel dashboards.

},
# Does not work via Theme, so added here for reference purposes until I figure out how to do it
'Tooltip': {
"stylesheets": [f"""
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could not figure out how to change the tooltip text color. I believe this should work but does not. Maybe a Bokeh Theme issues?

'plot.min_border_top': 80, # Add padding on top
}

ElementPlot.param.backend_opts.default = GLOBAL_BACKEND_OPTS
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this way of setting global opts is a hack. But it did not work setting them via hv.opts.defaults.

ElementPlot.param.backend_opts.default = GLOBAL_BACKEND_OPTS
ElementPlot.param.yformatter.default = NumeralTickFormatter(format='0a') # 1k, ...

hv.opts.defaults(
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the defaults below would give holoviews a more fresh and modern look.

('Magnitude', '@mag_class'),
('Events', '@event_count{0,0}'), # Format: 1,234
# tooltips below do currently not work on Labels
# ('Percentage', '@percentage{0 a}%'), # Format: 45.7%
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could not get additional tooltips working for Labels. Believe its a bug. Reported in #6769.

# HOLOVIEWS OPTS SETUP - Define global configuration
# ============================================================================

GLOBAL_BACKEND_OPTS={
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to set these GLOBAL_OPTS in the bokeh Theme but could not get it working. Especially the min_border would be nice to set in the theme instead.

}

ElementPlot.param.backend_opts.default = GLOBAL_BACKEND_OPTS
ElementPlot.param.yformatter.default = NumeralTickFormatter(format='0a') # 1k, ...
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default scientific notation on the y-axis is always a problem in a business context. Nobody uses it.

@codecov
Copy link

codecov bot commented Dec 25, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.23%. Comparing base (85fe644) to head (1351db1).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6772   +/-   ##
=======================================
  Coverage   89.23%   89.23%           
=======================================
  Files         340      340           
  Lines       73183    73183           
=======================================
  Hits        65303    65303           
  Misses       7880     7880           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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

Successfully merging this pull request may close these issues.

1 participant