Trying to unbold labels in a FixedTicker

I have tried many ways to try to unbold the x axis label. Bolding comes automatically due to a FixedTicker being assigned.

One of the attempts I made is as follows:

pPlot.xaxis.major_label_text_font_style = ‘normal’


With bokeh 2.3.2, I can instantiate a figure, set a FixedTicker for the x-axis, and the default font-style for the major-label text is normal.

In [240]: p = figure(width=500, height=300)

In [241]: p.xaxis.ticker = FixedTicker(ticks=[0.0,1.0,2.0,5.0,8.0,9.0,10.0])

In [242]: p.xaxis.major_label_text_font_style
Out[242]: 'normal'

With the following simple example, I can also set the font-style for the major label of both x- and y- axes, and the bokeh machinery honors the settings.

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from import show
from bokeh.plotting import figure
from bokeh.models.tickers import FixedTicker

p = figure(width=500, height=300)
p.xaxis.ticker = FixedTicker(ticks=[0.0,1.0,2.0,5.0,8.0,9.0,10.0])
p.yaxis.ticker = FixedTicker(ticks=[0.0,5.0,10.0])

p.xaxis.major_label_text_font_size = '12pt'
p.xaxis.major_label_text_font_style = 'normal' # this is the default in bokeh 2.3.2

p.yaxis.major_label_text_font_size = '12pt'
p.yaxis.major_label_text_font_style = 'bold'

p.line(x=[-0.1, 0,1,2,3,4,5,6,7,8,9,10, 10.1], y=[6,7,3,8,10,9,2,1,5,5,3,0,1])


Is there something different about your use case or the relevant package versions you are using? If so, a minimal reproducible example – including version info – would be required for further investigation.

Hello. I attempted that and still am getting bold

p.xaxis.ticker = FixedTicker(ticks=df[‘ColName’])
p.xaxis.major_label_text_font_style = ‘normal’

If I disable the ticker row, I get the below axis which is not ideal. Difficult to read.

Ideally I would wish to keep the logarithmic scale markers but as whole numbers and also have the minor axis markers show values. This would be the ideal solution for me. The only reason why I am applying the ticker is to circumvent the below problem.

Are you sure that is actually bolded? What happens if you ask for bold?

p.xaxis.major_label_text_font_style = ‘bold’

My guess is that will be “more bold” so maybe you simply want to select a different font.

Log tickers cause special manual rendering to get superscripts. I am guessing this makes log ticks look slightly “lighter” that normal ticks by comparison, and in turn you are assuming the normal ticks are “bold”

When I give an explicit ‘bold’ to the ordinary log axis, that too is ignored. It is almost like the log axis has a mind of its own when it comes to style.

I restored the ticker line and introduced the ‘bold’ style. I think you are right that it is perhaps bolder. It is really hard to tell. I am basing this on how less visible the 0’s become.

Keep in mind the linear y axis is what the font I am expecting here. I am not entirely sure what the default “normal” font would be here.

Separately, do you think what I actually wish to achieve is a possibility? The one concerning the default log axis displaying whole numbers instead and also minor tick marks displaying values.

What does “log axis displaying whole numbers” mean? I’m still not sure what you actually want to have happen.

also minor tick marks displaying values.

There is not currently any capability to label minor ticks.

10^0 is a very unhelpful way to state “1” as is 10^1 instead of “10” and 10^-1 instead of “0.1”.

I have no idea why bokeh log plot is displaying units in this manner. I am guessing it is because the range between 0.1 and 10 is large enough to present numbers in this manner.

This is why I use p.xaxis.ticker = FixedTicker(ticks=df[‘ColName’]) instead of the default axis.

In doing so I run into the font issue where the axis appears bold.

@Gediz The ticker controls where the ticks are located, it has absolutely nothing to do with how the tick labels are formatted. It sounds like you want to configure a differnet tick formatter. These are documented here:

And in addition to those basic options there is also FuncTickFormatter that allows you to format tick labels arbitrarily according to any needs using JS code.

Edit: also

10^0 is a very unhelpful way to state

If you are seeing this you must be using an older version of Bokeh? “Superscript” log tick labels were added somewhat recently and are the only output that the current LogTickFormatter supports at all. (An option to have the “caret” exponents was added for a future version).

I am sorry but what you state my experience does not correlate.

When I use the below code, it changes the font. If I comment it out it returns back to normal.

p.xaxis.ticker = FixedTicker(ticks=df[‘ColName’])

I have demonstrated this with screenshots.

My main question is, how can I stylistically “restore” the pre FixedTicker font (I am unsure what it is) such that the labels reflect the original appearance. This is the standard label font of bokeh.

@Gediz You have not demonstrated anything until you provide a complete Minimal Reproducible Example. In the interest of focusing this discussion, I have to insist that you provide something concrete and unambiguous that we can actually run and investigate directly without further speculation.

Hello, I will make another attempt to explain my issue. I have identified the specific line that causes my issue and what outcome I seek. I have commented to this end along the code below

p = figure(title=‘some title’, x_axis_label=‘X label’, x_axis_type=(‘log’), y_axis_label=‘Y label’, width=600, height=800)
p.add_layout(Legend(), ‘below’)
p.xaxis.ticker = FixedTicker(ticks=df[‘X label’])#Commenting out this line or not impacts the font outcome
p.xaxis.major_label_text_font_style = ‘normal’#this has no impact but replacing this with bold seems to make it more bod. Screenshots are above, it is hard to tell.
p.xaxis.major_label_text_font_size = ‘11px’
p.xaxis.major_label_text_font = ‘helvetica’

Above image is the output of the prior code.

My primary question is the specific font used by default on Bokeh axis which is been overwritten by the FixedTicker assignment. That is it’s size, face etc. I cannot seem to influence that in any way with my attempts.

I think I figured out the bold issue. It is a weird one.

This below line is a problem because the dataframe is not unique.
p.xaxis.ticker = FixedTicker(ticks=df[‘X label’])

The below line was a fix. I do not believe font modification is even needed.
p.xaxis.ticker = FixedTicker(ticks=df[‘X label’].unique())

1 Like

I thought the labels looked a bit fuzzy. Over-plotting would explain everything!