Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Create a Complete Line Chart | Basics: Line Charts
Visualization in Python with matplotlib
course content

Зміст курсу

Visualization in Python with matplotlib

Visualization in Python with matplotlib

1. Basics: Line Charts
2. Bar Charts
3. Scatter Plots

bookCreate a Complete Line Chart

Good job! I think you can now build an informative chart yourself with real data.

Let's just recap the necessary steps:

  1. Load the matplotlib.pyplot library. Preferably with plt alias;
  2. Create Figure and Axes objects using .subplots() function (preferably fig, ax);
  3. Initialize each line with ax.plot() functions with necessary data and customization parameters (label, color, marker, linestyle);
  4. Set axis labels using ax.set_xlabel() and ax.set_ylabel() functions;
  5. Display the plot title, legend using plt.title() and plt.legend() functions (legend requires label parameter within .plot() functions to be set);
  6. Display the plot using plt.show() function.
Завдання
test

Swipe to show code editor

You are given the us_cities_weather dataframe containing the weather data for the US cities (average temperature per month from 1961 - 1990 in Fahrenheit). You need to display the monthly average temperature for three cities: San Francisco, Denver, and Miami. Follow the next steps:

  1. Create Figure and Axes objects assigned to fig, ax variables respectively.

  2. Save data for each city in a separate variable (dv for Denver, sf for San Francisco, and mm for Miami).

  3. Set the parameters for three lines (each corresponding to the respective city):

    • Red ('r') dotted ('dotted') line with square ('s') points for San Francisco;

    • Blue ('b') dashed ('dashed') line with triangle ('^') points for Denver;

    • Orange ('darkorange') dashdotted ('dashdot') line with circle ('o') points for Miami.

  4. Set the labels for the plot:

    • 'Month' on the x-axis;

    • 'Average Temperature (Fahrenheit)' on the y-axis.

  5. Add plot title 'Average monthly temperature for the US cities'.

  6. Add a legend and display the plot.

Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 1. Розділ 12
toggle bottom row

bookCreate a Complete Line Chart

Good job! I think you can now build an informative chart yourself with real data.

Let's just recap the necessary steps:

  1. Load the matplotlib.pyplot library. Preferably with plt alias;
  2. Create Figure and Axes objects using .subplots() function (preferably fig, ax);
  3. Initialize each line with ax.plot() functions with necessary data and customization parameters (label, color, marker, linestyle);
  4. Set axis labels using ax.set_xlabel() and ax.set_ylabel() functions;
  5. Display the plot title, legend using plt.title() and plt.legend() functions (legend requires label parameter within .plot() functions to be set);
  6. Display the plot using plt.show() function.
Завдання
test

Swipe to show code editor

You are given the us_cities_weather dataframe containing the weather data for the US cities (average temperature per month from 1961 - 1990 in Fahrenheit). You need to display the monthly average temperature for three cities: San Francisco, Denver, and Miami. Follow the next steps:

  1. Create Figure and Axes objects assigned to fig, ax variables respectively.

  2. Save data for each city in a separate variable (dv for Denver, sf for San Francisco, and mm for Miami).

  3. Set the parameters for three lines (each corresponding to the respective city):

    • Red ('r') dotted ('dotted') line with square ('s') points for San Francisco;

    • Blue ('b') dashed ('dashed') line with triangle ('^') points for Denver;

    • Orange ('darkorange') dashdotted ('dashdot') line with circle ('o') points for Miami.

  4. Set the labels for the plot:

    • 'Month' on the x-axis;

    • 'Average Temperature (Fahrenheit)' on the y-axis.

  5. Add plot title 'Average monthly temperature for the US cities'.

  6. Add a legend and display the plot.

Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 1. Розділ 12
toggle bottom row

bookCreate a Complete Line Chart

Good job! I think you can now build an informative chart yourself with real data.

Let's just recap the necessary steps:

  1. Load the matplotlib.pyplot library. Preferably with plt alias;
  2. Create Figure and Axes objects using .subplots() function (preferably fig, ax);
  3. Initialize each line with ax.plot() functions with necessary data and customization parameters (label, color, marker, linestyle);
  4. Set axis labels using ax.set_xlabel() and ax.set_ylabel() functions;
  5. Display the plot title, legend using plt.title() and plt.legend() functions (legend requires label parameter within .plot() functions to be set);
  6. Display the plot using plt.show() function.
Завдання
test

Swipe to show code editor

You are given the us_cities_weather dataframe containing the weather data for the US cities (average temperature per month from 1961 - 1990 in Fahrenheit). You need to display the monthly average temperature for three cities: San Francisco, Denver, and Miami. Follow the next steps:

  1. Create Figure and Axes objects assigned to fig, ax variables respectively.

  2. Save data for each city in a separate variable (dv for Denver, sf for San Francisco, and mm for Miami).

  3. Set the parameters for three lines (each corresponding to the respective city):

    • Red ('r') dotted ('dotted') line with square ('s') points for San Francisco;

    • Blue ('b') dashed ('dashed') line with triangle ('^') points for Denver;

    • Orange ('darkorange') dashdotted ('dashdot') line with circle ('o') points for Miami.

  4. Set the labels for the plot:

    • 'Month' on the x-axis;

    • 'Average Temperature (Fahrenheit)' on the y-axis.

  5. Add plot title 'Average monthly temperature for the US cities'.

  6. Add a legend and display the plot.

Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Good job! I think you can now build an informative chart yourself with real data.

Let's just recap the necessary steps:

  1. Load the matplotlib.pyplot library. Preferably with plt alias;
  2. Create Figure and Axes objects using .subplots() function (preferably fig, ax);
  3. Initialize each line with ax.plot() functions with necessary data and customization parameters (label, color, marker, linestyle);
  4. Set axis labels using ax.set_xlabel() and ax.set_ylabel() functions;
  5. Display the plot title, legend using plt.title() and plt.legend() functions (legend requires label parameter within .plot() functions to be set);
  6. Display the plot using plt.show() function.
Завдання
test

Swipe to show code editor

You are given the us_cities_weather dataframe containing the weather data for the US cities (average temperature per month from 1961 - 1990 in Fahrenheit). You need to display the monthly average temperature for three cities: San Francisco, Denver, and Miami. Follow the next steps:

  1. Create Figure and Axes objects assigned to fig, ax variables respectively.

  2. Save data for each city in a separate variable (dv for Denver, sf for San Francisco, and mm for Miami).

  3. Set the parameters for three lines (each corresponding to the respective city):

    • Red ('r') dotted ('dotted') line with square ('s') points for San Francisco;

    • Blue ('b') dashed ('dashed') line with triangle ('^') points for Denver;

    • Orange ('darkorange') dashdotted ('dashdot') line with circle ('o') points for Miami.

  4. Set the labels for the plot:

    • 'Month' on the x-axis;

    • 'Average Temperature (Fahrenheit)' on the y-axis.

  5. Add plot title 'Average monthly temperature for the US cities'.

  6. Add a legend and display the plot.

Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Секція 1. Розділ 12
Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
We're sorry to hear that something went wrong. What happened?
some-alt