plot resolution discrepancy with embedding in gtk

You are selecting the GTK backend and then comparing it to GTKAgg. The
GTK backend does not support anti-aliased lines, whereas GTKAgg does.

"from matplotlib.backends.backend_gtkagg import FigureCanvasGTK as
FigureCanvas"
- should be FigureCanvasGTKAgg

examples/embedding_in_gtk.py shows embedding a matplotlib
FigureCanvasGTK (or GTKAgg) widget to a gtk.Window

Steve

···

On Wed, 2005-04-27 at 11:46 -0700, matplotlib-users- > request@lists.sourceforge.net wrote:
> Please note that my original posting was to matplotlib-users-admin by
> mistake, so not everyone saw the first part of this (below).
>
> Based on John's suggestions, I checked figsize and dpi settings and
> still find a difference in the plot quality between using pylab.figure
> and using matplotlib.figure.Figure.
>
> As a simple test, I modified the example pythonic_matplotlib.py to plot
> in a gtk window and use Figure as follows:
>
> ----------
> from pylab import figure, close, axes, subplot, show
> from matplotlib.numerix import arange, sin, pi
>
> import pygtk
> pygtk.require("2.0")
> import os, gtk
> import matplotlib
> matplotlib.use('GTKAgg')
>
> from matplotlib.backends.backend_gtkagg import FigureCanvasGTK as
> FigureCanvas
> from matplotlib.figure import Figure
>
> t = arange(0.0, 1.0, 0.01)
>
> #fig = figure(1)
> fig = Figure(dpi=100)
>
> ax1 = fig.add_subplot(211)
> ax1.plot(t, sin(2*pi*t),antialiased=True,linewidth=0.5)
> ax1.grid(True)
> ax1.set_ylim( (-2,2) )
> ax1.set_ylabel('1 Hz')
> ax1.set_title('A sine wave or two')
>
> for label in ax1.get_xticklabels():
> label.set_color('r')
>
>
> ax2 = fig.add_subplot(212)
> ax2.plot(t, sin(2*2*pi*t),antialiased=True,linewidth=0.5)
> ax2.grid(True)
> ax2.set_ylim( (-2,2) )
> l = ax2.set_xlabel('Hi mom')
> l.set_color('g')
> l.set_fontsize('large')
>
> win = gtk.Window()
> win.set_default_size(800,600)
> win.set_title("Plotting in a GTK Window")
> win.connect("destroy", lambda x: gtk.main_quit())
> vbox = gtk.VBox()
> canvas = FigureCanvas(fig)
>
> vbox.pack_start(canvas)
> win.add(vbox)
> win.show_all()
> gtk.main()
>
> #show()
> -------------
>
> With dpi=100 (the value in my .matplotlibrc),
> win.set_default_size(800,600) makes the size consistent with
> 'figure.figsize : 8, 6 ' in my .matplotlibrc and the plots are indeed
> the same size. Note I also explicitly set antialiased=True and
> linewidth=0.5 in the plot method calls to be consistent with my rc file.
>
> Compared to the original example, with embedding the sine waves plot
> jaggy, the border around the plot is not as bold, and the text is
> (slightly) bigger. Am I hallucinating or is there something else
> affecting the plot attributes? Thanks for any feedback.
>
> Jeff Orrey
>