![](/img/trans.png)
[英]python how do I move my y axis labels to the middle of my horizontal bar graph
[英]How do I move the axis labels in plotnine?
我正在嘗試將 x 和 y 軸標簽移動到圖表左下方的彼此靠近。
這在 R 的 ggplot2 中很容易:
theme(
axis.title.y = element_text(angle = 0, vjust = 0, hjust = 0.5, size = 15,
color = "grey55"),
axis.title.x = element_text(hjust = 0, size = 15, color = "grey55"))
在
關於<\/a>
plot_title<\/code>的相關 GitHub 問題的評論之后,您可以通過設置軸標題的
x<\/code>和
y<\/code>位置來移動位置。
對於您想要的結果,我認為
y=.1<\/code>和
x=.125<\/code>可以正常工作:
(p9.ggplot(p1_1, p9.aes(x = 'Test'))
+ p9.geom_histogram(bins = 10, fill = "#f9d9d6", color = "#E34234")
+ p9.theme_classic()
+ p9.themes.theme(
axis_title_y = p9.themes.element_text(angle = 0, va = 'bottom', ha = 'right',
size = 15, color = "#8c8c8c", y = .1),
axis_title_x = p9.themes.element_text(ha = 'left', va = 'center', size = 15,
color = "#8c8c8c", x = 0.125),
axis_text = p9.themes.element_text(size = 12, color = "#999999"),
axis_line = p9.themes.element_line(color = "#999999"),
axis_ticks = p9.themes.element_line(color = "#999999"),
plot_title = p9.themes.element_text(hjust = 0.5, size = 40, color = "#666666"),
panel_grid = p9.themes.element_blank(),
)
)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.