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
Line break in categorical axis labels #8169
Comments
Unfortunately this is probably not a trivial amount of work, and is also not an especially common use case. So I am not sure when we would be justified in prioritizing it. If you really need long labels, you could use actual |
Thank you, but at least in this example, the Label annotation possibility, looks a bit complicated: https://stackoverflow.com/questions/44955652/insert-a-newline-character-into-a-categorical-axis-factor-label-in-bokehjs Our standard case is unfortunately that we have long category labels (mainly for hbar charts). Currently we implement this in matplotlib If html could be passed instead of a string to the category labels that would be an ideal solution for us... see e.g. plotly's solution: https://plot.ly/python/horizontal-bar-charts/ (below Color Palette for Bar Chart) |
Yes. Currently axis and tick labels are drawn directly on an HTML canvas, which is what has limitations such as no automatic handling of line breaks. Having a general ability to render and position labels as divs containing HTML instead, would indeed be useful for this and other things e.g. LaTeX labels (but it would also come with its own tradeoffs, such floating divs would not work with SVG exports for example). However as I said it is by no means trivial to make that work, there are many important, competing priorities and very limited resources. If you are interested in working on it, I'm happy to provide any guidance. |
Having line breaks for x_axis_label would alleviate my problem. Just another user to vote for this feature... if you ever get the time/resources to do it. |
Just adding my voice to needing this. I'm not sure about your categorization of uncommon @bryevdv. |
I will tentatively add this to 1.0 milestone, because I made a preliminary implementation. That was the easy part. The harder part is to get around mine fields like |
A thought / motivating example. May or may not be helpful. I'm working with a lot of categorical, long-name data at the moment. One of the more frustrating aspects of plotting it with bokeh is that I need to constantly be fiddling with the plot height to get my labels spaced out sufficiently so I can read them. In the case of categorical labels I would argue that you definitely want to see all the labels (it's not like linear / numeric axes where you can just put in labels as convenient). So it's a case where you want the plot to grow (typically in height because it's far easier to read labels that are oriented on a y-axis) based on the number of factors you have and the desired spacing. I know the layout engine has been overhauled since I worked on it, so maybe it's more flexible now. Certainly when I worked on it, I would not have wanted to deal with plot height being set like this. But I just wanted to throw this out there as a motivating example. I would also be happy with a non-plotting-api solution. That is, I have to explicitly setup my SelfSizingAxis/Range. Because this would still be more convenient than iterating plot heights. |
Feature request (similar to #7317)
Please introduce some straightforward way to include line breaks (e.g. "\n" or "<br>") in labels of categorical axes (currently these are ignored):
The text was updated successfully, but these errors were encountered: