{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "![Callysto.ca Banner](https://github.com/callysto/curriculum-notebooks/blob/master/callysto-notebook-banner-top.jpg?raw=true)\n", "\n", "\"Open" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Geographic Progression of The American Revolution\n", "\n", "\n", "The American Revolution (1775-83) is also known as the American Revolutionary War and the U.S. War of Independence. \n", "\n", "On July 4, 1776, America's Thirteen Colonies declared that they were no longer part of Britain. The British disagreed. A war between Britain and the Thirteen Colonies began as a result of this disagreement. This war was known as the American Revolution or the War of Independence. (From \"Our Land and People\", Patricia Shields-Ramsay, Douglas Ramsay)\n", "\n", "\n", "> ![map of colonies](images/13_colonies.jpg)\n", ">\n", "> The location of the original thirteen English Colonies on the east coast of what is now known as the United States of America. \n", "\n", "In order to understand the origins and progression of the American Revolutionary War, we will look at the locations of various battles during each stage of the war. From this data, we can begin to understand where the battles were taking place, where they moved to, and try and understand the events surrounding them. To begin, we first need to download [an open data set from Wikipedia](https://en.wikipedia.org/wiki/List_of_American_Revolutionary_War_battles) that contains the locations and other information about the battles.\n", "\n", "Select the code cell below, then click the `▶Run` button in the toolbar to download and display the data." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
BattleDateColony/StateOutcome
0Powder Alarm*September 1, 1774MassachusettsBritish soldiers remove military supplies
1Storming of Fort William and Mary*December 14, 1774New HampshirePatriots seize powder and shot after brief ski...
2Battles of Lexington and ConcordApril 19, 1775MassachusettsPatriot victory: British forces raiding Concor...
3Siege of BostonApril 19, 1775 –March 17, 1776MassachusettsPatriot victory: British eventually evacuate B...
4Gunpowder Incident*April 20, 1775VirginiaVirginia governor Lord Dunmore removes powder ...
...............
253Action of 2 January 1783January 2, 1783HispaniolaInconclusive
254Action of 22 January 1783January 22, 1783VirginiaBritish victory
255Action of 15 February 1783February 15, 1783GuadeloupeBritish victory
256Action of 17 February 178317 February 1783CubaBritish victory
257Recapture of the Bahamas14–18 April 1783BahamasBritish victory
\n", "

258 rows × 4 columns

\n", "
" ], "text/plain": [ " Battle Date \\\n", "0 Powder Alarm* September 1, 1774 \n", "1 Storming of Fort William and Mary* December 14, 1774 \n", "2 Battles of Lexington and Concord April 19, 1775 \n", "3 Siege of Boston April 19, 1775 –March 17, 1776 \n", "4 Gunpowder Incident* April 20, 1775 \n", ".. ... ... \n", "253 Action of 2 January 1783 January 2, 1783 \n", "254 Action of 22 January 1783 January 22, 1783 \n", "255 Action of 15 February 1783 February 15, 1783 \n", "256 Action of 17 February 1783 17 February 1783 \n", "257 Recapture of the Bahamas 14–18 April 1783 \n", "\n", " Colony/State Outcome \n", "0 Massachusetts British soldiers remove military supplies \n", "1 New Hampshire Patriots seize powder and shot after brief ski... \n", "2 Massachusetts Patriot victory: British forces raiding Concor... \n", "3 Massachusetts Patriot victory: British eventually evacuate B... \n", "4 Virginia Virginia governor Lord Dunmore removes powder ... \n", ".. ... ... \n", "253 Hispaniola Inconclusive \n", "254 Virginia British victory \n", "255 Guadeloupe British victory \n", "256 Cuba British victory \n", "257 Bahamas British victory \n", "\n", "[258 rows x 4 columns]" ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "url = 'https://en.wikipedia.org/wiki/List_of_American_Revolutionary_War_battles'\n", "import pandas as pd\n", "revolution_data = pd.read_html(url)[17] # get the 18th table from the page\n", "revolution_data" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "From the table above we see that there is a lot of information to digest. There are 253 rows and four columns. The columns are the name of the battle, the date of the battle, where it took place, and the consequences of that battle.\n", "\n", "Next we are going to look up latitude and longitude values for each of the listed locations." ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
LocationCoordinates
MassachusettsMassachusetts, United States of America(42.3788774, -72.032366)
New HampshireNew Hampshire, United States of America(43.4849133, -71.6553992)
VirginiaVirginia, United States of America(37.1232245, -78.4927721)
New YorkNew York, United States of America(40.7127281, -74.0060152)
QuebecQuébec, Canada(52.4760892, -71.8258668)
.........
Delaware BayDelaware Bay, Cumberland County, New Jersey, U...(39.247595399999994, -75.30105997051399)
HispaniolaLa Hispaniola, Constanza, La Vega, República D...(18.77858115, -70.5427697709766)
Cape MayCape May, Cape May County, New Jersey, 18204, ...(38.9351126, -74.9060053)
GuadeloupeGuadeloupe, France(16.2490067, -61.5650444)
CubaCuba(23.0131338, -80.8328748)
\n", "

62 rows × 2 columns

\n", "
" ], "text/plain": [ " Location \\\n", "Massachusetts Massachusetts, United States of America \n", "New Hampshire New Hampshire, United States of America \n", "Virginia Virginia, United States of America \n", "New York New York, United States of America \n", "Quebec Québec, Canada \n", "... ... \n", "Delaware Bay Delaware Bay, Cumberland County, New Jersey, U... \n", "Hispaniola La Hispaniola, Constanza, La Vega, República D... \n", "Cape May Cape May, Cape May County, New Jersey, 18204, ... \n", "Guadeloupe Guadeloupe, France \n", "Cuba Cuba \n", "\n", " Coordinates \n", "Massachusetts (42.3788774, -72.032366) \n", "New Hampshire (43.4849133, -71.6553992) \n", "Virginia (37.1232245, -78.4927721) \n", "New York (40.7127281, -74.0060152) \n", "Quebec (52.4760892, -71.8258668) \n", "... ... \n", "Delaware Bay (39.247595399999994, -75.30105997051399) \n", "Hispaniola (18.77858115, -70.5427697709766) \n", "Cape May (38.9351126, -74.9060053) \n", "Guadeloupe (16.2490067, -61.5650444) \n", "Cuba (23.0131338, -80.8328748) \n", "\n", "[62 rows x 2 columns]" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# import and set up libraries\n", "!pip install geopy --user\n", "from geopy.geocoders import Nominatim\n", "from geopy.extra.rate_limiter import RateLimiter\n", "locator = Nominatim(user_agent='Callysto Geocoder')\n", "geocode = RateLimiter(locator.geocode, min_delay_seconds=.1)\n", "location_data_dictionary = {} # an empty dictionary that we will add to\n", "# loop through the unique locations in the previous dataframe and geocode their location\n", "for place in revolution_data['Colony/State'].unique():\n", " #location = locator.geocode(place) # without rate limiting\n", " location = geocode(place)\n", " print(location)\n", " location_data_dictionary.update({place:location})\n", "# clear the screen of the progress we were printing\n", "from IPython import display\n", "display.clear_output()\n", "# create the dataframe\n", "location_data = pd.DataFrame(data=location_data_dictionary).transpose()\n", "location_data.rename(columns={0:'Location', 1:'Coordinates'}, inplace=True)\n", "location_data" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Geographic View of The American Revolution\n", "\n", "Now that we have some location data about the Revolutionary War battles, let's put it on a map." ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
Make this Notebook Trusted to load map: File -> Trust Notebook
" ], "text/plain": [ "" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# join our two dataframes together\n", "map_data = revolution_data.join(location_data, on='Colony/State')\n", "# split the Coordinates column into Latitude and Longitude\n", "map_data[['Latitude','Longitude']] = pd.DataFrame(map_data['Coordinates'].tolist(), index=map_data.index)\n", "# create the map\n", "import folium\n", "battle_map = folium.Map(location=[50, -50], zoom_start=2)\n", "for i, row in map_data.iterrows():\n", " location=[row['Latitude'], row['Longitude']]\n", " battle_map.add_child(folium.Marker(location, tooltip=row['Battle'], popup=row['Date']))\n", "battle_map" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "It is interesting to note that that not all of the battles took place in the United States.\n", "\n", "We can list the battles that took place in Canada." ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
BattleDateColony/StateOutcomeLocationCoordinatesLatitudeLongitude
10Siege of Fort St. JeanSeptember 17 –November 3, 1775QuebecPatriot victory: Patriots capture British forc...Québec, Canada(52.4760892, -71.8258668)52.476089-71.825867
11Battle of Longue-PointeSeptember 25, 1775QuebecBritish victoryQuébec, Canada(52.4760892, -71.8258668)52.476089-71.825867
18Battle of QuebecDecember 31, 1775QuebecBritish victory: British repulse Patriot assau...Québec, Canada(52.4760892, -71.8258668)52.476089-71.825867
23Battle of Saint-PierreMarch 25, 1776QuebecPatriot victoryQuébec, Canada(52.4760892, -71.8258668)52.476089-71.825867
25Battle of The CedarsMay 18–27, 1776QuebecBritish victoryQuébec, Canada(52.4760892, -71.8258668)52.476089-71.825867
26Battle of Trois-RivièresJune 8, 1776QuebecBritish victory: Patriots forced to evacuate Q...Québec, Canada(52.4760892, -71.8258668)52.476089-71.825867
37Battle of Fort CumberlandNovember 10–29, 1776Nova ScotiaBritish victoryNova Scotia, Canada(45.1960403, -63.1653789)45.196040-63.165379
107Battle of ChillicotheMay 1779QuebecPatriot victoryQuébec, Canada(52.4760892, -71.8258668)52.476089-71.825867
154Battle of PekoweeAugust 8, 1780QuebecPatriot victoryQuébec, Canada(52.4760892, -71.8258668)52.476089-71.825867
170La Balme's DefeatNovember 5, 1780QuebecBritish-Iroquois victoryQuébec, Canada(52.4760892, -71.8258668)52.476089-71.825867
199Naval battle of LouisbourgJuly 21, 1781Nova ScotiaFranco-Patriot victoryNova Scotia, Canada(45.1960403, -63.1653789)45.196040-63.165379
203Lochry's DefeatAugust 24, 1781QuebecBritish-Iroquois victoryQuébec, Canada(52.4760892, -71.8258668)52.476089-71.825867
234Crawford expeditionMay 25-June 12, 1782QuebecBritish-Iroquois victoryQuébec, Canada(52.4760892, -71.8258668)52.476089-71.825867
235Naval battle off HalifaxMay 28–29, 1782Nova ScotiaBritish victoryNova Scotia, Canada(45.1960403, -63.1653789)45.196040-63.165379
236Raid on ChesterJune 30, 1782Chester, Nova ScotiaBritish victoryChester, Chester District Municipality, Nova S...(44.5413322, -64.2411853)44.541332-64.241185
237Raid on LunenburgJuly 1, 1782Nova ScotiaPatriot victoryNova Scotia, Canada(45.1960403, -63.1653789)45.196040-63.165379
239Hudson Bay ExpeditionAugust 8, 1782Rupert's LandFranco-Patriot victoryAnglican Centre, Diocese of Rupert's Land, 935...(49.8345313, -97.14746377135569)49.834531-97.147464
\n", "
" ], "text/plain": [ " Battle Date \\\n", "10 Siege of Fort St. Jean September 17 –November 3, 1775 \n", "11 Battle of Longue-Pointe September 25, 1775 \n", "18 Battle of Quebec December 31, 1775 \n", "23 Battle of Saint-Pierre March 25, 1776 \n", "25 Battle of The Cedars May 18–27, 1776 \n", "26 Battle of Trois-Rivières June 8, 1776 \n", "37 Battle of Fort Cumberland November 10–29, 1776 \n", "107 Battle of Chillicothe May 1779 \n", "154 Battle of Pekowee August 8, 1780 \n", "170 La Balme's Defeat November 5, 1780 \n", "199 Naval battle of Louisbourg July 21, 1781 \n", "203 Lochry's Defeat August 24, 1781 \n", "234 Crawford expedition May 25-June 12, 1782 \n", "235 Naval battle off Halifax May 28–29, 1782 \n", "236 Raid on Chester June 30, 1782 \n", "237 Raid on Lunenburg July 1, 1782 \n", "239 Hudson Bay Expedition August 8, 1782 \n", "\n", " Colony/State Outcome \\\n", "10 Quebec Patriot victory: Patriots capture British forc... \n", "11 Quebec British victory \n", "18 Quebec British victory: British repulse Patriot assau... \n", "23 Quebec Patriot victory \n", "25 Quebec British victory \n", "26 Quebec British victory: Patriots forced to evacuate Q... \n", "37 Nova Scotia British victory \n", "107 Quebec Patriot victory \n", "154 Quebec Patriot victory \n", "170 Quebec British-Iroquois victory \n", "199 Nova Scotia Franco-Patriot victory \n", "203 Quebec British-Iroquois victory \n", "234 Quebec British-Iroquois victory \n", "235 Nova Scotia British victory \n", "236 Chester, Nova Scotia British victory \n", "237 Nova Scotia Patriot victory \n", "239 Rupert's Land Franco-Patriot victory \n", "\n", " Location \\\n", "10 Québec, Canada \n", "11 Québec, Canada \n", "18 Québec, Canada \n", "23 Québec, Canada \n", "25 Québec, Canada \n", "26 Québec, Canada \n", "37 Nova Scotia, Canada \n", "107 Québec, Canada \n", "154 Québec, Canada \n", "170 Québec, Canada \n", "199 Nova Scotia, Canada \n", "203 Québec, Canada \n", "234 Québec, Canada \n", "235 Nova Scotia, Canada \n", "236 Chester, Chester District Municipality, Nova S... \n", "237 Nova Scotia, Canada \n", "239 Anglican Centre, Diocese of Rupert's Land, 935... \n", "\n", " Coordinates Latitude Longitude \n", "10 (52.4760892, -71.8258668) 52.476089 -71.825867 \n", "11 (52.4760892, -71.8258668) 52.476089 -71.825867 \n", "18 (52.4760892, -71.8258668) 52.476089 -71.825867 \n", "23 (52.4760892, -71.8258668) 52.476089 -71.825867 \n", "25 (52.4760892, -71.8258668) 52.476089 -71.825867 \n", "26 (52.4760892, -71.8258668) 52.476089 -71.825867 \n", "37 (45.1960403, -63.1653789) 45.196040 -63.165379 \n", "107 (52.4760892, -71.8258668) 52.476089 -71.825867 \n", "154 (52.4760892, -71.8258668) 52.476089 -71.825867 \n", "170 (52.4760892, -71.8258668) 52.476089 -71.825867 \n", "199 (45.1960403, -63.1653789) 45.196040 -63.165379 \n", "203 (52.4760892, -71.8258668) 52.476089 -71.825867 \n", "234 (52.4760892, -71.8258668) 52.476089 -71.825867 \n", "235 (45.1960403, -63.1653789) 45.196040 -63.165379 \n", "236 (44.5413322, -64.2411853) 44.541332 -64.241185 \n", "237 (45.1960403, -63.1653789) 45.196040 -63.165379 \n", "239 (49.8345313, -97.14746377135569) 49.834531 -97.147464 " ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "map_data[map_data['Location'].str.contains('Canada')]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We are also interested in looking at the battles by year, so we will create a `year` column from the last four characters of the `Date` column." ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
BattleDateColony/StateOutcomeLocationCoordinatesLatitudeLongitudeYear
0Powder Alarm*September 1, 1774MassachusettsBritish soldiers remove military suppliesMassachusetts, United States of America(42.3788774, -72.032366)42.378877-72.0323661774
1Storming of Fort William and Mary*December 14, 1774New HampshirePatriots seize powder and shot after brief ski...New Hampshire, United States of America(43.4849133, -71.6553992)43.484913-71.6553991774
2Battles of Lexington and ConcordApril 19, 1775MassachusettsPatriot victory: British forces raiding Concor...Massachusetts, United States of America(42.3788774, -72.032366)42.378877-72.0323661775
3Siege of BostonApril 19, 1775 –March 17, 1776MassachusettsPatriot victory: British eventually evacuate B...Massachusetts, United States of America(42.3788774, -72.032366)42.378877-72.0323661776
4Gunpowder Incident*April 20, 1775VirginiaVirginia governor Lord Dunmore removes powder ...Virginia, United States of America(37.1232245, -78.4927721)37.123224-78.4927721775
..............................
253Action of 2 January 1783January 2, 1783HispaniolaInconclusiveLa Hispaniola, Constanza, La Vega, República D...(18.77858115, -70.5427697709766)18.778581-70.5427701783
254Action of 22 January 1783January 22, 1783VirginiaBritish victoryVirginia, United States of America(37.1232245, -78.4927721)37.123224-78.4927721783
255Action of 15 February 1783February 15, 1783GuadeloupeBritish victoryGuadeloupe, France(16.2490067, -61.5650444)16.249007-61.5650441783
256Action of 17 February 178317 February 1783CubaBritish victoryCuba(23.0131338, -80.8328748)23.013134-80.8328751783
257Recapture of the Bahamas14–18 April 1783BahamasBritish victoryThe Bahamas(24.7736546, -78.0000547)24.773655-78.0000551783
\n", "

258 rows × 9 columns

\n", "
" ], "text/plain": [ " Battle Date \\\n", "0 Powder Alarm* September 1, 1774 \n", "1 Storming of Fort William and Mary* December 14, 1774 \n", "2 Battles of Lexington and Concord April 19, 1775 \n", "3 Siege of Boston April 19, 1775 –March 17, 1776 \n", "4 Gunpowder Incident* April 20, 1775 \n", ".. ... ... \n", "253 Action of 2 January 1783 January 2, 1783 \n", "254 Action of 22 January 1783 January 22, 1783 \n", "255 Action of 15 February 1783 February 15, 1783 \n", "256 Action of 17 February 1783 17 February 1783 \n", "257 Recapture of the Bahamas 14–18 April 1783 \n", "\n", " Colony/State Outcome \\\n", "0 Massachusetts British soldiers remove military supplies \n", "1 New Hampshire Patriots seize powder and shot after brief ski... \n", "2 Massachusetts Patriot victory: British forces raiding Concor... \n", "3 Massachusetts Patriot victory: British eventually evacuate B... \n", "4 Virginia Virginia governor Lord Dunmore removes powder ... \n", ".. ... ... \n", "253 Hispaniola Inconclusive \n", "254 Virginia British victory \n", "255 Guadeloupe British victory \n", "256 Cuba British victory \n", "257 Bahamas British victory \n", "\n", " Location \\\n", "0 Massachusetts, United States of America \n", "1 New Hampshire, United States of America \n", "2 Massachusetts, United States of America \n", "3 Massachusetts, United States of America \n", "4 Virginia, United States of America \n", ".. ... \n", "253 La Hispaniola, Constanza, La Vega, República D... \n", "254 Virginia, United States of America \n", "255 Guadeloupe, France \n", "256 Cuba \n", "257 The Bahamas \n", "\n", " Coordinates Latitude Longitude Year \n", "0 (42.3788774, -72.032366) 42.378877 -72.032366 1774 \n", "1 (43.4849133, -71.6553992) 43.484913 -71.655399 1774 \n", "2 (42.3788774, -72.032366) 42.378877 -72.032366 1775 \n", "3 (42.3788774, -72.032366) 42.378877 -72.032366 1776 \n", "4 (37.1232245, -78.4927721) 37.123224 -78.492772 1775 \n", ".. ... ... ... ... \n", "253 (18.77858115, -70.5427697709766) 18.778581 -70.542770 1783 \n", "254 (37.1232245, -78.4927721) 37.123224 -78.492772 1783 \n", "255 (16.2490067, -61.5650444) 16.249007 -61.565044 1783 \n", "256 (23.0131338, -80.8328748) 23.013134 -80.832875 1783 \n", "257 (24.7736546, -78.0000547) 24.773655 -78.000055 1783 \n", "\n", "[258 rows x 9 columns]" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "map_data['Year'] = map_data['Date'].str[-4:]\n", "map_data" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We can now animate those battles by the year that they took place. The year can be controlled by adjusting the slider on the bottom of the map below, or by simply pressing the play button. Look at the map below and observe the progress of battles that took place.\n", "\n", "If you hover your mouse over the battle location, you can see the name of the battle. You can also zoom in and out with the buttons at the top right." ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/html": [ " \n", " " ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/vnd.plotly.v1+json": { "config": { "plotlyServerURL": "https://plot.ly" }, "data": [ { "geo": "geo", "hovertemplate": "%{hovertext}

Year=1774
Latitude=%{lat}
Longitude=%{lon}", "hovertext": [ "Powder Alarm*", "Storming of Fort William and Mary*" ], "lat": [ 42.3788774, 43.4849133 ], "legendgroup": "", "lon": [ -72.032366, -71.6553992 ], "marker": { "color": "#636efa" }, "name": "", "showlegend": false, "type": "scattergeo" } ], "frames": [ { "data": [ { "geo": "geo", "hovertemplate": "%{hovertext}

Year=1774
Latitude=%{lat}
Longitude=%{lon}", "hovertext": [ "Powder Alarm*", "Storming of Fort William and Mary*" ], "lat": [ 42.3788774, 43.4849133 ], "legendgroup": "", "lon": [ -72.032366, -71.6553992 ], "marker": { "color": "#636efa" }, "name": "", "showlegend": false, "type": "scattergeo" } ], "name": "1774" }, { "data": [ { "geo": "geo", "hovertemplate": "%{hovertext}

Year=1775
Latitude=%{lat}
Longitude=%{lon}", "hovertext": [ "Battles of Lexington and Concord", "Gunpowder Incident*", "Capture of Fort Ticonderoga", "Battle of Chelsea Creek", "Battle of Machias", "Battle of Bunker Hill", "Battle of Gloucester", "Siege of Fort St. Jean", "Battle of Longue-Pointe", "Burning of Falmouth", "Battle of Kemp's Landing", "Siege of Savage's Old Fields", "Battle of Great Bridge", "Snow Campaign", "Battle of Great Cane Break", "Battle of Quebec" ], "lat": [ 42.3788774, 37.1232245, 40.7127281, 42.3788774, 42.3788774, 42.3788774, 42.3788774, 52.4760892, 52.4760892, 42.3788774, 37.1232245, 33.6874388, 37.1232245, 33.6874388, 33.6874388, 52.4760892 ], "legendgroup": "", "lon": [ -72.032366, -78.4927721, -74.0060152, -72.032366, -72.032366, -72.032366, -72.032366, -71.8258668, -71.8258668, -72.032366, -78.4927721, -80.4363743, -78.4927721, -80.4363743, -80.4363743, -71.8258668 ], "marker": { "color": "#636efa" }, "name": "", "showlegend": false, "type": "scattergeo" } ], "name": "1775" }, { "data": [ { "geo": "geo", "hovertemplate": "%{hovertext}

Year=1776
Latitude=%{lat}
Longitude=%{lon}", "hovertext": [ "Siege of Boston", "Burning of Norfolk", "Battle of Moore's Creek Bridge", "Battle of the Rice Boats", "Battle of Nassau", "Battle of Saint-Pierre", "Battle of Block Island", "Battle of The Cedars", "Battle of Trois-Rivières", "Battle of Sullivan's Island", "Battle of Turtle Gut Inlet", "Battle of Gwynn's Island", "Battle of Lindley's Fort", "Battle of Long Island", "Landing at Kip's Bay", "Battle of Harlem Heights", "Battle of Valcour Island", "Battle of Mamaroneck", "Battle of White Plains", "Battle of Fort Cumberland", "Battle of Fort Washington", "Battle of Fort Lee", "Ambush of Geary", "Battle of Iron Works Hill", "Battle of Trenton" ], "lat": [ 42.3788774, 37.1232245, 35.6729639, 32.3293809, 24.7736546, 52.4760892, 41.7962409, 52.4760892, 52.4760892, 33.6874388, 40.0757384, 37.1232245, 33.6874388, 40.7127281, 40.7127281, 40.7127281, 40.7127281, 40.7127281, 40.7127281, 45.1960403, 40.7127281, 40.0757384, 40.0757384, 40.0757384, 40.0757384 ], "legendgroup": "", "lon": [ -72.032366, -78.4927721, -79.0392919, -83.1137366, -78.0000547, -71.8258668, -71.5992372, -71.8258668, -71.8258668, -80.4363743, -74.4041622, -78.4927721, -80.4363743, -74.0060152, -74.0060152, -74.0060152, -74.0060152, -74.0060152, -74.0060152, -63.1653789, -74.0060152, -74.4041622, -74.4041622, -74.4041622, -74.4041622 ], "marker": { "color": "#636efa" }, "name": "", "showlegend": false, "type": "scattergeo" } ], "name": "1776" }, { "data": [ { "geo": "geo", "hovertemplate": "%{hovertext}

Year=1777
Latitude=%{lat}
Longitude=%{lon}", "hovertext": [ "Second Battle of Trenton", "Battle of Princeton", "Battle of Millstone", "Forage War", "Battle of Punk Hill", "Battle of Bound Brook", "Battle of Ridgefield", "Battle of Thomas Creek", "Meigs Raid", "Battle of Short Hills", "Siege of Fort Ticonderoga", "Battle of Hubbardton", "Battle of Fort Ann", "Siege of Fort Stanwix", "Battle of Oriskany", "Second Battle of Machias", "Battle of Bennington", "Battle of Staten Island", "Battle of Setauket", "First Siege of Fort Henry", "Battle of Cooch's Bridge", "Battle of Brandywine", "Battle of the Clouds", "Battle of Freeman's Farm", "Battle of Paoli", "Siege of Fort Mifflin", "Battle of Germantown", "Battle of Forts Clinton and Montgomery", "Battle of Bemis Heights", "Battle of Red Bank", "Battle of Gloucester", "Battle of White Marsh", "Battle of Matson's Ford" ], "lat": [ 40.0757384, 40.0757384, 40.0757384, 40.0757384, 40.0757384, 40.0757384, 41.6500201, -30.7532735, 40.7127281, 40.0757384, 40.7127281, 44.5990718, 40.7127281, 40.7127281, 40.7127281, 42.3788774, 40.7127281, 40.7127281, 40.7127281, 37.1232245, 38.6920451, 40.9699889, 40.9699889, 40.7127281, 40.9699889, 40.9699889, 40.9699889, 40.7127281, 40.7127281, 40.0757384, 40.0757384, 40.9699889, 40.9699889 ], "legendgroup": "", "lon": [ -74.4041622, -74.4041622, -74.4041622, -74.4041622, -74.4041622, -74.4041622, -72.7342163, -57.9772423, -74.0060152, -74.4041622, -74.0060152, -72.5002608, -74.0060152, -74.0060152, -74.0060152, -72.032366, -74.0060152, -74.0060152, -74.0060152, -78.4927721, -75.4013315, -77.7278831, -77.7278831, -74.0060152, -77.7278831, -77.7278831, -77.7278831, -74.0060152, -74.0060152, -74.4041622, -74.4041622, -77.7278831, -77.7278831 ], "marker": { "color": "#636efa" }, "name": "", "showlegend": false, "type": "scattergeo" } ], "name": "1777" }, { "data": [ { "geo": "geo", "hovertemplate": "%{hovertext}

Year=1778
Latitude=%{lat}
Longitude=%{lon}", "hovertext": [ "Battle of Barbados", "Battle of Quinton's Bridge", "North Channel Naval Duel", "Battle of Crooked Billet", "Battle of Barren Hill", "Mount Hope Bay raids", "Battle of Cobleskill", "Battle of Monmouth", "Battle of Alligator Bridge", "Wyoming Massacre", "First Battle of Ushant", "Siege of Pondicherry", "Battle of Newport", "Grey's raid", "Invasion of Dominica", "Siege of Boonesborough", "Attack on German Flatts", "Baylor Massacre", "Battle of Edgar's Lane", "Raid on Unadilla and Onaquaga", "Battle of Chestnut Neck", "Little Egg Harbor massacre", "Carleton's Raid", "Cherry Valley Massacre", "Battle of St. Lucia", "Capture of St. Lucia", "Capture of Savannah" ], "lat": [ 13.1500331, 40.0757384, 54.31536155, 40.9699889, 40.9699889, 41.7962409, 40.7127281, 40.0757384, -30.7532735, 40.9699889, 45.625054399999996, 22.3511148, 41.7962409, 42.3788774, 19.0974031, 37.1232245, 40.7127281, 40.0757384, 40.7127281, 27.9484308, 40.0757384, 40.0757384, 44.5990718, 40.7127281, 13.8250489, 13.8250489, 32.3293809 ], "legendgroup": "", "lon": [ -59.5250305, -74.4041622, -1.9180234948012402, -77.7278831, -77.7278831, -71.5992372, -74.0060152, -74.4041622, -57.9772423, -77.7278831, -3.6592840133440214, 78.6677428, -71.5992372, -72.032366, -70.3028026, -78.4927721, -74.0060152, -74.4041622, -74.0060152, 34.3819551, -74.4041622, -74.4041622, -72.5002608, -74.0060152, -60.975036, -60.975036, -83.1137366 ], "marker": { "color": "#636efa" }, "name": "", "showlegend": false, "type": "scattergeo" } ], "name": "1778" }, { "data": [ { "geo": "geo", "hovertemplate": "%{hovertext}

Year=1779
Latitude=%{lat}
Longitude=%{lon}", "hovertext": [ "Battle of Beaufort", "Battle of Kettle Creek", "Siege of Fort Vincennes", "Battle of Brier Creek", "Battle of Chillicothe", "Chesapeake raid", "Capture of Saint Vincent", "Battle of Stono Ferry", "Capture of Grenada", "Tryon's raid", "Battle of Grenada", "Battle of Stony Point", "Battle of Minisink", "Penobscot Expedition", "Battle of Paulus Hook", "Battle of Newtown", "Capture of Fort Bute", "Battle of Lake Pontchartrain", "Boyd and Parker ambush", "Action of 14 September 1779", "Siege of Savannah", "Battle of Baton Rouge", "Battle of Flamborough Head", "Action of 6 October 1779", "Battle of San Fernando de Omoa", "Action of 11 November 1779", "Action of 20 November 1779", "First Battle of Martinique" ], "lat": [ 33.6874388, 32.3293809, 40.3270127, 32.3293809, 52.4760892, 37.1232245, 12.90447, 33.6874388, 12.1360374, 41.6500201, 12.1360374, 40.7127281, 40.7127281, 42.3788774, 40.0757384, 27.9484308, -27.7700187, -27.7700187, 27.9484308, 37.808527350000006, 32.3293809, -27.7700187, 54.31536155, 46.603354, 15.6356088, 40.0332629, 40.0332629, 14.6113732 ], "legendgroup": "", "lon": [ -80.4363743, -83.1137366, -86.1746933, -83.1137366, -71.8258668, -78.4927721, -61.2765569, -80.4363743, -61.6904045, -72.7342163, -61.6904045, -74.0060152, -74.0060152, -72.032366, -74.4041622, 34.3819551, -57.2761535, -57.2761535, 34.3819551, -25.473085286479595, -83.1137366, -57.2761535, -1.9180234948012402, 1.8883335, -89.8988087, -7.8896263, -7.8896263, -60.9620777 ], "marker": { "color": "#636efa" }, "name": "", "showlegend": false, "type": "scattergeo" } ], "name": "1779" }, { "data": [ { "geo": "geo", "hovertemplate": "%{hovertext}

Year=1783
Latitude=%{lat}
Longitude=%{lon}", "hovertext": [ "Great Siege of Gibraltar", "Action of 2 January 1783", "Action of 22 January 1783", "Action of 15 February 1783", "Action of 17 February 1783", "Recapture of the Bahamas" ], "lat": [ 36.140807, 18.77858115, 37.1232245, 16.2490067, 23.0131338, 24.7736546 ], "legendgroup": "", "lon": [ -5.3541295, -70.5427697709766, -78.4927721, -61.5650444, -80.8328748, -78.0000547 ], "marker": { "color": "#636efa" }, "name": "", "showlegend": false, "type": "scattergeo" } ], "name": "1783" }, { "data": [ { "geo": "geo", "hovertemplate": "%{hovertext}

Year=1780
Latitude=%{lat}
Longitude=%{lon}", "hovertext": [ "Action of 8 January 1780", "Battle of Cape St. Vincent", "Battle of Young's House", "Battle of Van Creek", "San Juan Expedition", "Battle of Fort Charlotte", "Siege of Charleston", "Battle of Monck's Corner", "Second Battle of Martinique", "Battle of Lenud's Ferry", "Bird's invasion of Kentucky", "Battle of St. Louis", "Battle of Waxhaws", "Battle of Connecticut Farms", "Battle of Mobley's Meeting House", "Battle of Ramsour's Mill", "Battle of Springfield", "Huck's Defeat", "Battle of Bull's Ferry", "Battle of Colson's Mill", "Battle of Rocky Mount", "Battle of Hanging Rock", "Battle of Pekowee", "Action of 9 August 1780", "Action of 10 August 1780", "Action of 13 August 1780", "Battle of Camden", "Battle of Fishing Creek", "Battle of Musgrove Mill", "Battle of Black Mingo", "Battle of Wahab's Plantation", "Battle of Charlotte", "Action of 30 September 1780", "Battle of Kings Mountain", "Battle of Shallow Ford", "Royalton Raid", "Battle of Klock's Field", "Battle of Tearcoat Swamp", "La Balme's Defeat", "Battle of Fishdam Ford", "Battle of Blackstock's Farm", "Battle of Fort St. George" ], "lat": [ 39.3262345, 40.0332629, 40.7127281, 32.3293809, 15.6356088, -27.7700187, 33.6874388, 33.6874388, 14.6113732, 33.6874388, 37.1232245, 30.8703881, 33.6874388, 40.0757384, 33.6874388, 35.6729639, 40.0757384, 33.6874388, 40.0757384, 35.6729639, 33.6874388, 33.6874388, 52.4760892, 41.4036007, 46.603354, 52.865196, 33.6874388, 33.6874388, 33.6874388, 33.6874388, 33.6874388, 35.6729639, 32.3018217, 33.6874388, 35.6729639, 44.5990718, 40.7127281, 33.6874388, 52.4760892, 33.6874388, 33.6874388, 40.7127281 ], "legendgroup": "", "lon": [ -4.8380649, -7.8896263, -74.0060152, -83.1137366, -89.8988087, -57.2761535, -80.4363743, -80.4363743, -60.9620777, -80.4363743, -78.4927721, -92.007126, -80.4363743, -74.4041622, -80.4363743, -79.0392919, -74.4041622, -80.4363743, -74.4041622, -79.0392919, -80.4363743, -80.4363743, -71.8258668, -95.0138776, 1.8883335, -7.9794599, -80.4363743, -80.4363743, -80.4363743, -80.4363743, -80.4363743, -79.0392919, -64.7603583, -80.4363743, -79.0392919, -72.5002608, -74.0060152, -80.4363743, -71.8258668, -80.4363743, -80.4363743, -74.0060152 ], "marker": { "color": "#636efa" }, "name": "", "showlegend": false, "type": "scattergeo" } ], "name": "1780" }, { "data": [ { "geo": "geo", "hovertemplate": "%{hovertext}

Year=1781
Latitude=%{lat}
Longitude=%{lon}", "hovertext": [ "Battle of Jersey", "Battle of Mobile", "Battle of Cowpens", "Battle of Cowan's Ford", "Capture of Sint Eustatius", "Battle of Haw River", "Battle of Wetzell's Mill", "Siege of Pensacola", "Battle of Guilford Court House", "Battle of Cape Henry", "Siege of Fort Watson", "Battle of Porto Praya", "Battle of Blandford", "Battle of Hobkirk's Hill", "Battle of Fort Royal", "Action of 1 May 1781", "Battle of Fort Motte", "Battle of Pine's Bridge", "Siege of Augusta", "Siege of Ninety-Six", "Invasion of Tobago", "Action of 30 May 1781", "Battle of Spencer's Ordinary", "Francisco's Fight", "Battle of Green Spring", "Naval battle of Louisbourg", "Battle of Dogger Bank", "Battle of Piqua", "Lochry's Defeat", "Battle of the Chesapeake", "Battle of Groton Heights", "Battle of Eutaw Springs", "Battle of Lindley's Mill", "Long Run Massacre", "Siege of Yorktown", "Battle of Fort Slongo", "Siege of Negapatam", "Battle of Johnstown", "Second Battle of Ushant" ], "lat": [ 49.21230655, -27.7700187, 33.6874388, 35.6729639, 17.4865252, 35.6729639, 35.6729639, -27.7700187, 35.6729639, 37.1232245, 33.6874388, 16.0000552, 37.1232245, 33.6874388, 14.6113732, 46.603354, 33.6874388, 40.7127281, 32.3293809, 33.6874388, 11.24046155, 37.784616, 37.1232245, 37.1232245, 37.1232245, 45.1960403, 56.74123355, 40.2253569, 52.4760892, 37.1232245, 41.6500201, 33.6874388, 35.6729639, 37.1232245, 37.1232245, 40.7127281, 22.3511148, 40.7127281, 45.625054399999996 ], "legendgroup": "", "lon": [ -2.1255999596428845, -57.2761535, -80.4363743, -79.0392919, -62.9653116, -79.0392919, -79.0392919, -57.2761535, -79.0392919, -78.4927721, -80.4363743, -24.0083947, -78.4927721, -80.4363743, -60.9620777, 1.8883335, -80.4363743, -74.0060152, -83.1137366, -80.4363743, -60.67200597857749, -122.408751, -78.4927721, -78.4927721, -78.4927721, -63.1653789, 2.8911717166880475, -82.6881395, -71.8258668, -78.4927721, -72.7342163, -80.4363743, -79.0392919, -78.4927721, -78.4927721, -74.0060152, 78.6677428, -74.0060152, -3.6592840133440214 ], "marker": { "color": "#636efa" }, "name": "", "showlegend": false, "type": "scattergeo" } ], "name": "1781" }, { "data": [ { "geo": "geo", "hovertemplate": "%{hovertext}

Year=1782
Latitude=%{lat}
Longitude=%{lon}", "hovertext": [ "Invasion of Minorca", "Battle of Videau's Bridge", "Siege of Brimstone Hill", "Capture of Trincomalee", "Action of 15 January 1782", "Capture of Demerara and Essequibo", "Battle of Saint Kitts", "Battle of Sadras", "Capture of Montserrat", "Battle of Wambaw", "Gnadenhütten massacre", "Battle of Roatán", "Action of 16 March 1782", "Battle of Little Mountain", "Battle of Delaware Bay", "Battle of the Saintes", "Battle of Providien", "Battle of the Black River", "Battle of the Mona Passage", "Action of 20–21 April 1782", "Capture of the Bahamas", "Crawford expedition", "Naval battle off Halifax", "Raid on Chester", "Raid on Lunenburg", "Battle of Negapatam", "Hudson Bay Expedition", "Siege of Bryan Station", "Battle of Blue Licks", "Battle of the Combahee River", "Battle of Trincomalee", "Action of 4 September 1782", "Action of 5 September 1782", "Siege of Fort Henry", "Grand Assault on Gibraltar", "Action of 15 September 1782", "Action of 18 October 1782", "Battle of James Island", "Action of 6 December 1782", "Battle of the Delaware Capes" ], "lat": [ 39.949401, 33.6874388, 17.31569295, 43.5335672, 18.1152958, 6.5565821, 17.31569295, 22.3511148, 16.7417041, 33.6874388, 40.2253569, 15.6356088, 36.1309128, 37.1232245, 40.0757384, 19.0974031, 43.5335672, 15.6356088, 18.5, 45.625054399999996, 24.7736546, 52.4760892, 45.1960403, 44.5413322, 45.1960403, 43.5335672, 49.8345313, 37.1232245, 37.1232245, 33.6874388, 43.5335672, 46.603354, 40.85172235, 37.1232245, 36.140807, 39.247595399999994, 18.77858115, 33.6874388, 14.6113732, 38.9351126 ], "legendgroup": "", "lon": [ 4.0593888, -80.4363743, -62.744680590358186, -94.6316462, -77.1598454610168, -58.596566733398284, -62.744680590358186, 78.6677428, -62.1916844, -80.4363743, -82.6881395, -89.8988087, -5.3454756, -78.4927721, -74.4041622, -70.3028026, -94.6316462, -89.8988087, -68, -3.6592840133440214, -78.0000547, -71.8258668, -63.1653789, -64.2411853, -63.1653789, -94.6316462, -97.14746377135569, -78.4927721, -78.4927721, -80.4363743, -94.6316462, 1.8883335, -73.09921882199973, -78.4927721, -5.3541295, -75.30105997051399, -70.5427697709766, -80.4363743, -60.9620777, -74.9060053 ], "marker": { "color": "#636efa" }, "name": "", "showlegend": false, "type": "scattergeo" } ], "name": "1782" } ], "layout": { "geo": { "center": {}, "domain": { "x": [ 0, 1 ], "y": [ 0, 1 ] } }, "legend": { "tracegroupgap": 0 }, "margin": { "t": 60 }, "sliders": [ { "active": 0, "currentvalue": { "prefix": "Year=" }, "len": 0.9, "pad": { "b": 10, "t": 60 }, "steps": [ { "args": [ [ "1774" ], { "frame": { "duration": 0, "redraw": true }, "fromcurrent": true, "mode": "immediate", "transition": { "duration": 0, "easing": "linear" } } ], "label": "1774", "method": "animate" }, { "args": [ [ "1775" ], { "frame": { "duration": 0, "redraw": true }, "fromcurrent": true, "mode": "immediate", "transition": { "duration": 0, "easing": "linear" } } ], "label": "1775", "method": "animate" }, { "args": [ [ "1776" ], { "frame": { "duration": 0, "redraw": true }, "fromcurrent": true, "mode": "immediate", "transition": { "duration": 0, "easing": "linear" } } ], "label": "1776", "method": "animate" }, { "args": [ [ "1777" ], { "frame": { "duration": 0, "redraw": true }, "fromcurrent": true, "mode": "immediate", "transition": { "duration": 0, "easing": "linear" } } ], "label": "1777", "method": "animate" }, { "args": [ [ "1778" ], { "frame": { "duration": 0, "redraw": true }, "fromcurrent": true, "mode": "immediate", "transition": { "duration": 0, "easing": "linear" } } ], "label": "1778", "method": "animate" }, { "args": [ [ "1779" ], { "frame": { "duration": 0, "redraw": true }, "fromcurrent": true, "mode": "immediate", "transition": { "duration": 0, "easing": "linear" } } ], "label": "1779", "method": "animate" }, { "args": [ [ "1783" ], { "frame": { "duration": 0, "redraw": true }, "fromcurrent": true, "mode": "immediate", "transition": { "duration": 0, "easing": "linear" } } ], "label": "1783", "method": "animate" }, { "args": [ [ "1780" ], { "frame": { "duration": 0, "redraw": true }, "fromcurrent": true, "mode": "immediate", "transition": { "duration": 0, "easing": "linear" } } ], "label": "1780", "method": "animate" }, { "args": [ [ "1781" ], { "frame": { "duration": 0, "redraw": true }, "fromcurrent": true, "mode": "immediate", "transition": { "duration": 0, "easing": "linear" } } ], "label": "1781", "method": "animate" }, { "args": [ [ "1782" ], { "frame": { "duration": 0, "redraw": true }, "fromcurrent": true, "mode": "immediate", "transition": { "duration": 0, "easing": "linear" } } ], "label": "1782", "method": "animate" } ], "x": 0.1, "xanchor": "left", "y": 0, "yanchor": "top" } ], "template": { "data": { "bar": [ { "error_x": { "color": "#2a3f5f" }, "error_y": { "color": "#2a3f5f" }, "marker": { "line": { "color": "#E5ECF6", "width": 0.5 } }, "type": "bar" } ], "barpolar": [ { "marker": { "line": { "color": "#E5ECF6", "width": 0.5 } }, "type": "barpolar" } ], "carpet": [ { "aaxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "baxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "type": "carpet" } ], "choropleth": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "choropleth" } ], "contour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "contour" } ], "contourcarpet": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "contourcarpet" } ], "heatmap": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmap" } ], "heatmapgl": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmapgl" } ], "histogram": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "histogram" } ], "histogram2d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2d" } ], "histogram2dcontour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2dcontour" } ], "mesh3d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "mesh3d" } ], "parcoords": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "parcoords" } ], "pie": [ { "automargin": true, "type": "pie" } ], "scatter": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatter" } ], "scatter3d": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatter3d" } ], "scattercarpet": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattercarpet" } ], "scattergeo": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergeo" } ], "scattergl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergl" } ], "scattermapbox": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattermapbox" } ], "scatterpolar": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolar" } ], "scatterpolargl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolargl" } ], "scatterternary": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterternary" } ], "surface": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "surface" } ], "table": [ { "cells": { "fill": { "color": "#EBF0F8" }, "line": { "color": "white" } }, "header": { "fill": { "color": "#C8D4E3" }, "line": { "color": "white" } }, "type": "table" } ] }, "layout": { "annotationdefaults": { "arrowcolor": "#2a3f5f", "arrowhead": 0, "arrowwidth": 1 }, "coloraxis": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "colorscale": { "diverging": [ [ 0, "#8e0152" ], [ 0.1, "#c51b7d" ], [ 0.2, "#de77ae" ], [ 0.3, "#f1b6da" ], [ 0.4, "#fde0ef" ], [ 0.5, "#f7f7f7" ], [ 0.6, "#e6f5d0" ], [ 0.7, "#b8e186" ], [ 0.8, "#7fbc41" ], [ 0.9, "#4d9221" ], [ 1, "#276419" ] ], "sequential": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "sequentialminus": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ] }, "colorway": [ "#636efa", "#EF553B", "#00cc96", "#ab63fa", "#FFA15A", "#19d3f3", "#FF6692", "#B6E880", "#FF97FF", "#FECB52" ], "font": { "color": "#2a3f5f" }, "geo": { "bgcolor": "white", "lakecolor": "white", "landcolor": "#E5ECF6", "showlakes": true, "showland": true, "subunitcolor": "white" }, "hoverlabel": { "align": "left" }, "hovermode": "closest", "mapbox": { "style": "light" }, "paper_bgcolor": "white", "plot_bgcolor": "#E5ECF6", "polar": { "angularaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "radialaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "scene": { "xaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "yaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "zaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" } }, "shapedefaults": { "line": { "color": "#2a3f5f" } }, "ternary": { "aaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "baxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "caxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "title": { "x": 0.05 }, "xaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 }, "yaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 } } }, "updatemenus": [ { "buttons": [ { "args": [ null, { "frame": { "duration": 500, "redraw": true }, "fromcurrent": true, "mode": "immediate", "transition": { "duration": 500, "easing": "linear" } } ], "label": "▶", "method": "animate" }, { "args": [ [ null ], { "frame": { "duration": 0, "redraw": true }, "fromcurrent": true, "mode": "immediate", "transition": { "duration": 0, "easing": "linear" } } ], "label": "◼", "method": "animate" } ], "direction": "left", "pad": { "r": 10, "t": 70 }, "showactive": false, "type": "buttons", "x": 0.1, "xanchor": "right", "y": 0, "yanchor": "top" } ] } }, "text/html": [ "
\n", " \n", " \n", "
\n", " \n", "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "import plotly.express as px\n", "fig = px.scatter_geo(map_data, lat='Latitude', lon='Longitude', animation_frame='Year', hover_name='Battle')\n", "fig.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Using this interactive map, you can observe the progression of the American Revolution in North America in terms of the battles fought each year. Pay particular attention to the battles taking place in Quebec, the Maritime provinces, and along the Saint Lawrence River. \n", "\n", "\n", "### Questions\n", "1. Use the slider and hover over the battles on the map above, which battles were fought in what is now Canada?\n", "2. Why did some battles of the American Revolution take place in Quebec? \n", "3. Choose one of those battles and study it further. How might that battle have shaped Canada as we know it today?\n", "\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## The Progression of the War\n", "While the map above makes it easy to see where and when various battles were fought during the American Revolution, sometimes it's to look at different visualizations. The following bar chart displays how many battles took place each year." ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/html": [ " \n", " " ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/vnd.plotly.v1+json": { "config": { "linkText": "Export to plot.ly", "plotlyServerURL": "https://plot.ly", "showLink": true }, "data": [ { "marker": { "color": "rgba(255, 153, 51, 0.6)", "line": { "color": "rgba(255, 153, 51, 1.0)", "width": 1 } }, "name": "Battle", "orientation": "v", "text": "", "type": "bar", "x": [ "1774", "1775", "1776", "1777", "1778", "1779", "1780", "1781", "1782", "1783" ], "y": [ 2, 16, 25, 33, 27, 28, 42, 39, 40, 6 ] } ], "layout": { "legend": { "bgcolor": "#1A1A1C", "font": { "color": "#D9D9D9" } }, "paper_bgcolor": "#1A1A1C", "plot_bgcolor": "#1A1A1C", "template": { "data": { "bar": [ { "error_x": { "color": "#2a3f5f" }, "error_y": { "color": "#2a3f5f" }, "marker": { "line": { "color": "#E5ECF6", "width": 0.5 } }, "type": "bar" } ], "barpolar": [ { "marker": { "line": { "color": "#E5ECF6", "width": 0.5 } }, "type": "barpolar" } ], "carpet": [ { "aaxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "baxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "type": "carpet" } ], "choropleth": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "choropleth" } ], "contour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "contour" } ], "contourcarpet": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "contourcarpet" } ], "heatmap": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmap" } ], "heatmapgl": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmapgl" } ], "histogram": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "histogram" } ], "histogram2d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2d" } ], "histogram2dcontour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2dcontour" } ], "mesh3d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "mesh3d" } ], "parcoords": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "parcoords" } ], "pie": [ { "automargin": true, "type": "pie" } ], "scatter": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatter" } ], "scatter3d": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatter3d" } ], "scattercarpet": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattercarpet" } ], "scattergeo": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergeo" } ], "scattergl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergl" } ], "scattermapbox": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattermapbox" } ], "scatterpolar": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolar" } ], "scatterpolargl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolargl" } ], "scatterternary": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterternary" } ], "surface": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "surface" } ], "table": [ { "cells": { "fill": { "color": "#EBF0F8" }, "line": { "color": "white" } }, "header": { "fill": { "color": "#C8D4E3" }, "line": { "color": "white" } }, "type": "table" } ] }, "layout": { "annotationdefaults": { "arrowcolor": "#2a3f5f", "arrowhead": 0, "arrowwidth": 1 }, "coloraxis": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "colorscale": { "diverging": [ [ 0, "#8e0152" ], [ 0.1, "#c51b7d" ], [ 0.2, "#de77ae" ], [ 0.3, "#f1b6da" ], [ 0.4, "#fde0ef" ], [ 0.5, "#f7f7f7" ], [ 0.6, "#e6f5d0" ], [ 0.7, "#b8e186" ], [ 0.8, "#7fbc41" ], [ 0.9, "#4d9221" ], [ 1, "#276419" ] ], "sequential": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "sequentialminus": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ] }, "colorway": [ "#636efa", "#EF553B", "#00cc96", "#ab63fa", "#FFA15A", "#19d3f3", "#FF6692", "#B6E880", "#FF97FF", "#FECB52" ], "font": { "color": "#2a3f5f" }, "geo": { "bgcolor": "white", "lakecolor": "white", "landcolor": "#E5ECF6", "showlakes": true, "showland": true, "subunitcolor": "white" }, "hoverlabel": { "align": "left" }, "hovermode": "closest", "mapbox": { "style": "light" }, "paper_bgcolor": "white", "plot_bgcolor": "#E5ECF6", "polar": { "angularaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "radialaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "scene": { "xaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "yaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "zaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" } }, "shapedefaults": { "line": { "color": "#2a3f5f" } }, "ternary": { "aaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "baxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "caxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "title": { "x": 0.05 }, "xaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 }, "yaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 } } }, "title": { "font": { "color": "#D9D9D9" }, "text": "Battles per Year" }, "xaxis": { "gridcolor": "#434343", "showgrid": true, "tickfont": { "color": "#C2C2C2" }, "title": { "font": { "color": "#D9D9D9" }, "text": "Year" }, "zerolinecolor": "#666570" }, "yaxis": { "gridcolor": "#434343", "showgrid": true, "tickfont": { "color": "#C2C2C2" }, "title": { "font": { "color": "#D9D9D9" }, "text": "Number of Battles" }, "zerolinecolor": "#666570" } } }, "text/html": [ "
\n", " \n", " \n", "
\n", " \n", "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "import cufflinks as cf\n", "cf.go_offline()\n", "by_year = map_data.groupby('Year').count()['Battle']\n", "by_year.iplot(kind='bar', yTitle='Number of Battles', xTitle='Year', title='Battles per Year')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We can see that the year 1777 had the most battles out of the entire war. This is because 1776-1777 was the beginning of the British counter offensive, and British forces made considerable progress against the Americans. \n", "\n", "### Questions\n", "1. 1778 has about half as many battles as 1777, the year of the British counter offensive. What is the reason for this?\n", "2. 1780 has the second most battles in a year. What events lead to this year having as many battles as it did?" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## American Revolution Battle Locations\n", "\n", "We can also chart the number of battles by location." ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "application/vnd.plotly.v1+json": { "config": { "linkText": "Export to plot.ly", "plotlyServerURL": "https://plot.ly", "showLink": true }, "data": [ { "marker": { "color": "rgba(255, 153, 51, 0.6)", "line": { "color": "rgba(255, 153, 51, 1.0)", "width": 1 } }, "name": "Battle", "orientation": "h", "text": "", "type": "bar", "x": [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 6, 7, 10, 10, 11, 11, 22, 24, 31, 34 ], "y": [ "Anglican Centre, Diocese of Rupert's Land, 935, Nesbitt Bay, Crescent Park, Fort Rouge–East Fort Garry, Winnipeg, Winnipeg (city), Manitoba, R3T 1W6, Canada", "Tobago, Scarborough, Tobago, Trinidad and Tobago", "Sint Eustatius, Caribisch Nederland, Nederland", "Saint Vincent and the Grenadines", "North Sea / Nordsee / Noordzee / Nordsøen / Nordsjøen / Mer du Nord", "New Hampshire, United States of America", "Montserrat", "Mona Passage, República Dominicana", "Menorca, es Migjorn Gran, Menorca, Illes Balears, España", "Louisiana, United States of America", "Long Island, Suffolk County, New York, United States of America", "Jersey, Saint Lawrence, Jersey", "Indiana, United States of America", "Guadeloupe, France", "Essequibo, Essequibo Islands-West Demerara, Guyana", "Jamaica, Spanish Town, Saint Catherine, Middlesex County, Jamaika", "Delaware, United States of America", "Atlantic, Cass County, Iowa, 50022, United States of America", "Atlas moutains strait of Gibraltar Bay of Gibraltar, Douglas Path, Gibraltar, GX11 1AA, Gibraltar", "Açores, Portugal", "Barbados", "Barbary Coast, 55, Cyril Magnin Street, Union Square, San Francisco, San Francisco City and County, California, 94104, United States of America", "Bermuda", "España", "Cape May, Cape May County, New Jersey, 18204, United States of America", "Chester, Chester District Municipality, Nova Scotia, B0J 1J0, Canada", "Cuba", "Cabo Verde", "Éire / Ireland", "Delaware Bay, Cumberland County, New Jersey, United States of America", "Florida, Pancho Ramirez, Chajarí, Distrito Mandisoví, Departamento Federación, Entre Ríos, E3228, Argentina", "La Hispaniola, Constanza, La Vega, República Dominicana", "Saint Lucia", "Saint Kitts, Basseterre, Saint George Basseterre, Saint Kitts, 00265, Saint Kitts and Nevis", "Grenada", "Great Britain, Richmondshire, North Yorkshire, Yorkshire and the Humber, England, United Kingdom", "República Dominicana", "Gibraltar, GX11 1AA, Gibraltar", "Ohio, United States of America", "Vermont, United States of America", "The Bahamas", "Rhode Island, United States of America", "Portugal", "India", "Indian Res, شارع الشيخ زايد, شمال خليج نعمه, خليج القرش, شرم الشيخ, جنوب سيناء, 46911, Egypt / مصر", "Connecticut, United States of America", "Golfe de Gascogne / Golfo de Vizcaya", "Nova Scotia, Canada", "Guatemala", "France", "Martinique, France", "Ceylon, Martin County, Minnesota, United States of America", "Florida, Loreto, Municipio de Loreto, Departamento San Miguel, Corrientes, 3483, Argentina", "Georgia, United States of America", "North Carolina, United States of America", "Pennsylvania, United States of America", "Québec, Canada", "Massachusetts, United States of America", "Virginia, United States of America", "New Jersey, United States of America", "New York, United States of America", "South Carolina, United States of America" ] } ], "layout": { "height": 1100, "legend": { "bgcolor": "#1A1A1C", "font": { "color": "#D9D9D9" } }, "margin": { "b": 0, "l": 400, "r": 0, "t": 50 }, "paper_bgcolor": "#1A1A1C", "plot_bgcolor": "#1A1A1C", "template": { "data": { "bar": [ { "error_x": { "color": "#2a3f5f" }, "error_y": { "color": "#2a3f5f" }, "marker": { "line": { "color": "#E5ECF6", "width": 0.5 } }, "type": "bar" } ], "barpolar": [ { "marker": { "line": { "color": "#E5ECF6", "width": 0.5 } }, "type": "barpolar" } ], "carpet": [ { "aaxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "baxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "type": "carpet" } ], "choropleth": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "choropleth" } ], "contour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "contour" } ], "contourcarpet": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "contourcarpet" } ], "heatmap": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmap" } ], "heatmapgl": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmapgl" } ], "histogram": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "histogram" } ], "histogram2d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2d" } ], "histogram2dcontour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2dcontour" } ], "mesh3d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "mesh3d" } ], "parcoords": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "parcoords" } ], "pie": [ { "automargin": true, "type": "pie" } ], "scatter": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatter" } ], "scatter3d": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatter3d" } ], "scattercarpet": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattercarpet" } ], "scattergeo": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergeo" } ], "scattergl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergl" } ], "scattermapbox": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattermapbox" } ], "scatterpolar": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolar" } ], "scatterpolargl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolargl" } ], "scatterternary": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterternary" } ], "surface": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "surface" } ], "table": [ { "cells": { "fill": { "color": "#EBF0F8" }, "line": { "color": "white" } }, "header": { "fill": { "color": "#C8D4E3" }, "line": { "color": "white" } }, "type": "table" } ] }, "layout": { "annotationdefaults": { "arrowcolor": "#2a3f5f", "arrowhead": 0, "arrowwidth": 1 }, "coloraxis": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "colorscale": { "diverging": [ [ 0, "#8e0152" ], [ 0.1, "#c51b7d" ], [ 0.2, "#de77ae" ], [ 0.3, "#f1b6da" ], [ 0.4, "#fde0ef" ], [ 0.5, "#f7f7f7" ], [ 0.6, "#e6f5d0" ], [ 0.7, "#b8e186" ], [ 0.8, "#7fbc41" ], [ 0.9, "#4d9221" ], [ 1, "#276419" ] ], "sequential": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "sequentialminus": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ] }, "colorway": [ "#636efa", "#EF553B", "#00cc96", "#ab63fa", "#FFA15A", "#19d3f3", "#FF6692", "#B6E880", "#FF97FF", "#FECB52" ], "font": { "color": "#2a3f5f" }, "geo": { "bgcolor": "white", "lakecolor": "white", "landcolor": "#E5ECF6", "showlakes": true, "showland": true, "subunitcolor": "white" }, "hoverlabel": { "align": "left" }, "hovermode": "closest", "mapbox": { "style": "light" }, "paper_bgcolor": "white", "plot_bgcolor": "#E5ECF6", "polar": { "angularaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "radialaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "scene": { "xaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "yaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "zaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" } }, "shapedefaults": { "line": { "color": "#2a3f5f" } }, "ternary": { "aaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "baxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "caxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "title": { "x": 0.05 }, "xaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 }, "yaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 } } }, "title": { "font": { "color": "#D9D9D9" }, "text": "Battles by Location" }, "width": 800, "xaxis": { "gridcolor": "#434343", "showgrid": true, "tickfont": { "color": "#C2C2C2" }, "title": { "font": { "color": "#D9D9D9" }, "text": "Number of Battles" }, "zerolinecolor": "#666570" }, "yaxis": { "gridcolor": "#434343", "showgrid": true, "tickfont": { "color": "#C2C2C2" }, "title": { "font": { "color": "#D9D9D9" }, "text": "" }, "zerolinecolor": "#666570" } } }, "text/html": [ "
\n", " \n", " \n", "
\n", " \n", "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "by_location = map_data.groupby('Location').count()['Battle'].sort_values()\n", "by_location.iplot(kind='barh', margin=(400,0,0,50), dimensions=(800,1100), xTitle='Number of Battles', title='Battles by Location',)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Summary\n", "\n", "Using data from Wikipedia, we were able to visualize the locations and progress of the American Revolution, and also discover how many battles took place each year." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "[![Callysto.ca License](https://github.com/callysto/curriculum-notebooks/blob/master/callysto-notebook-banner-bottom.jpg?raw=true)](https://github.com/callysto/curriculum-notebooks/blob/master/LICENSE.md)" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.4" } }, "nbformat": 4, "nbformat_minor": 2 }