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

What is the implementation method of hierarchical display of multiple variables of tidyr and ggplot2 in R language data visualization?

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

Share

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

This article mainly talks about "R language data visualization tidyr and ggplot2 multi-variable hierarchical display of what is the implementation method", 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 data visualization tidyr and ggplot2 multi-variable hierarchical display of what is the implementation of it?"

In the common drawing of R language, the subgraph of different variables can be realized on a graph by using the par () parameter. If we want to implement it in ggplot2, we need to sort out our raw data, which is usually very troublesome, and we need to use our tidyr to help us draw.

It may not be easy to understand the above paragraph, let's give an example of chestnut.

Density distribution of each variable y1% ggplot (aes (x = value)) + geom_histogram (fill = factor (var), y =.. density..), alpha = 0.3, colour = 'black') + stat_density (geom =' line', position = 'identity', size = 1.5, aes (colour = factor (var) + facet_wrap (~ var) Ncol = 2) + labs (y = 'histogram and density curve', x = 'value', title = 'title', fill = 'variable') + theme (plot.title = element_text (hjust = 0.5)) + guides (color = FALSE)

Here are basically the previous blogs: r language learning ggplot2 drawing statistical graphics package is mentioned in a comprehensive detailed explanation.

The only one is guides (color = FALSE), which represents the legend of the hidden line color, because the color of the line is specified with color =. Similarly, if you want to hide a legend with histogram colors, you can use guides (fill = FALSE).

At this point, I believe you have a deeper understanding of "R language data visualization tidyr and ggplot2 multi-variable hierarchical display of what is the implementation method", 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.

Share To

Development

Wechat

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

12
Report