Posts for Tag: interactive

Animation of Coronavirus Cases and Deaths in US

Posted In: Health | Maps

Visualize the large number of coronavirus cases and deaths in the US each day/hour in about 10 seconds

The rate of COVID-19 deaths and cases in the US is crazy high after the 2020 winter holidays and maybe still be going up. This visualization shows the number of COVID cases that occur in one hour or the COVID deaths that occur in one day based on the average of the last five days. This is another attempt to show the true scale of how many cases and deaths the US is dealing with, since it is often hard to understand large numbers. I have also attempted to show the scale of US deaths/cases here and here. Unfortunately, there are so many people getting sick and dying, it’s hard to fathom just how many people this actually is.

The 5-day averaging was done to smooth out any peaks and troughs in data reporting due to weekends/holidays, since I noticed that some states were literally reporting zero COVID cases some days while reporting many hundreds or thousands of cases other days.

The dots shown on the animation are located in the state that the cases or deaths occur but are randomly spread out within the state. This is done for visual clarity since if they were shown in their actual location, most of the dots would be overlapping in urban, high density areas. This approach lets you see which states have high COVID instances but still locate them by state.

You can share this animation by putting ?cat=deaths or ?cat=cases behind the url or copying and sharing one of these links:

  • https://engaging-data.com/animation-of-us-covid/?cat=cases
  • https://engaging-data.com/animation-of-us-covid/?cat=deaths
  • Sources and Tools:

    The coronavirus data comes from the covidtracking.com API. The data is parsed daily using a custom python script and visualizations are made using the open-source Leaflet javascript mapping library and the interface and animation are made using HTML/CSS/javascript.

    US covid case death animation

    Stimulus Check Calculator (Late 2020 & Early 2021)

    Posted In: Government | Money
    stimulus check calculator

    How much money can you expect in your stimulus check?

    Updated to include the $1400 stimulus payment per adult and dependent in March 2021.
    Use this stimulus check calculator to figure out how much you will receive in your thrid stimulus check.

    On December 21, 2020, Congress passed a $900 billion dollar stimulus package in response to the COVID pandemic. The bill authorizes economic assistance to Americans in the amount of $600 per person subject to income limits. It also includes expanded unemployment benefits, rental assistance and an extension to the eviction ban. This calculator helps you calculate the amount of stimulus check that you can expect to receive based on your 2019 tax return filing status, adjusted gross income and number of dependents under 17.

    Changing the inputs to the calculator, will show you how your expected stimulus check amount will change. The graph shows for a giving filing status (single, married filing jointly or head of household) how the stimulus check amount will change as a function of income and number of children. You can share a URL with specific parameters included

    Sounds like some checks may even get to folks at the end of December and many more will get them in January 2021.

    On March 5, congress passed the American Rescue Plan which includes $1400 payments for all Americans. The phase out of this stimulus check is different in that over a $10000 range the stimulus goes from 100% to 0% at the phase out threshold, no matter how many dependents you have. This changes things significantly as you’ll see in the calculator.

    Sources and Tools:
    The stimulus check calculator is made using javascript and the plotly open source graphing library. It is based on news reports of the expected stimulus amounts and income thresholds.

    Election Results and Population Density

    Posted In: Elections
    election county population density

    How do 2020 presidential election results correlate with population density?

    The visualization I made about county election results and comparing land area to population size was very popular around the time of the 2020 presidential election. As the counties were represented by population, it was clear that democratic-leaning areas on that map tended to grow in size, while republican-leaning areas tended to shrink. This raised the question of exactly how population density correlates with election results.

    Hover over (or click on) the bubbles to see information about the county.

     

    It’s clear there is a very strong correlation between the vote margin and population density.  Vote margin is the percentage amount that one candidate beat the other candidate by in the county (0% means a tie while 50% means that one candidate got 75% and the other got 25% of the voteshare).  Population density is calculated as people per square mile in the county and is shown in the graph on a log scale, where each major grid line is 10 time greater than the previous one.  This is done because there is one to two orders of magnitude difference in the densest counties (in New York City) and even moderately dense counties.  There are also several counties with population density below 1 person per square mile (several in Alaska because of the size of their counties) but these are excluded from the graph.

    Richmond County, NY (i.e. the Borough of Staten Island) is the densest county (17th densest) in the country that Trump won. The densest counties favored Biden quite heavily as he won 45 of the 50 densest counties in the country, which also tend to have a fairly high population.

    This second graph is a histogram that specifically categorizes counties into discreet bins by population density. Note that they are on a log scale as well. You can toggle the graph to show the number of counties won by each candidate or the number of votes won in each of the population density bins. The black line shows the percentage of counties (or votes) won by the democratic candidate (Joe Biden) in each of those bins.

    Hover over (or click on) the bars to see information about each county bin.

    It’s pretty clear in these graphs that low population density areas clearly favor the republican while the denser areas favor the democrat.

     

    Data and Tools
    The 2020 county-level election data is downloaded from the New York Times county election data API and processed using a python script. Population data used is for 2018. The visualization was created using the open-source plotly javascript graphing library.

    How many Americans have contracted Coronavirus?

    Posted In: Health | Maps

    The number of US coronavirus cases is equal to the population of several states put together.

    click on the buttons below to see a new set of states. The number of Americans who have contracted the Coronavirus keeps going up with little indication of slowing down. This is an amazingly large number of cases is the highest in the world and I wanted to visualize how many people this actually is. While the number of US COVID-19 cases is very large, comparing these number to the size of the populations in several states helps to provide more context. The visualization shows a random collection of states whose total population is equal to the latest coronavirus numbers. If you click the button you can see a different set of states that have a population equal to the current number of coronavirus cases.
    The graph is updated daily using data from covidtracking.com. It’s important to note that the number of people with COVID-19 is an underestimate as many coronavirus cases are asymptomatic (i.e. people don’t get sick or show any symptoms) and the positivity rate of tests is quite high. Stay safe out there: stay away from people and wear your mask!

    Sources and Tools:

    Data on coronavirus cases was obtained from covidtracking.com. The visualization was created using javascript and the open source leaflet javascript mapping library.

    US coronavirus cases

    Van Gogh As Drawn By A Traveling Salesman

    Posted In: Fun | Math
    Van Gogh Portrait Line Drawing

    This “art project”, like the Mona Lisa one, draws a portrait of Vincent Van Gogh as a single continuous line. When it’s on the slow setting, is oddly satisfying and calming to watch the picture get drawn.

    Click the “Draw Van Gogh” button below to see his famous self portrait drawn with a single continuous line with 120,000 segments.

    The traveling salesman problem (TSP) is a classic problem in operations research and mathematical programming. It seeks to answer the question, given a set of destinations, what is the shortest possible travel route someone could take to visit them all. It is a notoriously challenging problem to solve when the number of destinations grows. A picture of the famous Van Gogh self-portrait was converted to 120,000 dots and a challenge was created to find the most optimal solution to visiting each of these 120 thousand points (i.e. drawing the shortest continuous line that goes through each and every point.

    The current most-optimal solution that has been found to this Van Gogh self-portrait challenge was calculated in 2013 by Honda, Nagata and Ono. I used the order of destinations (also called the “tour) that he developed and animated the line segments to create an animated drawing of the portrait as a single continuous line.

    Here an analogous TSP drawing for the Mona Lisa.

    Each time you click on the “Draw Van Gogh” button, it chooses a different starting point but follows the same order of destination points, looping around until all the points are visited.

    You can also change the speed at which the individual line segments are drawn. It is surprisingly relaxing and satisfying to watch the line wind its way around the screen to fill in the famous Van Gogh self-portrait.

    For a very high res version of the entire photo click here (around 4 MB file size).

    Data and Tools:
    I downloaded the 120,000 points and the tour from Honda, Nagata and Ono that is currently the shortest that has so far been calculated from the TSP Art website and the University of Waterloo.
    Javascript was used to draw on the HTML canvas and animate the process.

    van gogh tsp

    Visualizing the Variation in Sunlight by Latitude and Time of Year

    Posted In: Science

    How does the Earth’s tilt affect sunlight and seasons by latitude?

    This visualization looks at the variation in the amount of sunlight different latitudes receive over the different days of the year. The amount of sunlight can be classified in 3 different categories:

    • The number of hours of sunlight received each day
    • The average sunlight intensity (in watts per square meter)
    • The total amount of sunlight received across an entire latitude band (in gigawatt hours)

    The default view is to see the number of hours of sunlight received by latitude on the current date, shown by the yellow bars. The sunlight hours range from 0 to 24 hours per day while most latitudes range from 9 to 15 hours.

    If you hover over the yellow bars (or click on mobile), you will see the exact number of hours for that latitude band for that date.

    Pressing the ‘Start Animation’ button, will change the angle of the sun relative to the Earth (as the earth rotates around the sun) and change the distribution of sunlight across the globe.  You can view this animation with the earth fixed and the sun angle changing (the default view) or with the sun location fixed and the earth’s tilt changing.

    This visualization helps to show how the seasons come about. When the Northern Hemisphere is tilted towards the sun, the amount of sunlight it receives increases (hours of daylight, average sun intensity and total amount of sunlight received). As the hemisphere tilts away from the sun, the amount of sunlight it receives decreases. The amount of sunlight a region receives causes the seasons that we experience.

    Interestingly, when you are at the equator, the amount of sunlight per day does not really vary too significantly over the course of the year, whereas if you are near the poles, the difference between summer and winter is very dramatic. When looking at total sunlight received, the poles generally have lower sunlight because even in their summer, there is much lower land area relative to the middle latitudes (close to the equator)

    The second visualization shown here shows how the tilt of the Earth’s axis is changed over the course of the Earth’s revolution around the sun.  The Earth’s axis is tilted at 23.5 degrees relative to the plane of the Earth’s orbit around the sun. Like the last visualization, you can look at Earth the way we normally do (without the tilted axis) or from the perspective of the sun (with a tilted axis). This makes it a bit clearer why the tilt of the Earth’s axis can change from the north pole angled away to angled towards the sun.

     

    Sources and Tools:

    The equations for average daily solar insolation come from online lecture notes from University of Albany. The equations for number of hours of daylight comes from Wikipedia.   The visualizations are made using the javascript d3 data visualization library and the interface and animation are made using javascript.

     

    daylight hours