lets-plot
lets-plot copied to clipboard
`geom_text`: too small label size when applied log10 transformation
Example:
ggplot({'v': [1e10]}, aes(x='v')) + \
geom_point(aes(size='v'), y=0) + \
geom_text(aes(label='v'), y=1, size=10) + \
scale_size(trans='sqrt')
Output:
Expected (like in ggplot2):
Since size=10 in geom_text() the size scale does not affect size of the text regardless of trans.
Is this issue about a difference in interpretation of size in lets-plot vs ggplot2? In lets-plot geom_text size is in px (doubled). I.e. 20 px in this case. In ggplot2 it might be pt or other units.
Please clarify.
No, the issue has nothing to do with units. It is precisely that trans should not affect the constant size.
In lets-plot, removing trans changes the plot:
gggrid([
ggplot({'v': [1e10]}, aes(x='v')) + \
geom_point(aes(size='v'), y=0) + \
geom_text(aes(label='v'), y=1, size=10) + \
scale_size(trans='sqrt', guide='none'),
ggplot({'v': [1e10]}, aes(x='v')) + \
geom_point(aes(size='v'), y=0) + \
geom_text(aes(label='v'), y=1, size=10) + \
scale_size(guide='none'),
])
In ggplot2 it doesn't:
library(ggplot2)
library(cowplot)
plot_grid(
ggplot(data.frame(v = c(1e10)), aes(x = v)) +
geom_point(aes(size = v), y = 0) +
geom_text(aes(label = v), y = 1, size = 10) +
scale_size(trans = "sqrt", guide = "none"),
ggplot(data.frame(v = c(1e10)), aes(x = v)) +
geom_point(aes(size = v), y = 0) +
geom_text(aes(label = v), y = 1, size = 10) +
scale_size(guide = "none")
)