0

Well, I really didnt know how to ask this properly but here is the question. I have some code which produces data for me. I have 100 Reynolds Number from 0.1 to 2017 and at every Reynolds Number there will be shear stress values for 10.000 element. So I want Reynolds Numbers on x-axis and my shear stress(from 0.001 to 10) values on y-axis both will be on logarithmic scale and those 10.000 elements will be dots on the graph. So I will have totaly 100.000 points on the graph.

In this code I produce Re from 0.1 to 2017 and 10 element's shear stress values for every Reynolds Numbers. So at 0.1 on x-axis I need to have 10 points. So i looked for it but couldn't figure it out. So how can I do it ?

n = np.random.normal(mean, sd, 100)
for i in range(0, 105):
    Re = 0.1 * (1.1**i)  
    B = e ** (-0.08 * Re) * (2.5 * np.log(Re) + 5.25) + 8.5 * (1 - e ** (-0.08 * Re))  
    C = 0.8+0.9*((e**(-0.08*Re)/(Re**2))+((1-e**(-0.08*Re))/(B**2)))**(-0.5)  
    F = 0.31*Re*e**(-0.1*Re)+1.8*e**(-0.88*d50/D)*(1-e**(-0.1*Re)) 
    A = F/C   
    for j in range(10):
        Dcbss = 0.52*math.tan(fi) / (((1 + (abs(n[j])*A))**2)*(1+(1/2.5)*((abs(n[j])*F)**2)*math.tan(fi)))


5
  • You are using the variables mean and sd to create some data. Could you include some suitable values for those in your example? Commented May 19, 2019 at 13:37
  • 1
    Have you looked through the matplotlib gallery? Do you just need to know how to create a logarithmic scale Commented May 19, 2019 at 13:41
  • @wwii they arent so important in this question. mean is 0 and sd is 1. Commented May 19, 2019 at 13:46
  • I guess it isn't clear what your asking. Do you just need to know how to plot the data? 10 y values for every x value? Commented May 19, 2019 at 13:50
  • kinda yeah. i just couldnt figure out how those datas will match . when i look at the examples they write them seperately. but in this i cant write them seperately because they are random and too much. Commented May 19, 2019 at 13:56

1 Answer 1

2

Use a scatter plot. For each Reynolds Number you have n stress values. The scatter plot needs as many x values as there are y values so you have to create a sequence of x values the same length as the y values.

x = [1,1,1,1]
y = [1,2,3,4]

If you have multiple sets of x/y data you can plot it manually like this

x = [1,1,1,1]
y = [1,2,3,4]
plt.scatter(x,y)

x = [2,2,2,2]
y = [1.1,2.1,3.1,4.1]
plt.scatter(x,y)

plt.show()
plt.close()

For your case you want to accumulate x and y values in the inner loop, and plot them when the inner loop terminates.

from matplotlib import pyplot as plt
for i in range(0, 105):
    x = []
    y = []
    Re = 0.1 * (1.1**i)  
    B = e ** (-0.08 * Re) * (2.5 * np.log(Re) + 5.25) + 8.5 * (1 - e ** (-0.08 * Re))  
    C = 0.8+0.9*((e**(-0.08*Re)/(Re**2))+((1-e**(-0.08*Re))/(B**2)))**(-0.5)  
    F = 0.31*Re*e**(-0.1*Re)+1.8*e**(-0.88*d50/D)*(1-e**(-0.1*Re)) 
    A = F/C   
    for j in range(10):
        Dcbss = 0.52*math.tan(fi) / (((1 + (abs(n[j])*A))**2)*(1+(1/2.5)*((abs(n[j])*F)**2)*math.tan(fi)))
        x.append(i)
        y.append(Dcbss)
    plt.scatter(x,y)
plt.show()
plt.close()

From the docs: The plot function will be faster for scatterplots where markers don't vary in size or color.. If that is the case just use .plot() and specify a marker shape - plt.plot(x,y,'ro') instead of plt.scatter(x,y).


matplotlib.pyplot.scatter()
matplotlib.pyplot.plot()

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.