Ggplot Draw Bar Chart

Source: Internet
Author: User
Tags ggplot

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.