w3resource

Matplotlib Scatter: Draw a scatter plot to find sea level rise in past 100 years

Matplotlib Scatter: Exercise-6 with Solution

Write a Python program to draw a scatter plot to find sea level rise in past 100 years. We have collected the data from here [https://github.com/datasets/sea-level-rise].
This data contains "cumulative changes in sea level for the world’s oceans since 1880, based on a combination of long-term tide gauge measurements and recent satellite measurements. It shows average absolute sea level change, which refers to the height of the ocean surface, regardless of whether nearby land is rising or falling. Satellite data are based solely on measured sea level, while the long-term tide gauge data include a small correction factor because the size and shape of the oceans are changing slowly over time. (On average, the ocean floor has been gradually sinking since the last Ice Age peak, 20,000 years ago.)"

Sample Data:
data.csv

Sample Solution:

Python Code:

import matplotlib.pyplot as plt
import pandas as pd
data = pd.read_csv('data.csv')
year = data['year']
sea_levels = data['CSIRO_sea_level']
plt.scatter(year, sea_levels, edgecolors='g')
plt.xlabel('Year')
plt.ylabel('Sea Level (inches)')
plt.title('Rise in Sealevel')
plt.show()

Sample Output:

Matplotlib Scatter: Draw a scatter plot to  find sea level rise in past 100 years

Python Code Editor:

Contribute your code and comments through Disqus.:

Previous: Write a Python program to draw a scatter plot for three different groups comparing weights and heights.
Next: Matplotlib Exercises

What is the difficulty level of this exercise?



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://www.w3resource.com/graphics/matplotlib/scatter/matplotlib-scatter-exercise-6.php