break_width Parameter in Position Scales#
The break_width parameter specifies a fixed distance between axis breaks.
If the scale has an associated transformation, the distance is measured in transformed units.
For example, on a log10 scale, break_width=1 places breaks at every power of 10, and break_width=0.5 — at every half-power.
import pandas as pd
from lets_plot import *
LetsPlot.setup_html()
df = (pd.read_csv("https://raw.githubusercontent.com/JetBrains/lets-plot-docs/refs/heads/master/data/diamonds.csv")
.sample(n=5000, random_state=42))
print(df.shape)
(5000, 10)
ggplot(df, aes(x='carat', y='price')) + \
geom_point(alpha=0.3) + \
scale_y_log10() # <-- a log10 scale with auto-selected breaks
ggplot(df, aes(x='carat', y='price')) + \
geom_point(alpha=0.3) + \
scale_y_log10(break_width=0.5) # <-- breaks every 0.5 powers of 10