Python Forum
New to Python & Matplotlib - can I change the plot grid origin to lower left corner?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
New to Python & Matplotlib - can I change the plot grid origin to lower left corner?
#1
I'm completely new to Python and can't figure out what search terms to use to find the answer. I'm plotting very small images from a CCD and would like the grid/axes (0, 0) point to be in the lower left corner - not the middle of the rows/columns; that aligns the grid to the middle of the pixels. Here is the code I'm using for a 5 pixel x 5 pixel image showing a very "zoomed in" view of the CCD:

import matplotlib.pyplot as plt
import numpy as np

image = [[175.94289, 177.74895, 158.87912, 145.34993, 148.05937],
        [177.55653, 165.20393, 160.09775, 161.71048, 149.43646],
        [162.94765, 160.01396, 204.08203, 289.2722,  221.55945],
        [147.64162, 153.57835, 331.3954, 383.78668, 233.15973],
        [146.21872, 154.15912, 230.50053, 234.13762, 186.50993]]

npimage = np.array(image)

fig = plt.figure(figsize=(5, 5))
axes = fig.add_axes
plt.imshow(npimage, origin='lower', cmap='YlGnBu_r',
           vmax=np.percentile(npimage, 98), vmin=np.percentile(npimage, 5))
plt.xlabel('Image Column', fontsize=14)
plt.ylabel('Image Row', fontsize=14)
plt.grid(axis='both', color='white', ls='solid')

plt.show()
Reply
#2
Hello, I don't understand english very well but you should add this line in your code

plt.axis([0, 4, 0, 4])
Tell me if this is what you were searching for.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Pick a line in a plot with matplotlib Romain 3 5,622 Feb-28-2023, 11:56 AM
Last Post: get2sid
  Matplotlib scatter plot in loop with None values ivan_sc 1 2,268 Nov-04-2021, 11:25 PM
Last Post: jefsummers
  Matplotlib scatter plot slider with datetime sonny 0 2,950 Feb-05-2021, 02:31 AM
Last Post: sonny
  matplotlib creating a scatter plot via PathCollection tpourjalali 0 2,471 Apr-11-2020, 05:59 PM
Last Post: tpourjalali
  Plot/Image analysis %of colored area(grid) TiBotLCPP 0 1,834 Jul-09-2019, 02:33 PM
Last Post: TiBotLCPP
  MatPlotLib 2d plot of current density? ruben 0 2,202 May-13-2019, 06:47 AM
Last Post: ruben
  chessboard corner detection algorithm marlinayakno 1 4,023 Mar-08-2019, 12:40 AM
Last Post: scidam
  Bar Plot with Python ,matplotlib and sqlite3 tables gauravbhardwajee 0 4,955 Sep-25-2018, 06:17 PM
Last Post: gauravbhardwajee
  Draw a square-aspect log-linear plot via matplotlib Antonio 4 8,398 Jun-19-2018, 05:57 PM
Last Post: Antonio
  Remove internal lines donut plot matplotlib diego_last 5 6,267 Dec-14-2017, 04:05 PM
Last Post: diego_last

Forum Jump:

User Panel Messages

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