问题描述
我想做一个没有 y 轴刻度的绘图,并将 y 轴文本尽可能靠近绘图。
因此我在 import Data.Kind
type ControlFlowCMD :: (Type -> Type,Type) -> Type -> Type
newtype ControlFlowCMD fs a = ...
中使用了 axis.text.y = element_text(hjust = 2)
,但请注意,因为标签范围从 theme()
到 0
,40
值最终出现在图中而其他标签则没有。
一个可重现的小例子:
0
是否可以将 ggplot(mtcars,aes(x=wt,y=mpg)) + geom_point() +
scale_y_continuous(limits=c(0,40)) +
theme(axis.ticks = element_blank(),axis.text.y = element_text(hjust = 2))
与所有其他值的位置对齐?
解决方法
试试这个:
ggplot(mtcars,aes(x=wt,y=mpg)) + geom_point() +
scale_y_continuous(limits=c(0,40)) +
theme(axis.ticks = element_blank(),axis.text.y = element_text(hjust = 1,margin = margin(0,-3,0))
)
修改margin
以获得想要的结果