解决RStudio中"plot.new() : figure margins too large"问题

39 篇文章 9 订阅

  在RStudio中使用plot()函数进行画图时,常出现“plot.new() : figure margins too large”问题。如图(1)所示。

这里写图片描述

  出现该问题的原因是,RStudio里的【Plots】窗口太小,可以适当调大一点,或者把RStudio设置为全屏。解决步骤如下。
  1.用鼠标选中【Plots】选项卡,然后把该窗口拖大一点即可,如图(2)所示。
  
这里写图片描述
图(2) 将【Plots】窗口拖大

  2. 测试代码
  //数据源 drink.txt  

index   heat    caffeine    Na  price
1   207.2   3.3 15.5    2.8
2   36.8    5.9 12.9    3.3
3   72.2    7.3 8.2 2.4
4   36.7    0.4 10.5    4.0
5   121.7   4.1 9.2 3.5
6   89.1    4.0 10.2    3.3
7   146.7   4.3 9.7 1.8
8   57.6    2.2 13.6    2.1
9   95.9    0.0 8.5 1.3
10  199.0   0.0 10.6    3.5
11  49.8    8.0 6.3 3.7
12  16.6    4.7 6.3 1.5
13  38.5    3.7 7.7 2.0
14  0.0 4.2 13.1    2.2
15  118.8   4.7 7.2 4.1
16  107.0   0.0 8.3 4.2

  
  //ceshi.R  

drink <- read.table("G:/myProject/RDoc/Unit3/rChap1/drink.txt",header = T)
drink <- drink[,-1]
d=dist(drink)
hc1=hclust(d,method="ward.D2")  #离差平方和法
hc2=hclust(d,method="single")  #最短距离法
hc3=hclust(d,method="complete")  #最长距离法
hc4=hclust(d,method="median")  #中间距离法
opar=par(mfrow=c(2,2))  #分割绘图区域
plot(hc1,hang=-1);plot(hc2,hang=-1);plot(hc3,hang=-1);plot(hc4,hang=-1)
par(opar)  #释放绘图区域分割

  效果如下:

这里写图片描述
图(3)将【Plots】窗口放大之后,进行绘图的效果

  • 84
    点赞
  • 70
    收藏
    觉得还不错? 一键收藏
  • 16
    评论
评论 16
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值