Question

In: Computer Science

For python: How do I make an y vs x graph where x is from 1...

For python:

How do I make an y vs x graph where x is from 1 to 20 and y is x times 7

Solutions

Expert Solution

EXPLANATION:

Python provides a tremendous featured library to plotting graph using matplotlib library .Graph is good way to show the data visually (picture type) its the easy way to understand the data stored. We can also customize the graph plotting as our convinence.

In the given problem we need to make an y vs x graph where x is from 1 to 20 and y is x times 7 ,that means each value in the y is 7 times higher than the corresponding x value.

IN Y vs X graph the Y-axis is plotted horizontal direction and the X-axis plotted in vertical diretion

CODE:

OUTPUT:

In the given graph below the scale is :

On x-axis 1unit = 2.5 units

on Y-axis 1 unit = 20 units

RAW_CODE:

#Graph plotting y vs x graph
#y vs x graph means y values are plotted in horizontal direction and x values are plotted in vertical direction
#inporting numpy library
import numpy as np
#importing pyplot as plt from matplotlib library
import matplotlib.pyplot as plt
#x-axis has values from 1 to 20
x_axis=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]
#y-axis has y is x times 7
#that means each value in the y is 7 times to the corresponding value in x
#storing y values
y=np.array(x_axis)
y_axis=y*7
#plotting y vs x graph with some customizations linke marking the each co-ordinate with some marker along with color
plt.plot(y_axis, x_axis, color='black', linewidth = 2,
marker='o', markerfacecolor='blue', markersize=7)   
#title of the graph
plt.title("Y vs X graph")
#labelling y axis as x axis
plt.ylabel('x axis')
#labelling x axis as y axis
plt.xlabel('y axis')
#showing the plotted graph
plt.show()   

**********For any queries comment me in the comment box***********


Related Solutions

How do I make the series graph
How do I make the series graph
Use your calculator to complete the table. **How do I graph y=ex ***How do I graph...
Use your calculator to complete the table. **How do I graph y=ex ***How do I graph the Inverse of y=ex x y=ex -3 -2 -1 0 1 1 2 3
Having trouble with this question. Do I make a graph from 0 to 1 with ten...
Having trouble with this question. Do I make a graph from 0 to 1 with ten minute intervals so that I would have 6 rectangles? I think this is right. A bug is crawling at a velocity of f(t)= 1/2-t meters per hour, where 0 ≤ t ≤ 1 and t is in hours. a) Find both the left-endpoint and right-endpoint approximations for the area under the graph f(t) during this hour. Use 10-minute increments (be careful about units). b)...
How to create the graph? Make a graph of the average life vs the contract rate...
How to create the graph? Make a graph of the average life vs the contract rate c, where 0 ? c ? 100% and T=30y. In you submission, show the amortization table for c=5% (and make sure it fits on one page and is annotated)
How does the graph of y = sin x compare with the graph of y = cos x? Explain how you could horizontally translate the graph of y = sin x to obtain y = cos x.
How does the graph of y = sin x compare with the graph of y = cos x? Explain how you could horizontally translate the graph of y = sin x to obtain y = cos x.
How do you find the tangent line to the curve y=x³−9x at the point where x=1?
How do you find the tangent line to the curve y=x³−9x at the point where x=1?
Let F (x, y) = y sin x i – cos x j, where C is...
Let F (x, y) = y sin x i – cos x j, where C is the line segment from (π/2,0) to (π, 1). Then C F•dr is A 1 B 2 C 5/2 D 3 E 7/2
A random variable Y is a function of random variable X, where y=x^2 and fx(x)=(x+1)/2 from...
A random variable Y is a function of random variable X, where y=x^2 and fx(x)=(x+1)/2 from -1 to 1 and =0 elsewhere. Determine fy(y). In this problem, there are two x values for every y value, which means x=T^-1(y)= +y^0.5 and -y^0.5. Be sure you account for both of these. Ans: fy(y)=0.5y^-0.5
How do I make a skewness and kurtosis graph in Excel? Can anyone provide me a...
How do I make a skewness and kurtosis graph in Excel? Can anyone provide me a step?
I. Consider the condition (x == y). How is this handled if x and y are...
I. Consider the condition (x == y). How is this handled if x and y are primitive types? How is this handled if x and y are objects? II. For the program to get a name interactively a Scanner object must be instantiated. Write the Java statement to do this. III. Write a statement using a Scanner method to get the first name interactively. IV. Write a method to extract the initial (first letter) from the first name. V. Write...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT