In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "how to draw the epidemic map of the United States with Python code". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to draw a map of the epidemic in the United States with Python code.
Some of the effects that can be drawn by Plotly are as follows
The map produced by Plotly looks like this, because the cumulative number of confirmed cases in New York is much higher than in other areas, so that's what you see.
First, let's install the required modules:
# install plotly module, install directly is the latest version, I use 4.5.4 pip install plotly
If the installation is slow or unsuccessful, you can use the following code to change to a domestic source address for installation
Pip install plotly-I https://pypi.tuna.tsinghua.edu.cn/simple
Then import the modules you need to use:
# Import the module import plotly.graph_objects as go import pandas as pd you need to use
Then the data is needed for import. The data is stored in the Excel table as follows:
Import data as follows:
# Import data df = pd.read_excel ('CGRG Pythonic Universe US. Xlsx imports recorder sheethammer nameplate recording 1')
Next, you can create the map and set the corresponding parameters, as follows:
Fig = go.Figure (data=go.Choropleth (locations=df ['code'], # set location State number (abbreviated) z = df ['conNum'] .astype (float), # set fill color data locationmode =' USA-states', # set country name colorscale = 'Reds', # legend color colorbar_title = "number", # legend title) fig.update_layout (title_text =' cumulative number of diagnosed in the United States', # map title geo_scope='usa' # set the range of the map to the United States # scope has "world" optional "usa", "europe", "asia", "africa", "north america", "south america")
Finally, the map is exported with the following code:
# Export the map to a html file fig.write_html ("C:/Python/US/US.html"). I believe you have a better understanding of "how to draw a map of the epidemic in the United States with Python code". You might as well do it in practice! 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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.