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 distinguish positive and negative Bar Chart and beautify ggplot2

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

Share

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

Ggplot2 how to distinguish between positive and negative bar charts and beautification, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain for you in detail, people with this need can come to learn, I hope you can gain something.

In the data analysis report, the bar chart is a very common form of expression, which can reflect the comparison between items. In the practical application, in order to be more direct and beautiful, there are higher and higher requirements for the display form of the chart. Through the powerful ggplot2 package, you can also draw distinctive bar charts.

When I saw the positive and negative bar chart drawn by someone on the Internet, I spent some time polishing the beautification details, and basically I drew it as it was.

Realization process

First, load the ggplot2 package and randomly generate two-dimensional data.

Next, use ggplot () + geom_bar () to draw the basic bar graph.

Here, the reorder () function is used to sort according to the size of the Difference value and the bar chart. At the same time, in this step, add a black border to each bar, adjust the width of the bar, and leave a gap in the middle.

Set the x and y axis label, y axis scale, and flip the axis.

So far, the basic form has been done, and then we will enter the process of fine beautification.

Do the following in turn:

Remove the gray background

Delete the specified mesh and border

Modify font

Finally, we modify the color and font of the legend, and add label text on both sides of the bar chart to get the final effect.

If you want the chart to look good, the use of tools is on the one hand, and the cultivation of aesthetics and chart thinking is also particularly important. It's a good way to learn from imitation.

Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

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