Assignment Week-03 (2403B05107)
Assignment Week-03 (2403B05107)
3A: Write a Python program using Matplotlib to plot a simple line graph with the following
specifications:
1. Define the x-axis values as [1, 2, 3].
2. Define the corresponding y-axis values as [2, 4, 1].
3. Plot the points and connect them with a line.
4. Label the x-axis as "x - axis" and the y-axis as "y - axis".
5. Set the title of the graph as "My first graph!".
6. Display the graph.
Expected Output:
A line graph with the specified x and y values, labeled axes, and a title.
PROGRAM :
# x-axis values
x = [1, 2, 3]
# Corresponding y-axis values
y = [2, 4, 1]
Expected Output:
A plot showing all the specified lines, labels, customizations, title, legend, andannotation.
PROGRAM :
Expected Output:
A 2x2 grid of subplots, each showing the specified data, custom markers, tick settings, and titles.
PROGRAM :
# Use `fig` to open a new figure window and specify the window size
fig = plt.figure(figsize=(10, 10))
sub3.plot(list(range(0, 22, 3)), 'vg') # 'v' is for triangle markers, 'g' for green
sub3.set_xticks(list(range(0, 10, 1))) # Set x-ticks for sub3
sub3.set_title('3rd Rep')
Result:
Thus the basic plots using Matplotlib in Python program was successfully completed.