Python Forum
Getting proper x,y axis values
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Getting proper x,y axis values
#3
(Jul-29-2022, 04:05 PM)deanhystad Wrote: Why? Normally axis labels indicate range with maybe some subdivisions to give approximate value. If you want the real value you click on the plot.

It seems I got the axes right but now the points are not showing up. Do you know whats wrong with my code here?

from scipy.fft import fft2, fftshift
import numpy as np
import matplotlib.pyplot as plt
from skimage.filters import window
from scipy.fftpack import fftfreq


k = np.linspace(0,4.76*10,2400)
kx,ky = np.meshgrid(k, k)
x1 = 0.3
y1 = 0.4
x2 = 0.3
y2 = 1

z = 0.05*np.cos(2*np.pi*kx*x1 + 2*np.pi*ky*y1) + 0.05*np.cos(2*np.pi*kx*x2 + 2*np.pi*ky*y2)

wz = z * window('hann', z.shape)

plt.figure(0)
plt.imshow(wz)

f = fftfreq(len(k), np.diff(k)[0])
zf = np.abs(fftshift(fft2(wz)))[1200:, 1200:]
fig, ax = plt.subplots()
ax.set(xlim=(0, 2), ylim=(0, 2))
ax.imshow(zf,extent=[0,f[:k.size//2][-1], 0 , f[:k.size//2][-1]])
plt.show()
Reply


Messages In This Thread
Getting proper x,y axis values - by pyhill00 - Jul-29-2022, 03:30 PM
RE: Getting proper x,y axis values - by deanhystad - Jul-29-2022, 04:05 PM
RE: Getting proper x,y axis values - by pyhill00 - Jul-29-2022, 04:43 PM
RE: Getting proper x,y axis values - by deanhystad - Jul-29-2022, 05:07 PM
RE: Getting proper x,y axis values - by pyhill00 - Jul-29-2022, 05:11 PM
RE: Getting proper x,y axis values - by deanhystad - Jul-29-2022, 05:49 PM
RE: Getting proper x,y axis values - by pyhill00 - Jul-29-2022, 05:57 PM
RE: Getting proper x,y axis values - by deanhystad - Jul-29-2022, 06:46 PM
RE: Getting proper x,y axis values - by pyhill00 - Jul-29-2022, 06:48 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Pyserial issues with proper loops and binary jttolleson 16 2,841 Nov-02-2023, 08:39 PM
Last Post: deanhystad
  Print names in x-axis of a time-series values hobbyist 4 1,320 Apr-22-2023, 09:29 PM
Last Post: deanhystad
  ValueError: Length mismatch: Expected axis has 8 elements, new values have 1 elements ilknurg 1 5,378 May-17-2022, 11:38 AM
Last Post: Larz60+
  Proper way to do the OR statement? Mark17 5 1,833 Mar-01-2022, 01:54 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,558 Sep-14-2021, 08:29 AM
Last Post: hobbyist
  Put zero for x axis values quest 4 2,360 Jul-29-2021, 01:34 PM
Last Post: DeaD_EyE
  Difference Between Figure Axis and Sub Plot Axis in MatplotLib JoeDainton123 2 2,547 Aug-21-2020, 10:17 PM
Last Post: JoeDainton123
  proper use of 'end' in a 'with' statement ccrider27 1 2,112 Mar-18-2020, 10:33 PM
Last Post: buran
  Proper use of if..elif..else statement nick1941 2 2,477 Mar-06-2020, 11:22 PM
Last Post: nick1941
  Proper Layout of Code Question TheJax 2 2,254 Feb-08-2020, 06:14 PM
Last Post: TheJax

Forum Jump:

User Panel Messages

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