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 use R language ggplot2 to draw Network Diagram

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

Share

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

This article shows you how to use the R language ggplot2 to draw a network diagram, the content is concise and easy to understand, it can definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.

The picture to be imitated today comes from the paper Core gut microbial communities are maintained by beneficial interactions and strain variability in fish. The journal is Nature microbiology.

Image.png

Image.png

I have previously shared two tweets that draw network diagrams using ggraph in R language.

A small example of R language Network Graph

Another small example of using R language to do network diagram

(click the above blue font to go directly to the tweet content)

But the network diagram in today's paper is two two circular layouts. I don't know how to implement this with ggraph package.

After thinking about it carefully, this network diagram is a combination of dots and lines, which should be easily implemented using the geom_point () and geom_segment () functions of the ggplot2 package. Because it is a circular layout, the coordinates of the scattered points are generated directly by the circular function. If you have an idea, let's make it happen.

The first is to construct the dataset

The position coordinate of the scattered point is generated by a circular function, and the center of the circle is (0) and the radius is 4, resulting in a total of 32 points.

A

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