【问题标题】:Python plotnine increase distance between tick marksPython plotnine增加刻度线之间的距离
【发布时间】:2018-01-08 19:35:02
【问题描述】:

我正在尝试使用 plotnine ggplot 创建分组条形图。

bar graph

如您所见,x 刻度线彼此太近,标签杂乱无章。如何增加这些刻度标签之间的距离?

ggplot(test, aes(x = 'genre_pairs', y = 'average_rating', fill = 'group')) 
+geom_bar(stat = "identity", position = position_dodge()) 
+scale_x_discrete (expand = np.array([0.2,0]))

是我目前所拥有的

【问题讨论】:

    标签: python ggplot2 bar-chart python-ggplot plotnine


    【解决方案1】:

    您需要通过指定正确的图形大小来使图更宽。您可能会发现旋转文本很有帮助。

    ... + theme(figure_size=(11, 6), axis_text_x=element_text(rotation=45)
    

    【讨论】:

      【解决方案2】:

      您还可以使用 theme(axis_text_x=element_text(angle=30, hjust=1, vjust=1)) 来旋转文本方向。对于这样的任何场合,您都可以使用它来识别 x 刻度标签。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-02-20
        • 2018-07-19
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-02-22
        相关资源
        最近更新 更多