Notebook Tutorial 02- Styling - Axis properties - ticks

Dear Bryan and Community:
Now I am at least able to get through these notebooks and ask more targeted questions. Currently, as you can tell from the title of this topic, I am on Axis Styling, specifically, this part:

# change just some things about the y-axes
p.yaxis.axis_label = "Pressure"
p.yaxis.major_label_text_color = "orange"
p.yaxis.major_label_orientation = "vertical"

It turns out that “major_label” refers to the integers, which I was not expecting at all. I suppose it is academic at this point, but why aren’t those called ‘tick_label’, instead? Can I infer that if it is possible to label the intervening ticks, that they would be called ‘minor_label’?

The other thing that confused me on this section was this code:

# change things on all axes
p.axis.minor_tick_in = -3
p.axis.minor_tick_out = 6

I don’t understand what these values, -3 and 6, are doing at all. I don’t see how they relate to the ticks this code, as a whole, produces. For the exercise, I reduced both values by 1/10, and got this error:

ValueError: failed to validate LinearAxis(id='11252', ...).minor_tick_in: 
expected a value of type Integral, got -0.3 of type float

What the heck is an Integral? Is that the same as an integer?

When I took the exercise the other way, *10, I got this:
image

Which I still can’t make heads or tails of. It occurred to me that maybe tick in is above the axis and tick out is below, but if so, why are there no such ‘in’ ticks in the original plot? Can you help me understand what this is supposed to be doing, and what the value of it is? Thanks.

major_label refers to the tick labels for the major ticks. Plot axes can have both major and minor ticks, and in principle can have different labels for both, thus the need for a distinction. The units for major_label_orientation are in radians to specify the rotation of the label text of the major tick labels, but there are some convenience options like “vertical” for common cases.

Can I infer that if it is possible to label the intervening ticks, that they would be called ‘minor_label’?

It could, but there’s never been a huge demand for minor tick labels, so adding that feature has never been prioritized (it does not exist yet). But a custom extension axis could certainly render minor tick labels if someone wanted to create one.

In any case, if we had just called them “tick labels” to start with, that would have boxed in the possibility for minor tick labels in the future, or in extensions. Consistent naming is important, tho sometimes it might seem more verbose.

What the heck is an Integral ? Is that the same as an integer?

Yes. [1] tick_in and tick_out specify the number of pixels that ticks extend inside and outside the plot area. [2] Pixels are not divisible, so only integral numbers of pixels makes sense to allow. But the values can be negative, in which case the distance is extended in the “opposite” direction. That is to allow for cases where you want the ticks entirely inside or outside the axes.

tick in is above the axis and tick out is below,

Above and below are not good terms, because they don’t work for vertical axes, and also because you would have to configure the top and bottom horizontal axes differently to get the same tick behavior for both. The concepts are “inside the axes” (tick_in) and “outside the axes” (tick_out).

why are there no such ‘in’ ticks in the original plot?

I don’t understand the question. There are always default values for tick_in and tick_out. The exercise is just demonstrating that you can customize things and use values different from those defaults if you want a different appearance.


  1. OED, “of or denoted by an integer.” ↩︎

  2. FYI this kind of information is in the reference guide: https://docs.bokeh.org/en/2.4.2/docs/reference/models/axes.html#bokeh.models.Axis.major_tick_in ↩︎