{"id":11183,"date":"2020-07-12T07:40:54","date_gmt":"2020-07-12T07:40:54","guid":{"rendered":"https:\/\/holypython.com\/?p=11183"},"modified":"2022-12-12T13:16:38","modified_gmt":"2022-12-12T13:16:38","slug":"how-to-create-map-charts-in-python-w-plotly-mapbox","status":"publish","type":"post","link":"https:\/\/holypython.com\/how-to-create-map-charts-in-python-w-plotly-mapbox\/","title":{"rendered":"How to Create Map Charts in Python (w\/ Plotly &#038; Mapbox)"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-post\" data-elementor-id=\"11183\" class=\"elementor elementor-11183\">\n\t\t\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-494a5f78 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"494a5f78\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-268a62aa\" data-id=\"268a62aa\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<section class=\"elementor-section elementor-inner-section elementor-element elementor-element-7b4a8994 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"7b4a8994\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-50 elementor-inner-column elementor-element elementor-element-1b6d2e09\" data-id=\"1b6d2e09\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-74c3697e elementor-widget elementor-widget-menu-anchor\" data-id=\"74c3697e\" data-element_type=\"widget\" data-widget_type=\"menu-anchor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"elementor-menu-anchor\" id=\"intro\"><\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-e013591 elementor-widget elementor-widget-text-editor\" data-id=\"e013591\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>This Python tutorial provides a detailed and practical step-by-step demonstration of Map Charts or Geomaps.<\/p><p>Geomaps are fantastic visual representation tools for interpreting and presenting data which includes location.<\/p><p>Data at hand that has some kind of location information attached to it can come in many forms, subjects and domains. Some examples are:<\/p><ul><li>Global events and phenomenon<ul><li>War<\/li><li>Conflict<\/li><li>Pandemic<\/li><li>Global warming<\/li><li>Space data<\/li><li>Immigration<\/li><li>Macroeconomics<\/li><li>Aerial\/Flight data<\/li><\/ul><\/li><li>Nature related events:<ul><li>Earthquare<\/li><li>Tsunami<\/li><li>Bird, fish, mammals migration<\/li><li>Solar data<\/li><li>Wind data<\/li><li>Precipitation data<\/li><\/ul><\/li><li>Socio-economic data:<ul><li>Trade data<\/li><li>Housing and Real Estate data<\/li><li>Jobs<\/li><li>Wages &amp; Salaries<\/li><li>Population<\/li><li>Energy data<\/li><li>Life Expectancy<\/li><\/ul><\/li><li>Tourism and culture:<ul><li>Festivals<\/li><li>Voyage<\/li><li>Celebrations<\/li><li>Holidays<\/li><li>Voyage<\/li><li>Backpacking<\/li><li>Image data<\/li><\/ul><\/li><\/ul><p>And the list goes on as we count more and more niche subjects. This type of data sometimes comes fully ready with coordinates but sometimes only location data included will be a city name, county name, country name, province name or open address.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t<div class=\"elementor-column elementor-col-50 elementor-inner-column elementor-element elementor-element-5a14331a\" data-id=\"5a14331a\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-6e06347c elementor-position-left elementor-view-default elementor-mobile-position-top elementor-vertical-align-top elementor-widget elementor-widget-icon-box\" data-id=\"6e06347c\" data-element_type=\"widget\" data-widget_type=\"icon-box.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"elementor-icon-box-wrapper\">\n\n\t\t\t\t\t\t<div class=\"elementor-icon-box-icon\">\n\t\t\t\t<span  class=\"elementor-icon\">\n\t\t\t\t<i aria-hidden=\"true\" class=\"far fa-clock\"><\/i>\t\t\t\t<\/span>\n\t\t\t<\/div>\n\t\t\t\n\t\t\t\t\t\t<div class=\"elementor-icon-box-content\">\n\n\t\t\t\t\t\t\t\t\t<h4 class=\"elementor-icon-box-title\">\n\t\t\t\t\t\t<span  >\n\t\t\t\t\t\t\tEstimated Time\t\t\t\t\t\t<\/span>\n\t\t\t\t\t<\/h4>\n\t\t\t\t\n\t\t\t\t\t\t\t\t\t<p class=\"elementor-icon-box-description\">\n\t\t\t\t\t\t20 mins\t\t\t\t\t<\/p>\n\t\t\t\t\n\t\t\t<\/div>\n\t\t\t\n\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-40a1ff4c elementor-widget elementor-widget-raven-divider\" data-id=\"40a1ff4c\" data-element_type=\"widget\" data-widget_type=\"raven-divider.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"raven-widget-wrapper\">\r\n\t\t\t<div class=\"raven-divider\">\r\n\t\t\t\t<span class=\"raven-divider-line raven-divider-solid\"><\/span>\r\n\t\t\t<\/div>\r\n\t\t<\/div>\r\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-77932d5e elementor-position-left elementor-view-default elementor-mobile-position-top elementor-vertical-align-top elementor-widget elementor-widget-icon-box\" data-id=\"77932d5e\" data-element_type=\"widget\" data-widget_type=\"icon-box.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"elementor-icon-box-wrapper\">\n\n\t\t\t\t\t\t<div class=\"elementor-icon-box-icon\">\n\t\t\t\t<span  class=\"elementor-icon\">\n\t\t\t\t<i aria-hidden=\"true\" class=\"far fa-thumbs-up\"><\/i>\t\t\t\t<\/span>\n\t\t\t<\/div>\n\t\t\t\n\t\t\t\t\t\t<div class=\"elementor-icon-box-content\">\n\n\t\t\t\t\t\t\t\t\t<h4 class=\"elementor-icon-box-title\">\n\t\t\t\t\t\t<span  >\n\t\t\t\t\t\t\tSkill Level\t\t\t\t\t\t<\/span>\n\t\t\t\t\t<\/h4>\n\t\t\t\t\n\t\t\t\t\t\t\t\t\t<p class=\"elementor-icon-box-description\">\n\t\t\t\t\t\tUpper-Intermediate\t\t\t\t\t<\/p>\n\t\t\t\t\n\t\t\t<\/div>\n\t\t\t\n\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-18877162 elementor-widget elementor-widget-raven-divider\" data-id=\"18877162\" data-element_type=\"widget\" data-widget_type=\"raven-divider.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"raven-widget-wrapper\">\r\n\t\t\t<div class=\"raven-divider\">\r\n\t\t\t\t<span class=\"raven-divider-line raven-divider-solid\"><\/span>\r\n\t\t\t<\/div>\r\n\t\t<\/div>\r\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-1c0485e4 elementor-position-left elementor-view-default elementor-mobile-position-top elementor-vertical-align-top elementor-widget elementor-widget-icon-box\" data-id=\"1c0485e4\" data-element_type=\"widget\" data-widget_type=\"icon-box.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"elementor-icon-box-wrapper\">\n\n\t\t\t\t\t\t<div class=\"elementor-icon-box-icon\">\n\t\t\t\t<span  class=\"elementor-icon\">\n\t\t\t\t<i aria-hidden=\"true\" class=\"far fa-bookmark\"><\/i>\t\t\t\t<\/span>\n\t\t\t<\/div>\n\t\t\t\n\t\t\t\t\t\t<div class=\"elementor-icon-box-content\">\n\n\t\t\t\t\t\t\t\t\t<h4 class=\"elementor-icon-box-title\">\n\t\t\t\t\t\t<span  >\n\t\t\t\t\t\t\tExercises\t\t\t\t\t\t<\/span>\n\t\t\t\t\t<\/h4>\n\t\t\t\t\n\t\t\t\t\t\t\t\t\t<p class=\"elementor-icon-box-description\">\n\t\t\t\t\t\tna\t\t\t\t\t<\/p>\n\t\t\t\t\n\t\t\t<\/div>\n\t\t\t\n\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-5552f07a elementor-widget elementor-widget-raven-divider\" data-id=\"5552f07a\" data-element_type=\"widget\" data-widget_type=\"raven-divider.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"raven-widget-wrapper\">\r\n\t\t\t<div class=\"raven-divider\">\r\n\t\t\t\t<span class=\"raven-divider-line raven-divider-solid\"><\/span>\r\n\t\t\t<\/div>\r\n\t\t<\/div>\r\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-7ab1a24a elementor-position-left elementor-vertical-align-middle elementor-view-default elementor-mobile-position-top elementor-widget elementor-widget-icon-box\" data-id=\"7ab1a24a\" data-element_type=\"widget\" data-widget_type=\"icon-box.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"elementor-icon-box-wrapper\">\n\n\t\t\t\t\t\t<div class=\"elementor-icon-box-icon\">\n\t\t\t\t<span  class=\"elementor-icon\">\n\t\t\t\t<i aria-hidden=\"true\" class=\"fas fa-book\"><\/i>\t\t\t\t<\/span>\n\t\t\t<\/div>\n\t\t\t\n\t\t\t\t\t\t<div class=\"elementor-icon-box-content\">\n\n\t\t\t\t\t\t\t\t\t<h4 class=\"elementor-icon-box-title\">\n\t\t\t\t\t\t<span  >\n\t\t\t\t\t\t\tContent Sections\t\t\t\t\t\t<\/span>\n\t\t\t\t\t<\/h4>\n\t\t\t\t\n\t\t\t\t\n\t\t\t<\/div>\n\t\t\t\n\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-1504b6e elementor-vertical-align-middle elementor-widget elementor-widget-icon-box\" data-id=\"1504b6e\" data-element_type=\"widget\" data-widget_type=\"icon-box.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"elementor-icon-box-wrapper\">\n\n\t\t\t\n\t\t\t\t\t\t<div class=\"elementor-icon-box-content\">\n\n\t\t\t\t\t\t\t\t\t<h4 class=\"elementor-icon-box-title\">\n\t\t\t\t\t\t<a href=\"#intro\" >\n\t\t\t\t\t\t\tIntroduction\t\t\t\t\t\t<\/a>\n\t\t\t\t\t<\/h4>\n\t\t\t\t\n\t\t\t\t\n\t\t\t<\/div>\n\t\t\t\n\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-9668384 elementor-vertical-align-middle elementor-widget elementor-widget-icon-box\" data-id=\"9668384\" data-element_type=\"widget\" data-widget_type=\"icon-box.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"elementor-icon-box-wrapper\">\n\n\t\t\t\n\t\t\t\t\t\t<div class=\"elementor-icon-box-content\">\n\n\t\t\t\t\t\t\t\t\t<h4 class=\"elementor-icon-box-title\">\n\t\t\t\t\t\t<a href=\"#mapbox\" >\n\t\t\t\t\t\t\tMap Services\t\t\t\t\t\t<\/a>\n\t\t\t\t\t<\/h4>\n\t\t\t\t\n\t\t\t\t\n\t\t\t<\/div>\n\t\t\t\n\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-a49b0c0 elementor-vertical-align-middle elementor-widget elementor-widget-icon-box\" data-id=\"a49b0c0\" data-element_type=\"widget\" data-widget_type=\"icon-box.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"elementor-icon-box-wrapper\">\n\n\t\t\t\n\t\t\t\t\t\t<div class=\"elementor-icon-box-content\">\n\n\t\t\t\t\t\t\t\t\t<h4 class=\"elementor-icon-box-title\">\n\t\t\t\t\t\t<a href=\"#steps\" >\n\t\t\t\t\t\t\tMap Chart Step-by-Step\t\t\t\t\t\t<\/a>\n\t\t\t\t\t<\/h4>\n\t\t\t\t\n\t\t\t\t\n\t\t\t<\/div>\n\t\t\t\n\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-ca11bf8 elementor-widget elementor-widget-raven-divider\" data-id=\"ca11bf8\" data-element_type=\"widget\" data-widget_type=\"raven-divider.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"raven-widget-wrapper\">\r\n\t\t\t<div class=\"raven-divider\">\r\n\t\t\t\t<span class=\"raven-divider-line raven-divider-solid\"><\/span>\r\n\t\t\t<\/div>\r\n\t\t<\/div>\r\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-a9bb82c elementor-vertical-align-middle elementor-widget elementor-widget-icon-box\" data-id=\"a9bb82c\" data-element_type=\"widget\" data-widget_type=\"icon-box.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"elementor-icon-box-wrapper\">\n\n\t\t\t\n\t\t\t\t\t\t<div class=\"elementor-icon-box-content\">\n\n\t\t\t\t\t\t\t\t\t<h4 class=\"elementor-icon-box-title\">\n\t\t\t\t\t\t<a href=\"#full\" >\n\t\t\t\t\t\t\tFull Code\t\t\t\t\t\t<\/a>\n\t\t\t\t\t<\/h4>\n\t\t\t\t\n\t\t\t\t\n\t\t\t<\/div>\n\t\t\t\n\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-0b5a752 elementor-vertical-align-middle elementor-widget elementor-widget-icon-box\" data-id=\"0b5a752\" data-element_type=\"widget\" data-widget_type=\"icon-box.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"elementor-icon-box-wrapper\">\n\n\t\t\t\n\t\t\t\t\t\t<div class=\"elementor-icon-box-content\">\n\n\t\t\t\t\t\t\t\t\t<h4 class=\"elementor-icon-box-title\">\n\t\t\t\t\t\t<a href=\"#embed\" >\n\t\t\t\t\t\t\tSaving & Embeding\t\t\t\t\t\t<\/a>\n\t\t\t\t\t<\/h4>\n\t\t\t\t\n\t\t\t\t\n\t\t\t<\/div>\n\t\t\t\n\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-764ac01 elementor-vertical-align-middle elementor-widget elementor-widget-icon-box\" data-id=\"764ac01\" data-element_type=\"widget\" data-widget_type=\"icon-box.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"elementor-icon-box-wrapper\">\n\n\t\t\t\n\t\t\t\t\t\t<div class=\"elementor-icon-box-content\">\n\n\t\t\t\t\t\t\t\t\t<h4 class=\"elementor-icon-box-title\">\n\t\t\t\t\t\t<a href=\"#anim\" >\n\t\t\t\t\t\t\tDemonstration\t\t\t\t\t\t<\/a>\n\t\t\t\t\t<\/h4>\n\t\t\t\t\n\t\t\t\t\n\t\t\t<\/div>\n\t\t\t\n\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-7726bbed elementor-widget elementor-widget-raven-divider\" data-id=\"7726bbed\" data-element_type=\"widget\" data-widget_type=\"raven-divider.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"raven-widget-wrapper\">\r\n\t\t\t<div class=\"raven-divider\">\r\n\t\t\t\t<span class=\"raven-divider-line raven-divider-solid\"><\/span>\r\n\t\t\t<\/div>\r\n\t\t<\/div>\r\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-6fc36f8 elementor-widget elementor-widget-image\" data-id=\"6fc36f8\" data-element_type=\"widget\" data-widget_type=\"image.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<img fetchpriority=\"high\" decoding=\"async\" width=\"398\" height=\"344\" src=\"https:\/\/holypython.com\/wp-content\/uploads\/2020\/10\/holypython_side_logo_img.jpg\" class=\"attachment-full size-full wp-image-15177\" alt=\"\" srcset=\"https:\/\/holypython.com\/wp-content\/uploads\/2020\/10\/holypython_side_logo_img.jpg 398w, https:\/\/holypython.com\/wp-content\/uploads\/2020\/10\/holypython_side_logo_img-300x259.jpg 300w\" sizes=\"(max-width: 398px) 100vw, 398px\" \/>\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<div class=\"elementor-element elementor-element-cfb4858 elementor-widget elementor-widget-text-editor\" data-id=\"cfb4858\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>In cases where you don&#8217;t have a latitude-longitude data available it becomes a joy rather than a chore to tackle this issue with Python.<\/p><p>We have a\u00a0<a href=\"https:\/\/holypython.com\/locations-in-python-geocoding-w-geopy\/\">tutorial about geocoding<\/a>, which is the process of getting coordinates from a location&#8217;s name or address, and reverse geocoding which is getting the address or name of a place from its coordinate points (latitude and longitude). Like most tasks this is handled elegantly in Python with the help of Geopy library.<\/p><p>You can also check out this\u00a0<a href=\"https:\/\/holypython.com\/how-to-create-plotly-animations-the-ultimate-guide\/\" target=\"_blank\" rel=\"noopener\">guide about\u00a0<span style=\"font-weight: bold;\"><i>creating\u00a0<\/i><\/span>Plotly animations<\/a>\u00a0to see some other Visualization options in Python.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-1a0322e8 elementor-widget elementor-widget-heading\" data-id=\"1a0322e8\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h3 class=\"elementor-heading-title elementor-size-default\">Used Where?<\/h3>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-bddefca elementor-widget elementor-widget-text-editor\" data-id=\"bddefca\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<ul><li>Exploring data<\/li><li>Presentations<\/li><li>Business Strategy<\/li><li>Science and Engineering<\/li><li>Research<\/li><li>Financial markets<\/li><li>Apps &amp; Software<\/li><li>Websites<\/li><\/ul>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-a0a8b5f elementor-widget elementor-widget-text-editor\" data-id=\"a0a8b5f\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>You can find the interactive\u00a0<b>Chart Map\u00a0<\/b>at the bottom of this page embedded\u00a0for demonstration<i>.<\/i><\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-3e2ff72 elementor-widget elementor-widget-menu-anchor\" data-id=\"3e2ff72\" data-element_type=\"widget\" data-widget_type=\"menu-anchor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"elementor-menu-anchor\" id=\"mapbox\"><\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<section class=\"elementor-section elementor-inner-section elementor-element elementor-element-252e1e2 elementor-section-content-middle elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"252e1e2\" data-element_type=\"section\" data-settings=\"{&quot;background_background&quot;:&quot;classic&quot;}\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-50 elementor-inner-column elementor-element elementor-element-28a0a4e\" data-id=\"28a0a4e\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-a5a2e55 elementor-view-default elementor-widget elementor-widget-icon\" data-id=\"a5a2e55\" data-element_type=\"widget\" data-widget_type=\"icon.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"elementor-icon-wrapper\">\n\t\t\t<div class=\"elementor-icon\">\n\t\t\t<i aria-hidden=\"true\" class=\"fas fa-code\"><\/i>\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t<div class=\"elementor-column elementor-col-50 elementor-inner-column elementor-element elementor-element-a8236c4\" data-id=\"a8236c4\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-2edaac4 elementor-widget elementor-widget-heading\" data-id=\"2edaac4\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\">Discovering the Map Service and Getting a Free Account<\/h2>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<div class=\"elementor-element elementor-element-4c52b84 elementor-widget elementor-widget-text-editor\" data-id=\"4c52b84\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>First of all we&#8217;ll use Mapbox API key for map services. So it might be useful to take care of that as first step. There are many different map services out there and it might make sense to invest some time and discover different benefits and costs when a commercial application is at hand.<\/p><p>But, Mapbox has a generous free account and it will be perfect for this tutorial.<\/p><p>You can sign up <a href=\"https:\/\/account.mapbox.com\/auth\/signup\/\" target=\"_blank\" rel=\"noopener\">here<\/a> and get a free account and API key.<\/p><p>We will read the API key from a file you can save as following: (named .<em><strong>mapbox_token\u00a0<\/strong><\/em>with no file extension)<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-95640f3 elementor-widget elementor-widget-html\" data-id=\"95640f3\" data-element_type=\"widget\" data-widget_type=\"html.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<pre rel=\"Python\"><code>px.set_mapbox_access_token(open(\".mapbox_token\").read())\r\n<\/code><\/pre>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-33938a9 elementor-widget elementor-widget-text-editor\" data-id=\"33938a9\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>Thankfully,\u00a0<a style=\"background-color: #ffffff;\" href=\"https:\/\/www.mapbox.com\" target=\"_blank\" rel=\"noopener\">Mapbox<\/a> has a generous free plan so you shouldn&#8217;t have to worry about billing unless you have a huge traffic.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-10f6cea elementor-widget elementor-widget-image\" data-id=\"10f6cea\" data-element_type=\"widget\" data-widget_type=\"image.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t<figure class=\"wp-caption\">\n\t\t\t\t\t\t\t\t\t\t<img decoding=\"async\" width=\"737\" height=\"753\" src=\"https:\/\/holypython.com\/wp-content\/uploads\/2020\/07\/mapbox-pricing.jpg\" class=\"attachment-large size-large wp-image-11302\" alt=\"\" srcset=\"https:\/\/holypython.com\/wp-content\/uploads\/2020\/07\/mapbox-pricing.jpg 737w, https:\/\/holypython.com\/wp-content\/uploads\/2020\/07\/mapbox-pricing-294x300.jpg 294w\" sizes=\"(max-width: 737px) 100vw, 737px\" \/>\t\t\t\t\t\t\t\t\t\t\t<figcaption class=\"widget-image-caption wp-caption-text\">Mapbox pricing sneak peak<\/figcaption>\n\t\t\t\t\t\t\t\t\t\t<\/figure>\n\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-635a9b0 elementor-widget elementor-widget-text-editor\" data-id=\"635a9b0\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p><em>You can find more about the pricing scheme here:\u00a0<a href=\"https:\/\/www.mapbox.com\/pricing\/\">Mapbox Pricing<\/a>.<\/em><\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-64802c5 elementor-widget elementor-widget-menu-anchor\" data-id=\"64802c5\" data-element_type=\"widget\" data-widget_type=\"menu-anchor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"elementor-menu-anchor\" id=\"steps\"><\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<section class=\"elementor-section elementor-inner-section elementor-element elementor-element-a16be5e elementor-section-content-middle elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"a16be5e\" data-element_type=\"section\" data-settings=\"{&quot;background_background&quot;:&quot;classic&quot;}\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-50 elementor-inner-column elementor-element elementor-element-1d539e2\" data-id=\"1d539e2\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-bdd7500 elementor-view-default elementor-widget elementor-widget-icon\" data-id=\"bdd7500\" data-element_type=\"widget\" data-widget_type=\"icon.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"elementor-icon-wrapper\">\n\t\t\t<div class=\"elementor-icon\">\n\t\t\t<i aria-hidden=\"true\" class=\"fas fa-code\"><\/i>\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t<div class=\"elementor-column elementor-col-50 elementor-inner-column elementor-element elementor-element-6a26139\" data-id=\"6a26139\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-45790f2 elementor-widget elementor-widget-heading\" data-id=\"45790f2\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\">Creating the map chart w\/Plotly (Step-by-step)<\/h2>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<div class=\"elementor-element elementor-element-5cca11a elementor-widget elementor-widget-text-editor\" data-id=\"5cca11a\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>Let&#8217;s split up the code first and investigate each part for a better understanding.<\/p><p>First you&#8217;ll need the libraries:<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-9a02a5f elementor-widget__width-auto elementor-widget elementor-widget-heading\" data-id=\"9a02a5f\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h3 class=\"elementor-heading-title elementor-size-default\">Prep & Reading Data (<i>libraries, data file, API token etc.<\/i>)<\/h3>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-43c07a2 elementor-widget elementor-widget-html\" data-id=\"43c07a2\" data-element_type=\"widget\" data-widget_type=\"html.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<pre rel=\"Python\"><code>import plotly\r\nimport plotly.express as px\r\nimport pandas as pd<\/code><\/pre>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-67b7aac elementor-widget elementor-widget-text-editor\" data-id=\"67b7aac\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>API Access Token will be needed as explained above, so, here is the code for that part:<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-38c1b5a elementor-widget elementor-widget-html\" data-id=\"38c1b5a\" data-element_type=\"widget\" data-widget_type=\"html.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<pre rel=\"Python\"><code>px.set_mapbox_access_token(open(\".mapbox_token\").read())\r\n<\/code><\/pre>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-d19fc10 elementor-widget elementor-widget-text-editor\" data-id=\"d19fc10\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>Then, also, a data file needs to be opened and read which will be used to create the map chart later. Sorry about the creative file name:<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-c1140fc elementor-widget elementor-widget-html\" data-id=\"c1140fc\" data-element_type=\"widget\" data-widget_type=\"html.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<pre rel=\"Python\"><code>f = 'ddd.xlsx'\ndf = pd.read_excel(f, index_col=0)<\/code><\/pre>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-77f3944 elementor-widget__width-auto elementor-widget elementor-widget-heading\" data-id=\"77f3944\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h3 class=\"elementor-heading-title elementor-size-default\">Heart of the operation (<i>Creating figure object<\/i>)<\/h3>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-8dfb8ca elementor-widget elementor-widget-text-editor\" data-id=\"8dfb8ca\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>At this point, we are ready to create the figure object that will represent the map chart using express module of plotly library.<\/p><p>Here are the main parameters that&#8217;s used in the creation of map chart:<\/p><ul><li><strong>df<\/strong> is the first argument representing dataframe containing input data<\/li><li><strong>lat<\/strong>: latitude data for each data point<\/li><li><strong>lon<\/strong>: longitude data for each data point<\/li><\/ul><p>Here are some optional parameters that are used that make the map much prettier and functional:<\/p><ul><li><strong>hover_name<\/strong>: Defines the data to be shown when mouse pointer is hovered over each data point.<\/li><li><strong>size<\/strong>: Points to data that sizes are based on<\/li><li><strong>color_continuous_scale<\/strong>: Applies an appropriate color scale of choice<\/li><li><strong>size_max<\/strong>: limits the maximum size of each data<\/li><li><strong>zoom<\/strong>: defines map zoom level upon loading. 1 is for most zoomed out map<\/li><\/ul>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-cc49ff3 elementor-widget elementor-widget-html\" data-id=\"cc49ff3\" data-element_type=\"widget\" data-widget_type=\"html.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<pre rel=\"Python\"><code>fig = px.scatter_mapbox(df, hover_name='location', lat=\"lat\", lon=\"lon\", size=\"total_deaths_per_million\", color=\"total_deaths_per_million\",\r\n                            color_continuous_scale=px.colors.sequential.Rainbow, size_max=30, zoom=2)<\/code><\/pre>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<section class=\"elementor-section elementor-inner-section elementor-element elementor-element-726a601 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"726a601\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-inner-column elementor-element elementor-element-fcffc28\" data-id=\"fcffc28\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-4a83abd elementor-widget__width-auto elementor-widget elementor-widget-heading\" data-id=\"4a83abd\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h3 class=\"elementor-heading-title elementor-size-default\">Map Styles & Layers (<i>mapbox_style and mapbox_layer<\/i>)<\/h3>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-fcbdc60 elementor-widget elementor-widget-text-editor\" data-id=\"fcbdc60\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>After that, there are different map styles you can apply to your map. Using <strong>mapbox_style<\/strong> is a great way to quickly give style to the map and it will dictate the overall map color scheme (this part is also known as lowest layer or base map). Here are some of the options you can try:<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-27cf084 elementor-widget elementor-widget-text-editor\" data-id=\"27cf084\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<ul><li>dark<\/li><li>open-street-map<\/li><li>white-bg<\/li><li>carto-positron<\/li><li>carto-darkmatter<\/li><li>stamen-terrain<\/li><li>stamen-toner<\/li><li>stamen-watercolor<\/li><li>basic<\/li><li>streets<\/li><li>outdoors<\/li><li>light<\/li><li>dark<\/li><li>satellite<\/li><li>satellite-streets<\/li><\/ul>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-89310e9 elementor-widget elementor-widget-html\" data-id=\"89310e9\" data-element_type=\"widget\" data-widget_type=\"html.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<pre rel=\"Python\"><code>fig.update_layout(mapbox_style=\"open-street-map\")\r\n<\/code><\/pre>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-f3fab6a elementor-widget elementor-widget-text-editor\" data-id=\"f3fab6a\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>Also layers of the map can be specifically assigned by using an external source. Here is an example using <em><strong>Nationalmap<\/strong><\/em> from U.S. Geological Survey&#8217;s (USGS) <a href=\"http:\/\/U.S. Geological Survey's (USGS)\" data-wplink-url-error=\"true\">National Geospatial Map<\/a>.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-00b4345 elementor-widget elementor-widget-html\" data-id=\"00b4345\" data-element_type=\"widget\" data-widget_type=\"html.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<pre rel=\"Python\"><code>    # fig.update_layout(\r\n    #     mapbox_style=\"white-bg\",\r\n    #     mapbox_layers=[\r\n    #         {\r\n    #             \"below\": 'traces',\r\n    #             \"sourcetype\": \"raster\",\r\n    #             \"source\": [\r\n    #                 \"https:\/\/basemap.nationalmap.gov\/arcgis\/rest\/services\/USGSImageryOnly\/MapServer\/tile\/{z}\/{y}\/{x}\"\r\n    #             ]\r\n    #         }\r\n    #       ])\r\n<\/code><\/pre>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-e460ba2 elementor-widget elementor-widget-text-editor\" data-id=\"e460ba2\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p><em>It&#8217;s commented out so in case you&#8217;d like to give it a try please remember to remove the sharp signs.<\/em><\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-9855bc1 elementor-widget__width-auto elementor-widget elementor-widget-heading\" data-id=\"9855bc1\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h3 class=\"elementor-heading-title elementor-size-default\">Saving map chart locally (<i>plotly.offline.plot<\/i>)<\/h3>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-c276192 elementor-widget elementor-widget-text-editor\" data-id=\"c276192\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>Finally, you can save the map chart locally as an html file by using the following code:<\/p><p><i>Just adjust the file path based on your needs.<\/i><\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-8919691 elementor-widget elementor-widget-html\" data-id=\"8919691\" data-element_type=\"widget\" data-widget_type=\"html.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<pre rel=\"Python\"><code>plotly.offline.plot(fig, filename=r'C:\/Users\/ABC\/Desktop\/map_chart.html')<\/code><\/pre>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-7460505 elementor-widget elementor-widget-menu-anchor\" data-id=\"7460505\" data-element_type=\"widget\" data-widget_type=\"menu-anchor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"elementor-menu-anchor\" id=\"full\"><\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-8c46039 elementor-widget__width-auto elementor-widget elementor-widget-heading\" data-id=\"8c46039\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h3 class=\"elementor-heading-title elementor-size-default\">Map Chart (<i>Full code<\/i>)<\/h3>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-b584d4d elementor-widget elementor-widget-text-editor\" data-id=\"b584d4d\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>It&#8217;s always a good idea to create a function when code is getting long or whenever it makes sense. This allows coder to not worry about correctness and integrity of each line during the development phase. You can just <span style=\"text-decoration-line: underline;\">comment out<\/span>\u00a0a single line where you call the function and nothing will be executed.<\/p><p>But there are many more benefits. It also allows easy reproduction, easier reading and gives structure to the overall program.<\/p><p>Here is the full code compartmentalized as a user-defined function for easier use and reproduction:<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<div class=\"elementor-element elementor-element-04b338a elementor-widget elementor-widget-html\" data-id=\"04b338a\" data-element_type=\"widget\" data-widget_type=\"html.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<pre rel=\"Python\"><code>def vijulize():\r\n    import plotly\r\n    import plotly.express as px\r\n    import pandas as pd\r\n    \r\n    px.set_mapbox_access_token(open(\".mapbox_token\").read())\r\n\r\n    f = 'ddd.xlsx'\r\n    \r\n    df = pd.read_excel(f, index_col=0)\r\n    fig = px.scatter_mapbox(df, hover_name='location', lat=\"lat\", lon=\"lon\", size=\"total_deaths_per_million\", color=\"total_deaths_per_million\",\r\n                            color_continuous_scale=px.colors.sequential.Rainbow, size_max=30, zoom=1)\r\n    \r\n    fig.update_layout(mapbox_style=\"dark\")\r\n    plotly.offline.plot(fig, filename=r'C:\/Users\/ABC\/Desktop\/map_chart.html')\r\n\r\nvijulize()<\/code><\/pre>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-880b1fd elementor-widget elementor-widget-text-editor\" data-id=\"880b1fd\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>If you take a look at the full code, here is a summary of what&#8217;s happening:<\/p><ul><li>First 3 lines inside function imports necessary libraries<\/li><li>Next authorization is handled with a file which includes our API key<\/li><li>Next file path including the data is defined<\/li><li>After that data is read using <strong>pd.read_excel<\/strong><\/li><\/ul><p>After these pre-figure steps, which mostly handle supportive tasks such as opening and reading data, authorization, libraries etc. there are 3 major steps in the code:<\/p><ul><li>Creating the figure as an object named <em><strong>fig<\/strong><\/em><\/li><li>Updating fig with a cool color scheme<\/li><li>Saving fig using <strong>plotly.offline.plot()<\/strong> method<\/li><\/ul>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-26f9e06 elementor-widget elementor-widget-menu-anchor\" data-id=\"26f9e06\" data-element_type=\"widget\" data-widget_type=\"menu-anchor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"elementor-menu-anchor\" id=\"embed\"><\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<section class=\"elementor-section elementor-inner-section elementor-element elementor-element-9817558 elementor-section-content-middle elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"9817558\" data-element_type=\"section\" data-settings=\"{&quot;background_background&quot;:&quot;classic&quot;}\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-50 elementor-inner-column elementor-element elementor-element-d5e2740\" data-id=\"d5e2740\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-fa63036 elementor-view-default elementor-widget elementor-widget-icon\" data-id=\"fa63036\" data-element_type=\"widget\" data-widget_type=\"icon.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"elementor-icon-wrapper\">\n\t\t\t<div class=\"elementor-icon\">\n\t\t\t<i aria-hidden=\"true\" class=\"fas fa-code\"><\/i>\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t<div class=\"elementor-column elementor-col-50 elementor-inner-column elementor-element elementor-element-547b48f\" data-id=\"547b48f\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-7d1e79a elementor-widget elementor-widget-heading\" data-id=\"7d1e79a\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\">Saving and Embedding Geomaps (Map Chart)<\/h2>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<div class=\"elementor-element elementor-element-9339833 elementor-widget elementor-widget-text-editor\" data-id=\"9339833\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>There are multiple methods and ways about saving a map chart created by Plotly. It&#8217;s up to you to discover, investigate and choose the method that makes most sense to your work or application.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-1aac3a7 elementor-widget__width-auto elementor-widget elementor-widget-heading\" data-id=\"1aac3a7\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h3 class=\"elementor-heading-title elementor-size-default\">Map Chart File Embedding Solutions (<i>html format<\/i>)<\/h3>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-3f1b7d3 elementor-widget elementor-widget-text-editor\" data-id=\"3f1b7d3\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>Commonly there are 2 distinct methods approaches:<\/p>\n<ul>\n<li>Saving charts, animations, maps as html, json, png, gif, jpg on local disks. (Offline method)<\/li>\n<li>Saving charts, animations, maps as html, json, png, gif, jpg on cloud, website or a server such as Chart Stuido, Github, Hosting Service, Dropbox, Google Drive etc.&nbsp; (Online method)<\/li>\n<\/ul>\n<div>As mentioned above, in this tutorial, we used the little code below to save the map chart as an html file locally first.<\/div>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-2c62215 elementor-widget elementor-widget-html\" data-id=\"2c62215\" data-element_type=\"widget\" data-widget_type=\"html.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<pre rel=\"Python\"><code>plotly.offline.plot(fig, filename=r'C:\/Users\/ABC\/Desktop\/map_chart.html')\r\n<\/code><\/pre>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-6d13849 elementor-widget elementor-widget-text-editor\" data-id=\"6d13849\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<div>After that, this html file was uploaded to HolyPython&#8217;s Github repository and embedded using iframe html tags.<\/div><div>\u00a0<\/div><div>We have a detailed tutorial about <b><i>Saving <\/i><\/b>Plotly Animations and Charts where you can lots of information about different saving methods, take a look here:\u00a0<a href=\"https:\/\/holypython.com\/how-to-save-plotly-animations-the-ultimate-guide\/\">How to save Plotly Charts and Animations<\/a><\/div><div>\u00a0<\/div><div>Here is an iframe example that can be used to embed an html file like at the bottom of this page.<\/div>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-8c9075a elementor-widget elementor-widget-text-editor\" data-id=\"8c9075a\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<pre>&lt;iframe width=\"900\" height=\"800\" frameborder=\"0\" scrollng=\"no\" src=\"https:\/\/holypython.github.io\/holypython2\/somefile.html\"&gt;&lt;\/iframe&gt;<\/pre>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-fbd756c elementor-widget elementor-widget-menu-anchor\" data-id=\"fbd756c\" data-element_type=\"widget\" data-widget_type=\"menu-anchor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"elementor-menu-anchor\" id=\"corp\"><\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<section class=\"elementor-section elementor-inner-section elementor-element elementor-element-d4cbb18 elementor-section-content-middle elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"d4cbb18\" data-element_type=\"section\" data-settings=\"{&quot;background_background&quot;:&quot;classic&quot;}\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-50 elementor-inner-column elementor-element elementor-element-753e9e3\" data-id=\"753e9e3\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-3866eb3 elementor-view-default elementor-widget elementor-widget-icon\" data-id=\"3866eb3\" data-element_type=\"widget\" data-widget_type=\"icon.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"elementor-icon-wrapper\">\n\t\t\t<div class=\"elementor-icon\">\n\t\t\t<i aria-hidden=\"true\" class=\"fas fa-code\"><\/i>\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t<div class=\"elementor-column elementor-col-50 elementor-inner-column elementor-element elementor-element-0e59648\" data-id=\"0e59648\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-a216f12 elementor-widget elementor-widget-heading\" data-id=\"a216f12\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\">Demonstration<\/h2>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<div class=\"elementor-element elementor-element-f6ba4d3 elementor-widget elementor-widget-text-editor\" data-id=\"f6ba4d3\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>Et voila! Map is ready to be presented. What do you think? Isn&#8217;t it beautiful. It&#8217;s just amazing how far we came in data visualization in recent years thanks to coding pioneers in the field such as Mapbox, Plotly, Geopy and many other libraries.<\/p><p>What do you think about the map? I found these points particularly interesting at first sight:<\/p><ul><li>U.S. doesn&#8217;t seem to be doing so bad as we&#8217;ve seen in this <a href=\"https:\/\/holypython.com\/how-to-create-plotly-animations-the-ultimate-guide\/\">tutorial<\/a> based on nominal numbers. Belgium is taking the biggest hit by far in that compartment.<\/li><li>Sweden&#8217;s death per million numbers are off the charts compared to its Nordic neighbors Norway, Denmark and Finland. Maybe it&#8217;s time to reconsider herd immunity arguments<\/li><li>Italy, France and the U.K. all seem to have high death per million numbers. Many culprits there likely: elderly population, lack of virutic epidemic experience in recent decades in the area (compared to Asian countries like Japan or South Korea), well established global travel, tourism and trade, transparent and honest case reporting etc. etc.<\/li><\/ul>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-eb8fd81 elementor-section-stretched elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"eb8fd81\" data-element_type=\"section\" data-settings=\"{&quot;stretch_section&quot;:&quot;section-stretched&quot;}\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-3013ae7\" data-id=\"3013ae7\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-a8fd3d1 elementor-widget elementor-widget-menu-anchor\" data-id=\"a8fd3d1\" data-element_type=\"widget\" data-widget_type=\"menu-anchor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"elementor-menu-anchor\" id=\"anim\"><\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-4fd52bf elementor-widget elementor-widget-html\" data-id=\"4fd52bf\" data-element_type=\"widget\" data-widget_type=\"html.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<iframe width=\"900\" height=\"800\" frameborder=\"0\" scrollng=\"no\" src=\"https:\/\/holypython.github.io\/holypython2\/covid_mapbox_chart.html\"><\/iframe>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<\/div>\n\t\t","protected":false},"excerpt":{"rendered":"<p>This Python tutorial provides a detailed and practical step-by-step demonstration of Map Charts or Geomaps. Geomaps are fantastic visual representation tools for interpreting and presenting data which includes location. Data at hand that has some kind of location information attached to it can come in many forms, subjects and domains. Some examples are: Global events [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":11262,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[35,52,63],"tags":[],"class_list":["post-11183","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-advanced","category-tutorials","category-visualization"],"acf":[],"_links":{"self":[{"href":"https:\/\/holypython.com\/wp-json\/wp\/v2\/posts\/11183","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/holypython.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/holypython.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/holypython.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/holypython.com\/wp-json\/wp\/v2\/comments?post=11183"}],"version-history":[{"count":0,"href":"https:\/\/holypython.com\/wp-json\/wp\/v2\/posts\/11183\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/holypython.com\/wp-json\/wp\/v2\/media\/11262"}],"wp:attachment":[{"href":"https:\/\/holypython.com\/wp-json\/wp\/v2\/media?parent=11183"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/holypython.com\/wp-json\/wp\/v2\/categories?post=11183"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/holypython.com\/wp-json\/wp\/v2\/tags?post=11183"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}