[PYTHON] Vertically visualize the amount corresponding to the vertices of networkx using Axes3D

As the title suggests, when using networkx, there are some problems with visualization. For example

--When the real value corresponds to the node → Change the size (s) of the node --When discrete values correspond to the node → Change the color of the node

It can be easily distinguished by the feeling, but it is often difficult to read the numerical values well only in two dimensions. Here, I used Axes3D of matplotlib and tried to visualize it by cutting corners as much as possible. As an example, take the latitude and longitude of the location of the prefectural office in Kanto, and consider that the population of each prefecture is on each point. I visualized it as follows.

2D 3D
plot2d.png anim.gif

data

I took it properly (reference: https://www.benricho.org/chimei/latlng_data.html). I made the connection properly. I appologize if I am mistaken.

8,Ibaraki Prefecture,36.34139,140.44667,2868041
9,Tochigi Prefecture,36.56583,139.88361,1942312
10,Gunma Prefecture,36.39111,139.06083,1937626
11,Saitama,35.85694,139.64889,7337330
12,Chiba,35.60472,140.12333,6279026
13,Tokyo,35.68944,139.69167,13942856
14,Kanagawa Prefecture,35.44778,139.6425,9200166
8,9
8,11
8,12
9,8
9,10
9,12
10,9
10,11
11,8
11,9
11,10
11,12
11,13
13,12
13,14
14,13

Implementation

I use Axes3D, but networkx drawing functions such as nx.draw get angry even if I pass Axes3D. Therefore, I decided to forcibly draw by inputting the data in the z-axis direction. In particular

--Set the point where the graph is drawn to $ z = 0 $ --Draw the number corresponding to the node on the $ z $ axis

It is said. The result obtained in this way is shown in the figure above.

https://github.com/cocomoff/PlotMapHeight

Recommended Posts

Vertically visualize the amount corresponding to the vertices of networkx using Axes3D
How to visualize the decision tree model of scikit-learn
Python practice 100 knocks I tried to visualize the decision tree of Chapter 5 using graphviz
I tried to visualize the spacha information of VTuber
The story of using circleci to build manylinux wheels
How to calculate the amount of calculation learned from ABC134-D
[Python] I tried to visualize the follow relationship of Twitter
[TF] I tried to visualize the learning result using Tensorboard
Visualize the orbit of Hayabusa2
[Note] Let's try to predict the amount of electricity used! (Part 1)
I tried to get the index of the list using the enumerate function
I tried to make a regular expression of "amount" using Python
I wanted to challenge the classification of CIFAR-10 using Chainer's trainer
I tried to visualize the common condition of VTuber channel viewers
Visualize the response status of the census 2020
Supplement to the explanation of vscode
I tried to transform the face image using sparse_image_warp of TensorFlow Addons
I tried to get the batting results of Hachinai using image processing
I tried to visualize the age group and rate distribution of Atcoder
I tried to estimate the similarity of the question intent using gensim's Doc2Vec
How to find out the number of CPUs without using the sar command
Try to get the road surface condition using big data of road surface management
I tried to extract and illustrate the stage of the story using COTOHA
Try using n to downgrade the version of Node.js you have installed
I tried to visualize the text of the novel "Weathering with You" with WordCloud
Trial to judge the timing of the progress display of the for loop using 0b1111 ~
I tried the common story of using Deep Learning to predict the Nikkei 225
Using COTOHA, I tried to follow the emotional course of Run, Melos!