美文网首页
线条和框

线条和框

作者: 可能性之兽 | 来源:发表于2022-10-10 14:32 被阅读0次

geom_rect、geom_linerange、geom_segment、geom_ploygon。
这四个函数分别定义了ggplot2中的矩形图、垂直线图(线范围图)、线段图、几何多边形图。
这些函数都需要指定在坐标系统中的左边界、右边界、下边界、上边界。
分辨对应xmax,xmax,ymin,ymax等四个美学映射参数,当然单个矩形仍然可以执行分组颜色映射操作。

mydata <- data.frame(
  Lebal  = c("Point1","Point2","Point3","Point4","Point5"),
  xstart = c(5.5,15.7,19.5,37.2,36.9),
  xend   = c(9.7,28.1,24.6,44.6,47.1), 
  ystart = c(9.6,23.1,2.3,33.2,9.2),
  yend   = c(16.1,36.2,11.7,38.5,15.3),
  size   = c(12,48,30,11.5,28),
  class  = c("A","A","A","C","C")
)
ggplot(mydata)+
  geom_rect(aes(xmin = xstart,xmax = xend , ymin = ystart , ymax = yend , fill = class)) 
image.png
mydata <- data.frame(
  Lebal  = c("linerange1","linerange2","linerange3","linerange4","linerange5"),
  xstart = c(3.5,7,12,16,20),
  ymin   = c(2.5,6.5,3,4.5,3.8),
  ymax   = c(7.5,9.5,9,13.5,4.2),
  class  = c("A","A","A","C","C")
)
ggplot(mydata) +
  geom_linerange(aes(x = xstart, ymin = ymin , ymax = ymax , colour = class) , size = 1.5)

image.png
library(ggplot2)
mydata <- data.frame(
  Lebal  = c("Segment1","Segment2","Segment3","Segment4","Segment5"),
  xstart = c(3.5,4.4,8.3,13.2,20),
  ystart = c(5,2.7,4.6,2.2,4.7),
  xend   = c(7.5,8.7,21,25,23), 
  yend   = c(7.9,4.2,7.2,3.8,4.4),
  class  = c("A","A","A","C","C")
)
ggplot(mydata) +
  geom_segment(
    aes(
      x = xstart, 
      y = ystart, 
      xend = xend,
      yend = yend, 
      colour = class
    ),
   
    size = 1.5
  ) 

ggplot(mydata) +
  geom_segment(
    aes(
      x = xstart , 
      y = ystart , 
      xend = xend ,
      yend = yend  , 
      colour = class
    ),
    arrow = arrow(length = unit(0.5,"cm")),
    size = 1.5
  ) +
  scale_y_continuous(expand = c(0,0)) +
  coord_polar(theta = 'x')

#
image.png
mydata <- data.frame(
  long = c(15.4,17.2,19.7,15.9,7.4,8.9,8.5,10.4,11.3,9.7,4.8,3.7,22.4,25.6,27.8,25.1,16.7,15.9,29.9,38.7,43.2,40.2,35.6,29.4),
  lat  = c(38.1,36.2,33.1,24.6,29.0,33.6,12.1,11.7,8.9,6.1,5.7,9.1,8.4,7.6,5.7,3.9,4.3,5.9,32.6,31.8,27.6,22.3,24.5,29.6),
  group= c(1,1,1,1,1,1,2,2,2,2,2,2,3,3,3,3,3,3,4,4,4,4,4,4),
  order =c(1,2,3,4,5,6,1,2,3,4,5,6,1,2,3,4,5,6,1,2,3,4,5,6),
  class = rep(c("A","c"),each = 12)
)
ggplot(mydata) +
  geom_polygon(aes(x = long , y = lat , group  = group , fill = class),colour = "white") 
#按照X轴圆周化:

ggplot(mydata) +
  geom_polygon(aes(x = long , y = lat , group  = group , fill = class),colour = "white") +
  coord_polar(theta = 'x') +
  scale_x_continuous(expand = c(0,0)) 
#按照y轴圆周化:

ggplot(mydata) +
  geom_polygon(aes(x = long , y = lat , group  = group , fill = class),colour = "white") +
  coord_polar(theta = 'y') +
  scale_y_continuous(expand = c(0,0)) 
#分面:

ggplot(mydata) +
  geom_polygon(aes(x = long , y = lat , group  = group , fill = class),colour = "white") +
  facet_grid(.~class) 

ggplot2都有哪些使用不多但是却异常强大的图层函数 - 知乎 (zhihu.com)

相关文章

  • 线条和框

    geom_rect、geom_linerange、geom_segment、geom_ploygon。这四个函数分...

  • OCR-通过识别线条算矩形框

    1、通过opencv已经识别到线条数组了 2、清除矩形框线条 把矩形框里面的线条还有比较靠近边缘的线条清理 3、拼...

  • D17心智图笔记的记忆技巧

    以手绘心智图的方式记忆内容重点 加上外框线条 美化线条 文字上淡刷色彩

  • 你知道福昕阅读器的注释框还能这么用吗?

    一、设置注释框的线条颜色 点击注释,选择注释框,拉拽需要注释的地方生成注释框,选中注释框,就能看到注释格式,点击注...

  • 10.10注意事项

    速写:线条往柔和方向,不能框的太死,重在转折卡点就行了,大部分以灰和轻的线条为主,还有调子可以小细线轻轻的排,还是...

  • 白色线条和黄色线条

    一开始就错误的事,还在错。 修正自我的行为,充满了痛苦。 黑白格子以及黑色的我。 白色线条框不住白色的车...

  • 用CSS实现圆角框

    CSS圆角进化论新手画小像素—基本线条超圆滑圆角框的半完美解决方案纯CSS圆角框 实例HTML部分:

  • AutoCAD与CASS 9.X 选择框消失的解决方法

    问题:可以选中对象,但是无选择框的效果出现,即,无选择框的线条,框内没有绿色或者蓝色的颜色填充,鼠标框选划过的范围...

  • “单词”来哉-2

    重要的事情说三遍:先写字再画框!先写字再画框!先写字再画框! “单词”:气泡框 气泡框只要保持线条的流畅即可,不需...

  • 绘画班第十二次作业

    今天感觉颇多,1.草图画好后,先把不要的线条擦掉,上色后很难擦; 2.黑色线条先画外框,里边的先不画,会染色; 3...

网友评论

      本文标题:线条和框

      本文链接:https://www.haomeiwen.com/subject/wlsoartx.html