Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6164677
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T22:02:03+00:00 2026-05-23T22:02:03+00:00

How can I change the data on one axis? I’m making some spectrum analysis

  • 0

How can I change the data on one axis?

I’m making some spectrum analysis on some data and my x-axis is the index of some matrix. I’d like to change it so that the x-axis becomes the data itself.

I’m using the imshow() to plot the data (I have a matrix whose elements are some intensity, the y axes are their detector-source correspondent pair and the x-axis should be their frequency).

The code for it is written down here:

def pltspec(dOD, self):
    idx = 0
    b = plt.psd(dOD[:,idx],Fs=self.fs,NFFT=512)
    B = np.zeros((2*len(self.Chan),len(b[0])))
    for idx in range(2*len(self.Chan)):
        b = plt.psd(dOD[:,idx],Fs=self.fs,NFFT=512)
        B[idx,:] = 20*log10(b[0])
    fig = plt.figure()
    ax = fig.add_subplot(111)
    plt.imshow(B, origin = 'lower')
    plt.colorbar()
    locs, labels = xticks(find(b[1]), b[1])
    plt.axis('tight')
    ax.xaxis.set_major_locator(MaxNLocator(5))

I think if there’s a way of interchanging the index of some array with its value, my problem would be solved.

I’ve managed to use the line locs, labels = xticks(find(b[1]), b[1]). But with it on my graph my axis interval just isn’t right… I think it has something to do with the MaxNLocator (which I used to decrease the number of ticks).

And if I use the xlim, I can set the figure to be what I want, but the x axis is still the same (on that xlim I had to use the original data to set it right).

What am I doing wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T22:02:04+00:00Added an answer on May 23, 2026 at 10:02 pm

    Yes, you can use the xticks method exemplified in this example.

    There are also more sophisticated ways of doing it. See ticker.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I change the data in only one cell of a mysql table.
I can set data in JTable constructor, and then user can change this data
You can change the connection string at run-time like this. You make the connection
Can someone tell me how i can change the .xml file that a flash
I understand that I can change a sql table using the follow sp: EXEC
Consider the requirement to change a data member on one or more properties of
Lets say we have a native library that works with data like this: double
I have SQL Server database and I just realized that I can change the
I have an XML file that has data in it, but one of the
How can I get a user-defined function to re-evaluate itself based on changed data

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.