Write a program in python (using matplotlib.pyplot) to create a scatter plot.
Use of scatter plot: Scatter plots are usually used to compare two variables (three if you are plotting in 3 dimensions), looking for correlation or groups.
We use the data values y2 above y1. y1 and y2 are two random variables taken for the plot. For this we use the parameter bottom which indicates which value will be at the bottom. N is also a variable to assign the no of bars existing in the plot. Also we use the arrange method of numpy to evenly space the bars and assign its values to the x values variable. Xticks functions give the label to the evenly spaced xvalues. To name the axes xlabel and ylabel functions are used and to give the title to the plot the title function is used. To show the legend the legend function is used and finally to show the plot the show function.
Program:
Output
Explanation:
We use the data values y2 above y1. y1 and y2 are two random variables taken for the plot. For this we use the parameter bottom which indicates which value will be at the bottom. N is also a variable to assign the no of bars existing in the plot. Also we use the arrange method of numpy to evenly space the bars and assign its values to the x values variable. Xticks functions give the label to the evenly spaced xvalues. To name the axes xlabel and ylabel functions are used and to give the title to the plot the title function is used. To show the legend the legend function is used and finally to show the plot the show function.
need an explanation for this answer? contact us directly to get an explanation for this answer