0

I am trying to scale the axes on my plot from 0 to 1 but following the progression of the sin function over that interval. I need to do this to get an even data distribution for my graph.

I have attempted to use the FuncScale operator but to no avail.

import numpy as np
import matplotlib.pyplot as plt
import random as rand

#Define radius and angle
r = np.arange(0,5,0.0001)
a = np.arange(0, np.pi/2 ,(np.pi/100000))#[:-1]
print(len(r))
print(len(a))
#x = r * np.cos(a)
#y = r * np.sin(a)

#Generate random integer list and zip with radii and angles
samp=50000
q = rand.sample(range(samp),samp)
qrzip = zip(r,q)
u = rand.sample(range(samp),samp)
uazip = zip(a,u)

#Turn tuples back into list
qr = list(qrzip)
ua = list(uazip)

# Sort with lambda function
qr.sort(key=lambda x: x[1])
ua.sort(key=lambda x: x[1])

#Form lists of radii and angles in random order
qrr = [qrr[0] for qrr in qr]
uaa = [uaa[0] for uaa in ua]

#Define variables
cos = qrr*np.cos(uaa)
sin = qrr*np.sin(uaa)

plt.plot(cos, sin,'g,')
plt.xlim(0, 5)
plt.ylim(0, 5)
plt.gca().set_aspect('equal', adjustable='box')
plt.draw()

The function plots on a normal integer scale but I want it to plot on the scale sin(0,1)

  • what do you think the output should look like? Having trouble understanding what you want on the axis... – AirSquid May 27 '19 at 19:19
  • @JeffH As you can see if you plot it you get an uneven distribution of points, the point density increases as you near the origin. What I want is to have the points distributed evenly throughout the quadrant of the circle which is being plotted. – pthieme May 27 '19 at 19:23
  • You should also post the resulting plot. And please try to trim everything that's not really neccessary to create a [mvce](https://stackoverflow.com/help/minimal-reproducible-example), That way people can focus more on your question. I personally do not know if what you ask is possible. – flurble May 27 '19 at 19:28
  • I see that. That is a byproduct of how you are generating points. The radii are more closely spaced near the origin, so you will get higher density there. So the goal is uniformly distributed points within 1 quadrant of circle? – AirSquid May 27 '19 at 19:29
  • https://imgur.com/a/Bfm7FXM The plot Correct i want the points to be uniformly distributed in the quadrant. – pthieme May 27 '19 at 19:31
  • This looks helpful: https://stackoverflow.com/questions/5837572/generate-a-random-point-within-a-circle-uniformly – AirSquid May 27 '19 at 19:35
  • Thanks! Would still like to know if scaling on a sin scale is possible but I will check this out. – pthieme May 27 '19 at 19:37

0 Answers0