Matplotlib Assignment– 1

Foundations of Matplotlib

Basic Questions

  1. Plot a simple line chart showing numbers from 1 to 10 on the x-axis and their values on the y-axis.
  2. Plot a line chart showing numbers from 1 to 10 on the x-axis and their squares on the y-axis.
  3. Plot a line chart of numbers 1–10 with axis labels “Numbers” and “Squares” and a title “Line Chart Example”.
  4. Plot two lines on the same figure: one for y=x and another for y=x², with different colors.
  5. Plot a line chart for y=x³ and use red dashed lines with circle markers.
  6. Create a scatter plot of 20 random points with x values from 0–50 and y values from 0–100.
  7. Create a scatter plot of 15 points showing height (x-axis) and weight (y-axis) of students.
  8. Draw a bar chart showing sales of 5 products: A, B, C, D, E with values [50, 70, 30, 85, 60].
  9. Draw a horizontal bar chart showing marks of 5 students with values [75, 90, 65, 80, 95].
  10. Create a histogram showing the distribution of ages for the list [22, 25, 30, 22, 26, 28, 22, 25, 30, 35].
  11. Plot a histogram for 100 random values generated from normal distribution.
  12. Draw a line chart for monthly temperature values [15, 18, 22, 28, 35, 40, 38, 36, 30, 25, 20, 16].
  13. Create a line chart with grid enabled for numbers 1–10.
  14. Create a line chart with custom tick marks at every 2nd value on the x-axis from 0 to 10.
  15. Plot sine and cosine functions for x values between 0 and 2π.
  16. Draw a bar chart showing number of cars sold by 4 companies: Toyota, Ford, BMW, Tesla.
  17. Create a scatter plot of exam marks for 10 students with roll numbers on x-axis and marks on y-axis.
  18. Create a histogram of 50 random integers between 1 and 20.
  19. Draw a line chart with two y-axes: one showing numbers, another showing their cubes.
  20. Create a bar chart with labels rotated at 45 degrees for better readability.

Intermediate Questions

  1. Plot two subplots: one showing y=x and the other showing y=x².
  2. Create a figure with 2 rows and 2 columns of subplots for line, scatter, bar, and histogram charts.
  3. Create a scatter plot where marker size increases with x value.
  4. Create a scatter plot where marker color changes based on y value.
  5. Draw a bar chart with custom colors for each bar.
  6. Create a grouped bar chart comparing sales of two products across 5 regions.
  7. Create a stacked bar chart showing contributions of 3 categories in 4 groups.
  8. Plot a histogram with 20 bins for normally distributed random data.
  9. Create a line chart with legend showing labels “Linear” and “Quadratic”.
  10. Draw a line chart with customized font size for labels and title.
  11. Create a scatter plot with transparency (alpha value) applied.
  12. Plot a bar chart with error bars included.
  13. Create a line chart with markers placed at every data point and line style dotted.
  14. Plot a line chart with x-axis limited to 0–50 and y-axis limited to 0–2000.
  15. Create a subplot layout where one large chart is at the top and two smaller charts are at the bottom.
  16. Plot sine, cosine, and tangent functions on the same figure with a legend.
  17. Create a bar chart with values displayed on top of each bar.
  18. Plot a histogram and overlay a density line on it.
  19. Create a line chart with annotation showing the maximum value point.
  20. Plot a chart where gridlines are shown only on the y-axis.

Advanced Questions

  1. Create a customized plot showing daily stock price movement using line and scatter plots together.
  2. Build a grouped bar chart comparing monthly expenses (Rent, Food, Transport) for 6 months.
  3. Plot a multi-line chart showing population growth of three countries from 2000–2020.
  4. Create a histogram showing distribution of exam scores and mark the pass line at 40 with a vertical line.
  5. Create a subplot with 4 different trigonometric functions: sine, cosine, tan, and cot.
  6. Plot a bar chart showing revenue of 5 companies and add text labels showing percentage share.
  7. Create a scatter plot showing relationship between study hours and exam scores, then fit a regression line on it.
  8. Plot a figure showing temperature variation across months using both line chart and bar chart in the same plot.
  9. Create a histogram of random numbers and compare it with a normal distribution curve overlaid.
  10. Create a figure with customized size, background color, axis labels, ticks, and grid style to simulate a professional-looking chart.