question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add example to illustrate label placement

See original GitHub issue

This issue is a byproduct from issue #5353 [Extensions do not render when using bokeh.embed.components / bokeh.embed.file_html APIs]

The motivation for this issue is to include plot axis labels with (rendered) LaTeX labels, derived from the following example: http://bokeh.pydata.org/en/latest/docs/user_guide/extensions_gallery/latex.html

As mentioned in issue #5353, the placement of the labels is problematic, and I suspect there is a better way to place labels. Building on the example from issue #5353:

p = bokeh.plotting.figure(title="LaTeX Demonstration")

p.line(x, y)

equation = "f = \sum_{n=1}^\infty\\frac{-e^{i\pi}}{2^n}!"

horizLabel = LatexLabel(text=equation,
                        x=0.5, y=0.7, 
                        x_units='data', y_units='data',
                        render_mode='css', text_font_size='6pt',
                        angle=0) 
p.add_layout(horizLabel, "below")

vertLabel = LatexLabel(text=equation,
                       x=-0.3, y=2.0, 
                       x_units='data', y_units='data',
                       render_mode='css', text_font_size='6pt',
                       angle=90, angle_units="deg")
p.add_layout(vertLabel, "left")

l = bokeh.layouts.layout([[p]], sizing_mode='stretch_both')

with open("embedLatexLabelTest-file_html.html","w") as f:
    f.write(bokeh.embed.file_html(l, bokeh.resources.CDN, "Plot with LaTeX label"))

The latex labels move when panning the plot - also, the vertical label is too far from the plot and the horizontal label is not displayed, but those are moot points:

image

So I switched to “screen” units:

horizLabel = LatexLabel(text=equation,
                        x=500, y=0, 
                        x_units='screen', y_units='screen',
                        render_mode='css', text_font_size='6pt',
                        angle=0) 
p.add_layout(horizLabel, "below")

vertLabel = LatexLabel(text=equation,
                       x=50, y=500, 
                       x_units='screen', y_units='screen',
                       render_mode='css', text_font_size='6pt',
                       angle=90, angle_units="deg")
p.add_layout(vertLabel, "left")

However, now the vertical border / padding makes the label look awkward and the horizontal label is not shown until scrolling down the page:

image

These are extracts from the “real” program generating the plots. In that case, the data and labels are different, and the output is inconsistent - i.e., some labels look decent, while others are butted up against the axis, while others look like they require more padding (maybe via the `min_border_left/bottom’ attribute?). I can post examples of those if that would be helpful, but I’m hoping this provides enough information.

@bryevdv suggested I add this issue, requesting that an example be added to Bokeh so future users that encounter this type of issue have a reference.

Thanks for your help!

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:23 (15 by maintainers)

github_iconTop GitHub Comments

1reaction
bryevdvcommented, May 10, 2018

Wow, there is alot going on here. I am going to close this issue due to lengthy inactivity, but also because there are some other issues (e.g. #6031) that seem to overlap with it. I know this is an important topic to a specific class of users, I do hope we can make improvements in this area in time, but resources are spread extremely thin right now.

1reaction
StevenCHowellcommented, Feb 13, 2017

@arossi1 I will be able to return to this later this week. I will post my results.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Label Placement | GEOG 486: Cartography and Visualization
The first guideline to remember is that adding point labels is not like making a bulleted list—your labels should be shifted up or...
Read more >
Setting point label placement properties—ArcMap
Click a label class in the Label Classes list. Click the placement options you want from the Placement Properties box. Optionally, click Properties...
Read more >
Fundamentals of Label Placement (Live Carto, Episode #6)
This talk is part of the How to do Map Stuff livestream event! For a full schedule, see: bit.ly/map_stuff. Typography can make or...
Read more >
Edit titles or data labels in a chart - Microsoft Support
On the Layout tab, in the Labels group, click Data Labels, and then click the option that you want. For additional data label...
Read more >
Variable label placement | Mapbox GL JS
The icon-image used in this example comes from the Mapbox Light style's sprite. To view all available images in a style's sprite or...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found