Matplotlib Assignment– 1
Foundations of Matplotlib
Basic Questions
- Plot a simple line chart showing numbers from 1 to 10 on the x-axis and their values on the y-axis.
- Plot a line chart showing numbers from 1 to 10 on the x-axis and their squares on the y-axis.
- Plot a line chart of numbers 1–10 with axis labels “Numbers” and “Squares” and a title “Line Chart Example”.
- Plot two lines on the same figure: one for y=x and another for y=x², with different colors.
- Plot a line chart for y=x³ and use red dashed lines with circle markers.
- Create a scatter plot of 20 random points with x values from 0–50 and y values from 0–100.
- Create a scatter plot of 15 points showing height (x-axis) and weight (y-axis) of students.
- Draw a bar chart showing sales of 5 products: A, B, C, D, E with values [50, 70, 30, 85, 60].
- Draw a horizontal bar chart showing marks of 5 students with values [75, 90, 65, 80, 95].
- Create a histogram showing the distribution of ages for the list [22, 25, 30, 22, 26, 28, 22, 25, 30, 35].
- Plot a histogram for 100 random values generated from normal distribution.
- Draw a line chart for monthly temperature values [15, 18, 22, 28, 35, 40, 38, 36, 30, 25, 20, 16].
- Create a line chart with grid enabled for numbers 1–10.
- Create a line chart with custom tick marks at every 2nd value on the x-axis from 0 to 10.
- Plot sine and cosine functions for x values between 0 and 2π.
- Draw a bar chart showing number of cars sold by 4 companies: Toyota, Ford, BMW, Tesla.
- Create a scatter plot of exam marks for 10 students with roll numbers on x-axis and marks on y-axis.
- Create a histogram of 50 random integers between 1 and 20.
- Draw a line chart with two y-axes: one showing numbers, another showing their cubes.
- Create a bar chart with labels rotated at 45 degrees for better readability.
Intermediate Questions
- Plot two subplots: one showing y=x and the other showing y=x².
- Create a figure with 2 rows and 2 columns of subplots for line, scatter, bar, and histogram charts.
- Create a scatter plot where marker size increases with x value.
- Create a scatter plot where marker color changes based on y value.
- Draw a bar chart with custom colors for each bar.
- Create a grouped bar chart comparing sales of two products across 5 regions.
- Create a stacked bar chart showing contributions of 3 categories in 4 groups.
- Plot a histogram with 20 bins for normally distributed random data.
- Create a line chart with legend showing labels “Linear” and “Quadratic”.
- Draw a line chart with customized font size for labels and title.
- Create a scatter plot with transparency (alpha value) applied.
- Plot a bar chart with error bars included.
- Create a line chart with markers placed at every data point and line style dotted.
- Plot a line chart with x-axis limited to 0–50 and y-axis limited to 0–2000.
- Create a subplot layout where one large chart is at the top and two smaller charts are at the bottom.
- Plot sine, cosine, and tangent functions on the same figure with a legend.
- Create a bar chart with values displayed on top of each bar.
- Plot a histogram and overlay a density line on it.
- Create a line chart with annotation showing the maximum value point.
- Plot a chart where gridlines are shown only on the y-axis.
Advanced Questions
- Create a customized plot showing daily stock price movement using line and scatter plots together.
- Build a grouped bar chart comparing monthly expenses (Rent, Food, Transport) for 6 months.
- Plot a multi-line chart showing population growth of three countries from 2000–2020.
- Create a histogram showing distribution of exam scores and mark the pass line at 40 with a vertical line.
- Create a subplot with 4 different trigonometric functions: sine, cosine, tan, and cot.
- Plot a bar chart showing revenue of 5 companies and add text labels showing percentage share.
- Create a scatter plot showing relationship between study hours and exam scores, then fit a regression line on it.
- Plot a figure showing temperature variation across months using both line chart and bar chart in the same plot.
- Create a histogram of random numbers and compare it with a normal distribution curve overlaid.
- Create a figure with customized size, background color, axis labels, ticks, and grid style to simulate a professional-looking chart.