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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T07:01:35+00:00 2026-06-17T07:01:35+00:00

I was trying to plot some data with scatter. My code is import matplotlib.pyplot

  • 0

I was trying to plot some data with scatter. My code is

import matplotlib.pyplot as plt
import matplotlib as mpl
import numpy as np
from scipy.interpolate import griddata
data = np.loadtxt('file1.txt')
x = data[:,0]
y = data[:,1]
z = data[:,2]
plt.scatter(x, y, c=z, s=100, cmap=mpl.cm.spectral)
cbar=plt.colorbar()
s=18
plt.ylabel(r"$a_v$", size=s)
plt.xlabel(r"$a_{\rm min}$", size=s)
plt.xlim([x.min(),x.max()])
plt.ylim([y.min(),y.max()])
plt.show()

The result is
enter image description here

Now I came on the idea to try imshow with the some data, soince I didn’t like the circles of scatter.
So I tried this

from matplotlib.mlab import griddata
import matplotlib.pyplot as plt
data = np.loadtxt('file1.txt')
x = data[:,0]
y = data[:,1]
z = data[:,2]

N = 30j
extent = (min(x), max(x), min(y), max(y))

xs,ys = np.mgrid[extent[0]:extent[1]:N, extent[2]:extent[3]:N]

resampled = griddata(x, y, z, xs, ys)

plt.imshow(resampled.T, extent=extent)
s=18
plt.ylabel(r"$a_v$", size=s)
plt.xlabel(r"$a_{\rm min}$", size=s)
plt.xlim([x.min(),x.max()])
plt.ylim([y.min(),y.max()])
cbar=plt.colorbar()
plt.show()

With this result:
enter image description here

My problem is obviosly why imshow() does invert the data? What happens here exactly?

PS: Here are the data, in case someone would like to play with them

  • 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-17T07:01:36+00:00Added an answer on June 17, 2026 at 7:01 am

    Look at the keyword arguments of imshow. There is origin. The default is “upper”, but you want “lower”.

    The default makes sense for plotting images, that usually start at the top-left corner. For most matrix-plotting, you’ll want origin="lower"

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

Sidebar

Related Questions

I am trying to plot some data using pylab scatter function. I'm using pylab.scatter(X,
I'm trying to plot some data into a histogram using pyplot.hist as such: hst
I am trying to plot some data and I am getting this error from
I'm using GD to plot some simple charts from array point data.. Trying to
I am trying to plot some HDF data in matplotlib. After importing them using
So I have some data import pyfits import matplotlib.pyplot a = pyfits.getdata('data.fits') x =
I am trying to make a 2D density plot (from some simulation data) with
I am trying to plot some data from Flexible Image Transport System (FITS) files,
I am trying to plot (with Gnuplot) some basic 3d data from one file
In my code I am trying to extract some data from a file. I

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.