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

How to draw a waterfall with R language & EXCEL

2025-04-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

In this issue, the editor will bring you about how to draw waterfalls in R language & EXCEL. The article is rich in content and analyzes and narrates it from a professional point of view. I hope you can get something after reading this article.

Waterfall diagram is a process chart that makes one state evolve into another state under many reasons and factors. In this process, we can understand what are the main factors that lead to the change and the strength of the influence. There are three packages that can be done in R language, which are waterfall,waterfalls-based ggplot2 drawing system and rAmCharts (drawing dynamic interactive waterfall diagram). Finally, it introduces how to draw waterfall diagram with EXCEL.

1. Waterfall package drawing

This package draws the simplest waterfall diagram. It is not flexible enough to modify the properties of the picture. It is not recommended to use it only to understand it.

Library (waterfall)

Mydata=data.frame (Item=as.factor (c ('Before','Factor axiomagy) Factor Bobby, Factor Cohen, Factor D')

'Factor Eleven, Fine, and G')

Data=c (325,32mics, 105pr. 38pr. 86pr. 97232389).

Waterfallchart (Item~data,data=mydata)

2. Waterfalls package

This package is based on ggplot2, so all the functions of ggplot2 and the functions in its extension package can be used to modify the waterfall diagram. Another reason is that there is only one function in this package, waterfallchart, which contains more than 20 parameters that basically meet the requirements of drawing a waterfall diagram. If you want to further beautify the picture, you can refer to other functions in the ggplot2 family.

Library (waterfalls)

Library (ggplot2)

Library (ggthemes)

Waterfall (.data = mydata

Rect_text_labels = paste (levels (mydata$Item),'\ nMy data)

Fill_colours = c ('darkslateblue','chocolate','chocolate','chartreuse'

'chartreuse','chartreuse','chartreuse','chartreuse')

Calc_total = TRUE, total_rect_color = "darkslateblue"

Total_rect_text = paste ('After','\ nsum (mydata$data))

Total_rect_text_color = "black"

Total_axis_text = "After"

Rect_width = 0.9

Draw_axis.x = "behind"

Rect_border = "white"

Fill_by_sign = FALSE) +

Theme_map () +

Geom_hline (yintercept = 0, colour = 'skyblue')

III. RAmCharts

This package can make a dynamic waterfall diagram, but the difficulty lies in the construction of the data form, with an extra column of symbols.

Mydata=data.frame ("label=c") ('Before','Factor Aids,' factors', factors, D'.

'Factor EffectiveFormula Fengfei Fengfei Factor Gongji after')

Value=c (325, 32, 105, 38, 86, 97, 232, 389, 1030)

Operation=c ('total','minus','minus','plus','plus','plus','plus','plus','total'))

AmWaterfall (data = mydata, show_values = TRUE

4. Use EXCEL to make

Select all the columns except the shaded section and click to insert the stacked bar chart, where the data formula for the Dummy column

= IF (B3

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