Adding One More Line
Quite good! That's a good visualization! Let's expand our chart with new data.
We may want to compare the emission levels by displaying several lines on a single chart. It can be easily done by calling the .plot()
method of Axes
object multiple times. For instance, if you call ax.plot()
two times, you will get two lines on one chart. By default, the first line will be blue, the second one will be orange.
1234567891011121314151617181920# Import the libraries import matplotlib.pyplot as plt import pandas as pd # Load the data data = pd.read_csv('https://codefinity-content-media.s3.eu-west-1.amazonaws.com/ed80401e-2684-4bc4-a077-99d13a386ac7/co2.csv', index_col = 0) # Filter the data ita = data.loc['Italy'] swe = data.loc['Sweden'] # Create Figure and Axes objects fig, ax = plt.subplots() # Initialize lines ax.plot(ita.index.astype(int), ita.values) ax.plot(swe.index.astype(int), swe.values) # Display the plot plt.show()
Danke für Ihr Feedback!
Fragen Sie AI
Fragen Sie AI
Fragen Sie alles oder probieren Sie eine der vorgeschlagenen Fragen, um unser Gespräch zu beginnen
Awesome!
Completion rate improved to 2.94
Adding One More Line
Swipe um das Menü anzuzeigen
Quite good! That's a good visualization! Let's expand our chart with new data.
We may want to compare the emission levels by displaying several lines on a single chart. It can be easily done by calling the .plot()
method of Axes
object multiple times. For instance, if you call ax.plot()
two times, you will get two lines on one chart. By default, the first line will be blue, the second one will be orange.
1234567891011121314151617181920# Import the libraries import matplotlib.pyplot as plt import pandas as pd # Load the data data = pd.read_csv('https://codefinity-content-media.s3.eu-west-1.amazonaws.com/ed80401e-2684-4bc4-a077-99d13a386ac7/co2.csv', index_col = 0) # Filter the data ita = data.loc['Italy'] swe = data.loc['Sweden'] # Create Figure and Axes objects fig, ax = plt.subplots() # Initialize lines ax.plot(ita.index.astype(int), ita.values) ax.plot(swe.index.astype(int), swe.values) # Display the plot plt.show()
Danke für Ihr Feedback!