|
From: kmilner <km...@us...> - 2009-03-23 21:10:15
|
Hi All, I'm trying to plot evenly grided data to tiles for google maps overlays. Each tile needs to be a 256x256 pixel PNG image, without any borders. The problem that I'm having is that the leftmost column of the resultant PNG image (saved using FigureCanvasAgg.print_figure) is transparent. My real code uses basemap because the output has to be in the mercator projection, but the sample code below is simplified to exclude it. You can view the sample image that is produced at this address: http://earth.usc.edu/ftp/kmilner/trans_test.png Any ideas? Thanks! Kevin #!/usr/bin/env python from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas from matplotlib.figure import Figure import numpy dpi = 64 pixels = 256 fig = Figure(linewidth=0, frameon=False) canvas = FigureCanvas(fig) fig.figurePatch.set_alpha(0.0) ax_bounds = [0, 0, 1, 1] ax = fig.add_axes(ax_bounds, axisbg=(1.0,1.0,0.0,0.0), frameon=False ) inches = pixels / dpi fig.set_size_inches(256 / dpi, 256 / dpi) num = 31 z = numpy.empty( (num, num) ) for x in xrange(num): for y in xrange(num): z[x, y] = x * y x, y = numpy.meshgrid( range(num), range(num) ) image = ax.pcolor(x, y, z) image = ax.contourf(x, y, z) canvas.print_figure("/tmp/trans_test.png", dpi=dpi) -- View this message in context: http://www.nabble.com/Leftmost-column-of-PNG-output-is-transparent-tp22669232p22669232.html Sent from the matplotlib - users mailing list archive at Nabble.com. |
|
From: Jae-Joon L. <lee...@gm...> - 2009-03-25 16:29:53
|
I couldn't reproduce it (my output has no transparent column). I'm running the current svn. I wonder if others can reproduce it. Kevin, what happen if you only do one of the pcolor or the contourf (it is not clear why you're calling pcolor as it will be overridden by contourf)? -JJ On Mon, Mar 23, 2009 at 5:10 PM, kmilner <km...@us...> wrote: > > Hi All, > > I'm trying to plot evenly grided data to tiles for google maps overlays. > Each tile needs to be a 256x256 pixel PNG image, without any borders. > > The problem that I'm having is that the leftmost column of the resultant PNG > image (saved using FigureCanvasAgg.print_figure) is transparent. > > My real code uses basemap because the output has to be in the mercator > projection, but the sample code below is simplified to exclude it. You can > view the sample image that is produced at this address: > http://earth.usc.edu/ftp/kmilner/trans_test.png > > Any ideas? > > Thanks! > Kevin > > #!/usr/bin/env python > > from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas > from matplotlib.figure import Figure > import numpy > > dpi = 64 > pixels = 256 > fig = Figure(linewidth=0, frameon=False) > canvas = FigureCanvas(fig) > > fig.figurePatch.set_alpha(0.0) > > ax_bounds = [0, 0, 1, 1] > > ax = fig.add_axes(ax_bounds, axisbg=(1.0,1.0,0.0,0.0), > frameon=False ) > > inches = pixels / dpi > fig.set_size_inches(256 / dpi, 256 / dpi) > > num = 31 > > z = numpy.empty( (num, num) ) > > for x in xrange(num): > for y in xrange(num): > z[x, y] = x * y > > x, y = numpy.meshgrid( range(num), range(num) ) > > image = ax.pcolor(x, y, z) > image = ax.contourf(x, y, z) > > canvas.print_figure("/tmp/trans_test.png", dpi=dpi) > -- > View this message in context: http://www.nabble.com/Leftmost-column-of-PNG-output-is-transparent-tp22669232p22669232.html > Sent from the matplotlib - users mailing list archive at Nabble.com. > > > ------------------------------------------------------------------------------ > Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are > powering Web 2.0 with engaging, cross-platform capabilities. Quickly and > easily build your RIAs with Flex Builder, the Eclipse(TM)based development > software that enables intelligent coding and step-through debugging. > Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > |
|
From: Kevin M. <km...@us...> - 2009-03-25 16:35:37
|
Maybe I'll try the latest SVN version. I'm running the version in the ubuntu 8.10 repositories, which appears to be 0.98.3 As for both contourf and pcolor, I was just testing to see that it was messed up either way, leaving one commented and one uncommented. Having them both uncommented was just a typo, but the problem persists either way. Thanks, Kevin Jae-Joon Lee wrote: > I couldn't reproduce it (my output has no transparent column). I'm > running the current svn. I wonder if others can reproduce it. > > Kevin, > what happen if you only do one of the pcolor or the contourf (it is > not clear why you're calling pcolor as it will be overridden by > contourf)? > > -JJ > > > On Mon, Mar 23, 2009 at 5:10 PM, kmilner <km...@us...> wrote: > >> Hi All, >> >> I'm trying to plot evenly grided data to tiles for google maps overlays. >> Each tile needs to be a 256x256 pixel PNG image, without any borders. >> >> The problem that I'm having is that the leftmost column of the resultant PNG >> image (saved using FigureCanvasAgg.print_figure) is transparent. >> >> My real code uses basemap because the output has to be in the mercator >> projection, but the sample code below is simplified to exclude it. You can >> view the sample image that is produced at this address: >> http://earth.usc.edu/ftp/kmilner/trans_test.png >> >> Any ideas? >> >> Thanks! >> Kevin >> >> #!/usr/bin/env python >> >> from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas >> from matplotlib.figure import Figure >> import numpy >> >> dpi = 64 >> pixels = 256 >> fig = Figure(linewidth=0, frameon=False) >> canvas = FigureCanvas(fig) >> >> fig.figurePatch.set_alpha(0.0) >> >> ax_bounds = [0, 0, 1, 1] >> >> ax = fig.add_axes(ax_bounds, axisbg=(1.0,1.0,0.0,0.0), >> frameon=False ) >> >> inches = pixels / dpi >> fig.set_size_inches(256 / dpi, 256 / dpi) >> >> num = 31 >> >> z = numpy.empty( (num, num) ) >> >> for x in xrange(num): >> for y in xrange(num): >> z[x, y] = x * y >> >> x, y = numpy.meshgrid( range(num), range(num) ) >> >> image = ax.pcolor(x, y, z) >> image = ax.contourf(x, y, z) >> >> canvas.print_figure("/tmp/trans_test.png", dpi=dpi) >> -- >> View this message in context: http://www.nabble.com/Leftmost-column-of-PNG-output-is-transparent-tp22669232p22669232.html >> Sent from the matplotlib - users mailing list archive at Nabble.com. >> >> >> ------------------------------------------------------------------------------ >> Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are >> powering Web 2.0 with engaging, cross-platform capabilities. Quickly and >> easily build your RIAs with Flex Builder, the Eclipse(TM)based development >> software that enables intelligent coding and step-through debugging. >> Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com >> _______________________________________________ >> Matplotlib-users mailing list >> Mat...@li... >> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >> >> |