Python Forum
plotting (using numpy) - scaling of x axis
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
plotting (using numpy) - scaling of x axis
#1
Hey there,

I'm new to python and the answer to my question might be really easy to find out but I admit I don't really know what to look for. I tried but without success.

So I simply want to plot the following function: 1/np.sqrt(1+(x/1700)**2)
So obviously this is what I want on the y-axis, however, I don't want something like plt.plot(x,1/np.sqrt(1+(x/1700)**2))
I want to "scale" the x-axis so that I have 1/np.sqrt(1+(x/1700)**2)  over np.log(1700/x). This is simply to make it look nicer since
x should go from 159 to 160000

So I thought I could try sth like this:

"
x=np.arange(159,160000)
plt.plot(np.log(1700/x) , 1/np.sqrt(1+(x/1700)**2))
"

Should sth like this be possible?
I keep getting no graph and simply errors like:

RuntimeWarning: divide by zero encountered in log
invalid value encountered in subtract
return np.amin(x[1:] - x[0:-1]) >= 0

Obviously I shouldn't divide by zero but I don't think I actually do...
as for the second error I don't get at all where it's coming from

I would really appreciate it if anyone could tell me what I'm doing wrong. Thanks!
Reply
#2
Okay solved - integer division :D
Reply
#3
Thanks for posting back!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Floor division problem with plotting x-axis tick labels Mark17 5 2,047 Apr-03-2022, 01:48 PM
Last Post: Mark17
  Sample labels from excel file in order to put them on x-axis and y-axis of a plot hobbyist 11 4,232 Sep-14-2021, 08:29 AM
Last Post: hobbyist
  Difference Between Figure Axis and Sub Plot Axis in MatplotLib JoeDainton123 2 2,426 Aug-21-2020, 10:17 PM
Last Post: JoeDainton123
  Error while writing a code for feature scaling prateek 1 2,482 Aug-15-2017, 09:17 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020