Today's meeting to discuss a half-day of their own research results, colleagues frowned, the first as if she did not understand, the second feeling in front of a bright, but do not know how to landing. Landed this thing, give time, I want to practice my analysis.
Today I got a simple, bar chart.
is a bar chart that is often played in Excel. Compare the BoxPlot and Ggplot, or ggplot more powerful, and make the diagram more beautiful.
Explain the following command in detail.
Ggplot (data = ls, mapping = AES (x = dim_province_name, y = ratio)) +geom_bar (stat = ' identity ', fill = ' steelblue ', colour = ' black ') +geom_text (AES (label = ROUND (ratio,2)), Vjust = 1.5, colour = "white", size=2) #按ratio值的大小, rearrange the order of the bars by simply Aes () The properties in X are changed with the reorder () function. Ggplot (data = ls, mapping = AES (x = Reorder (dim_province_name,ratio), y = ratio)) +geom_bar (stat = ' identity ', fill = ' ste Elblue ', colour = ' black ') +geom_text (AES (label = ROUND (ratio,2)), Vjust = 1.5, colour = "white", size=2) +xlab (' Province ') l S is a collection of data frame types, in which I have stored a few variables, where dim_province_name, ratio is I used to write the x-axis and y-axis, placed in the AES box, if I want to sort, just the AES () in the X attribute with reorder () A function change is possible. Geom_bar is a bar chart, identity is independent do not make any changes can. Fills to fill the color, colour it for the border. Geom_text used to write labels, ratio the number of bits is too long, I used a round, only left two bits. Size to resize. Xlab to explain the x-axis annotations. Ggplot is a particularly tolerant drawing tool, feeling that as long as you remember his several parameters, he is always very kind and sincere to you. Oh, good. It feels like the Bible, is it a Buddhist sutra?!
Ggplot Draw Bar Chart