Hi, all. I have a problem when using matpltlib and pygtk. When I draw a very
very long line in a figure, the line cannot be drawn as it should be. For
example, consider the codes below:

---------------------Beginning of codes----------------------
#!/usr/bin/env python
import gtk

from matplotlib.figure import Figure
from matplotlib.lines import Line2D

from matplotlib.backends.backend_gtkagg import FigureCanvasGTK as
FigureCanvas
from matplotlib.backends.backend_gtkagg import NavigationToolbar2GTK as
NavigationToolbar
# Uncomment the two lines below to use GTKAgg as a different backend
#from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg as
FigureCanvas
#from matplotlib.backends.backend_gtkagg import NavigationToolbar2GTKAgg \
#                                                                   as
NavigationToolbar

win = gtk.Window()
win.connect("destroy", lambda x: gtk.main_quit())
win.set_default_size(400,300)
win.set_title("Embedding in GTK")
vbox = gtk.VBox()
win.add(vbox)

fig = Figure()
ax = fig.add_subplot(111)
ax.grid(True)
ax.set_autoscale_on(False)
ax.set_xlim(0, 2)
ax.set_ylim(-2, 2)
ax.plot([1, 1, 20000,20000], [-1, 1, 1, 0])

canvas = FigureCanvas(fig)
vbox.pack_start(canvas)
toolbar = NavigationToolbar(canvas, win)
vbox.pack_start(toolbar, False, False)
win.show_all()
gtk.main()

---------------------End of codes----------------------
You might think that it will show a line like this:

+--------------------------------------------------------...
                               |
       A
very very long line ....
                               |
                               |
                               |
                               |
But the result is like this:
        ...----------------------------------------------------------+
  Also a very very long line  ...                                      |

|

|

|

You can view the picture here:
http://ljiaping.googlepages.com/embedding_in_gtk1.jpg

And if you use the zoom button in the navigation toolbar to zoom out this
image, the horizontal line will change its direction to right. You can view
the picture here:
http://ljiaping.googlepages.com/embedding_in_gtk2.jpg

But if you use GTKAgg as matplotlib's backend the figure shows properly.
Here is the source code file
embedding_in_gtk.py<http://ljiaping.googlepages.com/embedding_in_gtk.py>,
you can try it yourself.

I have tried to read the source codes of the library to know the reason, but
I have not enough knowledge of image processing and I failed.
Any help is appreciated. Thank you.
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to