Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Case Analysis of ggplot2 relocation position

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

Most people do not understand the knowledge points of this "ggplot2 relocation position case Analysis" article, so the editor summarizes the following content, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "ggplot2 relocation position case Analysis" article.

The repositioning position of graphic elements is often involved in the geom () function (geometric object) of ggplot2. Different parameter adjustments can make the image show different effects. The main relocation involves the following ways:

Position describes dodge to avoid overlap, fill stacking graphic elements side by side and height standard 1identity without any adjustment jitter adding disturbance to points to avoid coincidence stack stacking graphic elements

Here is a brief demonstration of fill type relocation based on the same data.

> dat type Sample Num1 A sample1 902B sample1 343C sample1 564D sample1 995E sample1 156A sample2 507B sample2 208C sample2 249D sample2 7010 E sample2 14

Drawing

> datp = ggplot (dat, aes (x = type,y = Num,fill = Sample) + geom_bar (stat = "identity", width = 0.6 position = "fill") + scale_fill_manual (values = c ("red", "blue") + labs (x = "", y = ", title =" test ") + geom_text (label = dat$Num), position=position_fill (vjust = 0.5) Size = 5) + guides (fill = guide_legend (reverse = F)) + theme (plot.title = element_text (size = 25 bold = "bold", vjust = 0.5, hjust = 0.5), legend.title = element_blank (), legend.text = element_text (size = 18, face = "bold"), legend.position = 'right' Legend.key.size=unit (0.8 camera cm') print (p)

With the same code and different position, we can see the obvious difference among dodge, stack and fill.

The above is about the content of the article "ggplot2 relocation position example Analysis". I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please follow the industry information channel.

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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report