Created
September 21, 2020 10:45
-
-
Save BexTuychiev/381c28ba23177b3d567fefdfc065e065 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Create a figure and an axis | |
| fig, ax = plt.subplots() | |
| # Plot CO2 emissions with a blue line | |
| ax.plot(climate_change['date'], climate_change['co2'], color='blue') | |
| # Specify that we will be using a twin x axis | |
| ax2 = ax.twinx() | |
| ax2.plot(climate_change['date'], climate_change['relative_temp'], color='red') | |
| # Change the color of ticks | |
| ax.tick_params('y', colors='blue') # 'y' because we want to change the y axis | |
| ax2.tick_params('y', colors='red') | |
| ax.set(title='CO2 emmissions and relative temperature by year', | |
| xlabel='Year') # Does not matter which one you pick, ax or ax2 | |
| plt.show(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment