[Matplotlib-users] Colobar and change axis x and y labels
Hello,
I don't know if I can ask questions concerning matplotlib problems
in this email list ... just let me know that this is not the right
place, if.
I have an image, which I can read and put into a figure. The image
has axis and I can even save the image. I have two issues:
1. Since it is an 512 x 512 pixel image, the x and y axis labels
go from 0 to 500. However, I don't want these labels, I want to
change them to, e.g., 0 .. 3400 and 0 .. 3400. How can I do this?
2. I tried to attach a color bar to the right of the image but without
success. Have you a hint?
The code can be found below, it is a rather simple one.
Thanks in advance for any help.
Pythphys.
*
import scipy
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import numpy as np
file_path = "path_to_file"
# The binary file is read
data = scipy.fromfile(file=file_path,dtype=scipy.int16)
data = data.byteswap()
# The file has 512 x 512 pixel
data.shape = 512, 512
# The following code works fine. However, I still need:
#
# - Color bar (plt.color() does not work)
# - The x and y labels are 0 ... 500 and 0 ... 500 <= I want to change
these labels. How.
fig = plt.figure()
frame = plt.subplot(111)
frame.imshow(data)
frame.axis()
plt.xlabel('X (nm)')
plt.ylabel('Y (nm)')
plt.savefig("image")
--
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Fwd: Re: Colobar and change axis x and y labels
Thanks Alexa and Jerzy.
other questions? ... Here they are:
- changing to an image grey scale only needs ... what?
- I need to do a 'plane fit' of the image. Does matplotlib
have some routine for this? Or shall I use other math libs?
Thanks again.
> Le 16/02/2012 02:20, Alexa Villaume a écrit :
>> Try using 'xticks' and 'yticks', those commands let you define the
>> location and label fo your tick marks.
>>
> This *alone* will not do, the image might be scaled badly. Add extent.
>
> Try this:
>
> fig = plt.figure()
> frame = plt.subplot(111)
> im=frame.imshow(data,extent=[0,3400,0,3400])
> plt.xticks([0,3400]); plt.yticks([0,3400])
> plt.xlabel('X (nm)')
> plt.ylabel('Y (nm)')
> plt.colorbar(im)
>
> plt.show()
>
> ==
>
> Jerzy Karczmarczuk
> Caen, France
>
>
>
> --
> Virtualization& Cloud Management Using Capacity Planning
> Cloud computing makes use of virtualization - but cloud computing
> also focuses on allowing computing to be delivered as a service.
> http://www.accelacomm.com/jaw/sfnl/114/51521223/
> ___
> Matplotlib-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
--
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
