The language mapping base point R in FIG.

FIG point
point map provides a large number of tag values plotted on a simple horizontal scale methods
generally most useful for dot in FIG sorted and separated variable packet symbols and colors different time zone
may be used dotchar () function to create point FIG format:
dotchart (x, labels =)
x is a numeric vector
labels by each point is the vector composed of the tag
groups used to specify a factor for grouping the elements in x specify
color may be controlled for each color point to the point when the grouping of points of different groups should apply a different color
gcolor may control different sets of color tags
cex control the size of the label can be
an example of a simple point in FIG.

row.names()返回数据框行的名称,names()返回数据框列的名称
dotchart(mtcars$mpg,labels = row.names(mtcars),cex = 0.7,
         main="Gas Mileage for Car Models",
         xlab = "Miles Per Gallon")

Here Insert Picture Description
Example 2 The colored dot packet ordering FIG
this example, the most important is assigned a different color on a different set of points as a distinguishing
variable first need to be grouped so as to display the conversion factor to the Y-axis, i.e., the left of each packet ( 4,6,8)

par(mar=c(4,2,4,2))
x <- mtcars[order(mtcars$mpg),]
#将数值向量cyl转换为一个引子
x$cyl <- factor(x$cyl)
x$cyl
#指定每一个点的颜色
#添加一个字符型向量(color)到数据框x中,根据cyl的值,它所含的值为"red","blue","darkgreen"
x$color[x$cyl==4] <- "red"
x$color[x$cyl==6] <- "blue"
x$color[x$cyl==8] <- "darkgreen"
dotchart(x$mpg,labels=row.names(x),cex = 0.7,
         groups = x$cyl,gcolor = "black",
         color = x$color,
         pch=19,
         main="Gas Mileage for Car Models",
         xlab = "Miles Per Gallon"
         )

Here Insert Picture Description
End summarizes
the different plot dotchart () function is used to draw a large number of production methods have labels on the horizontal scale is simple
but not passing through the point of FIG process is so disorganized in general sorted FIG point and the packet is variable, and different symbols separate color region when the most useful (such labels which can be seen to which group at what level)
to distinguish between different groups of points usually assigned into different groups on different color or dot shape

Published 39 original articles · won praise 11 · views 10000 +

Guess you like

Origin blog.csdn.net/weixin_42712867/article/details/96422273