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 8249075
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T23:24:44+00:00 2026-06-07T23:24:44+00:00

I am generating 2D arrays on log-spaced axes (for instance, the x pixel coordinates

  • 0

I am generating 2D arrays on log-spaced axes (for instance, the x pixel coordinates are generated using logspace(log10(0.95), log10(2.08), n).

I want to display the image using a plain old imshow, in its native resolution and scaling (I don’t need to stretch it; the data itself is already log scaled), but I want to add ticks, labels, lines that are in the correct place on the log axes. How do I do this?

Ideally I could just use commands line axvline(1.5) and the line would be in the correct place (58% from the left), but if the only way is to manually translate between logscale coordinates and image coordinates, that’s ok, too.

For linear axes, using extents= in the call to imshow does what I want, but I don’t see a way to do the same thing with a log axis.

Example:

from matplotlib.colors import LogNorm

x = logspace(log10(10), log10(1000), 5)
imshow(vstack((x,x)), extent=[10, 1000, 0, 100], cmap='gray', norm=LogNorm(), interpolation='nearest')
axvline(100, color='red')

This example does not work, because extent= only applies to linear scales, so when you do axvline at 100, it does not appear in the center. I’d like the x axis to show 10, 100, 1000, and axvline(100) to put a line in the center at the 100 point, while the pixels remain equally spaced.

  • 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-06-07T23:24:45+00:00Added an answer on June 7, 2026 at 11:24 pm

    Actually, it works fine. I’m confused.

    Previously I was getting errors about “Images are not supported on non-linear axes” which is why I asked this question. But now when I try it, it works:

    import matplotlib.pyplot as plt
    import numpy as np
    
    x = np.logspace(1, 3, 5)
    y = np.linspace(0, 2, 3)
    z = np.linspace(0, 1, 4)
    Z = np.vstack((z, z))
    
    plt.imshow(Z, extent=[10, 1000, 0, 1], cmap='gray')
    plt.xscale('log')
    
    plt.axvline(100, color='red')
    
    plt.show()
    

    This is better than pcolor() and pcolormesh() because

    1. it’s not insanely slow and
    2. is interpolated nicely without misleading artifacts when the image is not shown at native resolution.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What I am doing: generating a series of long 1D arrays. What I want
when generating python wrappers with swig the python wrapper classes in the generated python
I'm generating json from a Rails app, and am filtering fields using the format.json
I'm learning how to use arrays in Haskell, for example, generating a times table:
I have two arrays of x - y coordinates, and I would like to
I generated some C# classes from an XSD using the Visual Studio XSD utility
I am using Facebook PHP SDK to authenticate the user. After generating the LoginUrl
I have been searching for a source code for generating combinations using C++. I
Motivation and Problem There are several libraries for generating html markup strings using ruby
I am generating associative arrays and the key value is a string concat of

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.