In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "the introduction of box diagram and its beautification skills in R language visualization". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Next let the editor to take you to learn "R language visualization box diagram introduction and its beautification skills" it!
Today, I would like to share with you how to use ggplot function to make box diagram and its beautification in R language.
Box chart is also an important type of chart that is often used to present the distribution of data.
Or take the dataset built into the ggplot2 package as an example to demonstrate:
Ggplot (mpg,aes (class,displ)) + geom_boxplot ()
The above is the simplest form, a classification variable, a continuous numerical type; we add classification variables, so that the box chart can present more data information.
Ggplot (diamonds,aes (cut,price,fill=color)) + geom_boxplot ()
Next, as usual, we use the switch of the position parameter to verify the usage rules of the position parameter of the boxplot chart:
Ggplot (diamonds,aes (cut,price,fill=color,alpha=1/30)) + geom_boxplot (position= "identity")
# when the position is set to not make any transformation, the classified box chart will be superimposed on the corresponding X-axis classification items, resulting in occlusion and reading inconvenience. This parameter is not recommended.
Ggplot (diamonds,aes (cut,price,fill=color)) + geom_boxplot (position= "stack")
From experience, we can guess that it is estimated that the stacking method to present the multi-dimensional box chart will certainly fail, because even if the classification box chart is really stacked, its function of presenting the data distribution pattern will be lost. sure enough, the software reported an error.
Ggplot (diamonds,aes (cut,price,fill=color)) + geom_boxplot (position= "dodge")
Sure enough, when adding multi-classification variables, the default position parameter used in the box chart is dodge.
Ggplot (diamonds,aes (cut,price,fill=color)) + geom_boxplot (position= "fill")
Similarly, it makes no sense to set the position parameter to the stacking percentage, and the software fails and warns you.
Ggplot (diamonds,aes (cut,price,fill=color)) + geom_boxplot () + facet_grid (. ~ color)
Ggplot (diamonds,aes (cut,price,fill=color)) + geom_boxplot () + facet_wrap (~ color)
Carefully understand the difference between the effects of the two facet functions:
Box diagram beautification:
Cluster:
Ggplot (diamonds,aes (cut,price,fill=color)) + geom_boxplot () + ggtitle ("Box Plot") + theme_wsj () + scale_fill_wsj () + guides (fill=guide_legend (title=NULL))
Ggplot (diamonds,aes (cut,price,fill=color)) + geom_boxplot () + ggtitle ("Box Plot") + theme_economist () + scale_fill_economist () + guides (fill=guide_legend (title=NULL))
Facet:
Ggplot (diamonds,aes (cut,price,fill=color)) + geom_boxplot () + ggtitle ("Box Plot") + theme_wsj () + scale_fill_wsj () + guides (fill=guide_legend (title=NULL)) + facet_grid (. ~ color)
Ggplot (diamonds,aes (cut,price,fill=color)) + geom_boxplot () + ggtitle ("Box Plot") + theme_economist () + scale_fill_economist () + guides (fill=guide_legend (title=NULL)) + facet_grid (. ~ color)
At this point, I believe you have a deeper understanding of the "R language visualization box diagram introduction and its beautification skills", might as well to the actual operation of it! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.