How to plot US 2020 elections with plotly
HTML-код
- Опубликовано: 5 фев 2025
- hello everyone, in this video we will use plotly express to plot a choropleth map showing the US 2020 Elections results.
Interested in learning Python, checkout the beginner Python courses here
How to Build GUI Apps with Python and Tkinter
www.udemy.com/...
Learn Python From Scratch and Build 10 Programs
www.udemy.com/...
A Practical Guide to Coding With Python
www.udemy.com/...
Thanks a lot great video and finally explained/written in easy understandable way(not like a lot of others that are over complicated ). Much appreciated helped a lot with my own US election project!
Thanks Richard, am glad i could help
Thank you very much for this wonderful video. You helped me a lot.
Not a single person is able to add annotations on the states like the name amd the data.
I added state names that appear on the map, so it visually displays the abbreviation for each state:
# add state abbreviations
fig.add_scattergeo(
locations=data_for_map['id'],
locationmode='USA-states',
text=data_for_map['id'],
mode='text',
textfont=dict(
color='white',
))
You can add this before doing fig.show()
Why couldn't you write locations= 'state' in place of 'usa_state_code'
well that's another way to do it! will try it out.