![]() ![]() The way to make a plot with two different y-axis is to use two different axes objects with the help of twinx() function. ![]() One of the solutions is to make the plot with two different y-axes. We don’t see any variation in it because of the scale of gdpPercap values. ![]() The line for lifeExp over years is flat and really low. We can immediately see that this is a bad idea. # create figure and axis objects with subplots()Īx.plot(gapminder_us.year, gapminder_us.lifeExp, marker="o")Īx.plot(gapminder_us.year, gapminder_us, marker="o") Naively, let us plot both on the same plot with a single y-axis. lifeExp values are below 100 and gdpPercap values are in thousands. The variable on x-axis is year and on y-axis we are interested in lifeExp & gdpPercap.īoth lifeExp and gdpPercap have different ranges. We are interested in making a plot of how lifeExp & gdpPercap changes over the years. Let us subset gapminder data by using Pandas query() function to filter for rows with United States. #load gapminder data from url as pandas dataframe We will use gapminder data from Carpentries to make the plot with two different y-axis on the same plot. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
June 2023
Categories |