I tried to implement a solution for this issue. Basically I want to
give the x and y position in datacoords and the width + height in
However, when using the following code:
im = Image.open("../Icons/Program Icon.png")
limx = self.mainAxes.get_xlim()
limy = self.mainAxes.get_ylim()
[x0, y0], [x1, y1] = self.mainAxes.bbox.get_points()
datawidth = limx - limx
dataheight = limy - limy
pixelwidth = x1 - x0
pixelheight = y1 - y0
adaptedwidth = im.size * (datawidth/pixelwidth)
adaptedheight = im.size * (dataheight/pixelheight)
for peak in Blocks.peaks(self.quote.Close,
self.mainAxes.imshow(im, origin = 'lower', extent =
(date2num(peak.datetime), date2num(peak.datetime) + 100 , 400, 425)) #
left right bottom top
There is no visible result. When zooming in to a place where an image
should be present I encounter the following error every time I move
Traceback (most recent call last):
line 135, in mouseReleaseEvent
FigureCanvasBase.button_release_event( self, x, y, button )
line 1198, in button_release_event
File "C:\Python25\lib\site-packages\matplotlib\cbook.py", line 155, in process
line 2048, in release_zoom
line 2070, in draw
line 133, in draw
line 279, in draw
File "C:\Python25\lib\site-packages\matplotlib\figure.py", line 772, in draw
for a in self.axes: a.draw(renderer)
File "C:\Python25\lib\site-packages\matplotlib\axes.py", line 1545, in draw
File "C:\Python25\lib\site-packages\matplotlib\image.py", line 233, in draw
im = self.make_image(renderer.get_image_magnification())
File "C:\Python25\lib\site-packages\matplotlib\image.py", line 220,
rx = widthDisplay / numcols
ZeroDivisionError: float division
Any idea what might cause this issue? Did I do something wrong? I know
it's not pretty, but it should work right?
2009/7/30 Bas van Leeuwen <leeuwen@...287...>:
Thank you for your kind and speedy reply, I completely glanced over
the extent parameter.
Datacoords are actually what I need so this is perfect for me.
To clarify what I want, I want to mark certain parts of a graph with
an icon representing the reason it's interesting. Icons are for peaks,
trends, correlation, etc.
Thank you very much!
2009/7/30 Jae-Joon Lee <lee.j.joon@...287...>:
The location of the image can be set by specifying the "extent"
keyword, however, this is set in data coordinate.
figimage may be close to what you want.
As far as I know, there is no direct support in matplotlib to place an
image with arbitrary transformation. But it may not be difficult to
implement. However, "annotate a plot with icons" is not enough to
figure out what you really want.
Maybe some screenshots from other plotting tool will be helpful. Or,
please elaborate how you want to position your image.
On Thu, Jul 30, 2009 at 12:11 PM, Bas van Leeuwen<leeuwen@...287...> wrote:
Is there any way to annotate a plot with icons?
The only way to include an image that I've found is using imshow, but
imshow does not accept (x,y) coordinates.
There probably is an easy solution, but I have not been able to find
any. Please be patient
Thank you in advance for your reply,
Bas van Leeuwen
PS, I'm sorry if this mail arrives multiple times, I didn't see the
previous one in the archive.
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
Matplotlib-users mailing list