【问题标题】:ggplot2: aspect_ratio and placing title/axis label in the right placeggplot2:aspect_ratio 并将标题/轴标签放在正确的位置
【发布时间】:2011-07-28 16:01:20
【问题描述】:

在R下使用ggplot2(下面的代码使用rpy2,其实我不知道直R,抱歉)。

我正在尝试将 aspect_ratio 添加到我的情节中(这样它就可以很好地放在幻灯片上)。下面的例子非常小。 Aspect_ratio 做了正确的事情,除了标题和 x 轴标签分别放置在图的上方和下方,标题和图之间以及图和 x 轴标签之间有一个巨大的空白,如(plot here)

   TITLE TITLE


PLOT PLOT PLOT PLOT
PLOT PLOT PLOT PLOT
PLOT PLOT PLOT PLOT
PLOT PLOT PLOT PLOT


    x-axis label

不酷。我该怎么做才能把它们挤在一起?

#!/usr/bin/env python2.6
import rpy2.robjects.lib.ggplot2 as ggplot2
import rpy2.robjects as ro
from rpy2.robjects.packages import importr

df = ro.DataFrame({'x': ro.IntVector((1,2)), 'y': ro.IntVector((3,4))})
pp = ggplot2.ggplot(df) + \
    ggplot2.aes_string(x='x', y='y') + \
    ggplot2.opts(**{'title' : 'Title',
                    'aspect.ratio' : 0.618033989} ) + \
    ggplot2.geom_line()
grdevices = importr('grDevices')
grdevices.pdf(file="aspect.pdf")
pp.plot()
grdevices.dev_off()

【问题讨论】:

    标签: r ggplot2 aspect-ratio


    【解决方案1】:

    这是当前布局系统的一个限制,我希望尽快解决。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-09-23
      • 1970-01-01
      • 1970-01-01
      • 2010-12-06
      • 1970-01-01
      • 1970-01-01
      • 2013-07-09
      相关资源
      最近更新 更多