首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >geom_line图形上y轴的比例尺被打包

geom_line图形上y轴的比例尺被打包
EN

Stack Overflow用户
提问于 2017-02-27 07:02:17
回答 1查看 881关注 0票数 0

我正在制作一个R标记文件,使用对冲基金数据为一个金融计量经济学类分配。我的作业定于周二完成,但我在pdf_document中的数字呈现方式上有一些问题。

代码语言:javascript
复制
```{r Q4}

图书馆(Dplyr)

图书馆(Ggplot2)

图书馆(天平)

hedgefunds.long <- hedgefunds.long %>% group_by(战略) %>%变异(RET= (log(NAV)-滞后(log(NAV)* 100)

ggplot(hedgefunds.long) + geom_line(aes(x = date,y= RET)) + scale_y_continuous(breaks=pretty_breaks(n=6)) + facet_wrap(~策略,ncol = 2)

代码语言:javascript
复制
​

![](https://developer.qcloudimg.com/http-save/yehe-900000/bfcf616a6168a16ae14f2cceac554022.jpg)

​

Another issue I am having is that bits are cut off when the pdf document is knitted. I was wondering if there was a way to make sure that the legend in the picture below is not cut off at the top and bottom. 

[watch the labels on the axes](https://i.stack.imgur.com/MBF3z.jpg)

edit: (changed corrplot a bit, still haven't figure out resizing)

```javascript

addgrid.col = "gray50",tl.cex = 0.8,tl.offset = 0.5,tl.col =“黑色”)

代码语言:javascript
复制
head on each dataset,

```javascript
代码语言:javascript
复制
> head(hedgefunds, 10)

A级老虎: 10×15

代码语言:javascript
复制
     date `Hedge Fund Index` `Convertible Arbitrage` `Dedicated Short Bias`
代码语言:javascript
复制
   <date>              <dbl>                   <dbl>                  <dbl>

一九九三年一日-12-31 100.00 100.00 100.00

1994-01-31 101.14 100.36 98.40

1994-02-28 97.00 100.51 100.37

1994-03-31 93.54 99.54 107.59

1994年5月-04-30 91.91 97.03 108.97

1994年6月-05-31 93.96 96.04 111.42

1994年7月-06-30 93.20 96.24 118.49

1994年8月-07-31 93.53 96.37 117.09

1994年9月-08-31 96.12 96.33 110.46

1994年10月-09-30 96.76 95.18 112.20

..。增加11个变量:Emerging Markets,“股票市场”

中性<dbl>,事件驱动的<dbl>,事件驱动的不良<dbl>,事件

驱动多策略<dbl>,事件驱动风险套利<dbl>,固定

收益套利<dbl>,Global Macro<dbl>,多头/空头股票

Managed FuturesMulti-Strategy

头(hedgefunds.long,10)

资料来源:本地数据框架10 x4。

集团:战略1

代码语言:javascript
复制
     date         Strategy    NAV        RET
代码语言:javascript
复制
   <date>            <chr>  <dbl>      <dbl>

1993年1日-12-31对冲基金指数100.00 NA

1994-01-31对冲基金指数101.14 1.1335510

1994-02-28对冲基金指数97.00 -4.1794717

1994-03-31对冲基金指数93.54 -3.6321826

1994-04-30对冲基金指数91.91 -1.7579315

1994-05-31对冲基金指数93.96 2.2059322

1994-06-30对冲基金指数93.20 -0.8121438

1994年8月07-31对冲基金指数93.53 0.3534519

1994年9月-08-31对冲基金指数96.12 2.7315170

1994-09-30对冲基金指数96.76 0.6636275

图书馆(Tidyr)

hedgefunds.long <- tidyr::hedgefunds(对冲基金,策略,NAV,-date)

代码语言:javascript
复制

将尝试这一点,并查看它是否works...will编辑文章,如果它这样做。坐标标号的r-变化尺寸

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-02-27 07:54:01

我没有一个可重复的数据来检查,但在我看来,数字大小太小,迫使你的数字堆在一起。

左右播放您的图形窗口大小,特别是Q4中的高度,也考虑facet_wrap(~ Strategy, ncol = 2)中的ncol > 2;Q8的宽度和高度。

可以添加fig.width和fig.height‘{r fig.width=x,fig.height=y}

{r Q4, fig.width=7, fig.height=10} # plot()

如果数字大小不能修复它,则可以设置页边距。

代码语言:javascript
复制
# ggplot margins 
gg + theme(plot.margin = unit(c(t,r,b,l), "cm")) # replace t,r,b,l with appropriate values
# plot margins
par(mar=c(b,l,t,r)) # replace b,l,t,r with appropriate values
plot()
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42479615

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档