Home>
I output the time series data and the spectrogram that analyzed the frequency using the wavelet transform, but the x-axis of the graph of the time series data and the x-axis of the color map are different.
How should I change the program to align the two x-axis?
m = 6
#Frequency band to analyze [Hz]
list1 = range (1, 80, 1)
print ("start")
for freq in list1:
print (freq, end = "")
print ('-', end = "")
mw2 = signal.morlet (int (fs/freq * m * 2), m, 1.0, complete = True)
corr_tmp = np.correlate (ags_data, mw2)/sum (abs (mw2))
sup_first = np.zeros (int (len (mw2)/2))
sup_end = np.zeros (len (ags_data)-len (corr_tmp)-int (len (mw2)/2))
corr_tmp = np.append (sup_first, corr_tmp)
corr_tmp = np.append (corr_tmp, sup_end)
if freq == list1 [0]:
corr_stack = abs (corr_tmp [: 10]) ** 2
else: else:
corr_stack = np.vstack ((corr_stack, abs (corr_tmp [:: 10]) ** 2))
print ("end")
#Image map output stage
import matplotlib.pyplot as plt
import matplotlib.gridspec as gridspec
xsl = ags_data [::10]
xmin = xsl.min ()
xmax = xsl.max ()
ymin = list1.start
ymax = list1.stop
fig = plt.figure (figsize = (8,4))
gs = gridspec.GridSpec (2,1)
ax1 = fig.add_subplot (gs [0,:])
plt.plot (df.index, ags_data, linewidth = 1)
plt.title ("sample_waveform")
plt.xlabel ("Time [s]")
plt.ylabel ("Amplitude")
plt.grid (True)
ax1.axis ('tight')
# plt.xlim ([0,5])
ax2 = fig.add_subplot (gs [1, :])
im = ax2.imshow (corr_stack, extent = [xmin, xmax, ymin, ymax], interpolation ='none', cmap ='jet', origin ='lower')
plt.title ("wavelet_coherence")
plt.xlabel ("Time [s]")
plt.ylabel ("Frequency [Hz]")
plt.grid (linestyle ='-', linewidth = 0.5)
plt.xticks ()
#I want to add a color bar ↓ Reference
# https://matplotlib.org/2.0.2/examples/pylab_examples/colorbar_tick_labelling_demo.html
cmlb = [0,0.01,0.02,0.03,0.04,0.05,0.06,0.07,0.08,0.09,0.1]
cbar = fig.colorbar (im, ticks = cmlb, orientation ='horizontal')
cbar.ax.set_xticklabels (cmlb) # horizontal colorbar
ax2.axis ('tight')
-
Answer # 1
Related articles
- python - graph drawing with matplotlib
- python - i want to display a graph of matplotlib on tkinter and enable mouse operation in canvas
- python - about matplotlib graph fill
- python - about x-axis adjustment in matplotlib
- python - i want to add an auxiliary scale in the graph of matplotlib
- python - to graph what you counted on the photo
- when graphing a list with matplotlib in python, the number of elements is large and the graph is not displayed
- python matplotlibpyplot i get an error trying to display a moving average on a candlestick chart
- python - the graph becomes a straight line
- python - i want to display the sensing data as a graph using the value sent by post from a web browser
- python - keras graph partition
- python - i want to load graph data created with pyplot as image data without saving it
- i want to create a graph with equal date intervals in matplotlib
- python outputs a graph of approximation error with euclidean distance (2)
- python outputs a graph of approximation error using euclidean distance
- python - even if i try to display the waveform display of audio data with matplotlib, the dimensions of (x, y) do not match beca
- python - i want to display the correlation coefficient on the matplotlib graph
- python - how to delete vertices that meet the conditions in a graph using networkx
- python - i want to convert the histogram to a bar graph
Related questions
- python : correctly translate the dictionary into a dataframe, where the values will be divided by keys
- python : Comparison with pandas
- python : yfinance AttributeError: 'Index' object has no attribute 'tz_localize'
- python : How to add multiple columns to a multi-index DataFrame at once
- python : How to find if there is a value in a pandas.DataFrame column
- python : Moving Average of Grouped Data
- python : Error creating dataframe
- python : How to display a plot in good quality in matplotlib
- python : f -string in function
- Passing parameter list to SQL query python [duplicate]
It was solved by setting extent = [df.index [0], de.index [-1], ymin, ymax].