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

Introduction of R language Visualization area Map and its beautification method

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

This article mainly introduces "the introduction of R language visualization area map and its beautification method". In daily operation, I believe many people have doubts about the introduction of R language visualization area map and its beautification method. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the doubts about "the introduction of R language visualization area map and its beautification method". Next, please follow the editor to study!

What I want to share with you today is the area map, that is, the area map that is often mentioned.

This example selects a homemade dataset:

Head (data5)

Ggplot (data,aes (xQuery)) + geom_area (fill= "steelblue")

Ggplot (data5,aes (Year,Sale,fill=Fac)) + geom_area ()

By default, the relocation parameter of the area map after adding the classification variable is stacking: we can confirm it by adding the location parameter position:

Ggplot (data5,aes (Year,Sale,fill=Fac)) + geom_area (position= "stack")

The area map layer can be adjusted by adjusting the parameters in the position, as previously described:

Ggplot (data5,aes (Year,Sale,fill=Fac)) + geom_area (position= "identity", alpha=0.1)

# No position change is made, but it is inconvenient to read because the layers in the area map block each other.

Of course, the area map is not suitable to use the dodge parameter, the dodge parameter requires the Abscissa to be a discrete scale (that is, they cannot occlude each other)

Ggplot (data5,aes (Year,Sale,fill=Fac)) + geom_area (position= "dodge")

Ggplot (data5,aes (Year,Sale,fill=Fac)) + geom_area (position= "fill") # percentage stacking

Faceted expression:

Ggplot (data5,aes (Year,Sale,fill=Fac)) + geom_area (position= "stack") + facet_grid (. ~ Fac)

Ggplot (data5,aes (Year,Sale,fill=Fac)) + geom_area (position= "stack") + facet_wrap (~ Fac)

Pay attention to the difference between the two faceted forms:

Beautify:

Accumulation

Ggplot (data5,aes (Year,Sale,fill=Fac)) + geom_area (position= "stack") + ggtitle ("Area Plot") + theme_wsj () + scale_fill_wsj () + guides (fill=guide_legend (title=NULL))

Ggplot (data5,aes (Year,Sale,fill=Fac)) + geom_area (position= "stack") + ggtitle ("Area Plot") + theme_economist () + scale_fill_economist () + guides (fill=guide_legend (title=NULL))

Percentage accumulation:

Ggplot (data5,aes (Year,Sale,fill=Fac)) + geom_area (position= "fill") + ggtitle ("Area Plot") + theme_wsj () + scale_fill_wsj () + guides (fill=guide_legend (title=NULL))

Ggplot (data5,aes (Year,Sale,fill=Fac)) + geom_area (position= "fill") + ggtitle ("Area Plot") + theme_economist () + scale_fill_economist () + guides (fill=guide_legend (title=NULL))

Facet:

Ggplot (data5,aes (Year,Sale,fill=Fac)) + geom_area (position= "stack") + ggtitle ("Area Plot") + theme_wsj () + scale_fill_wsj () + guides (fill=guide_legend (title=NULL)) + facet_grid (. ~ Fac)

Ggplot (data5,aes (Year,Sale,fill=Fac)) + geom_area (position= "stack") + ggtitle ("Area Plot") + theme_economist () + scale_fill_economist () + guides (fill=guide_legend (title=NULL)) + facet_grid (. ~ Fac)

At this point, the study of "the introduction of R language visualization area map and its beautification method" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

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

Internet Technology

Wechat

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

12
Report