On 9/11/07, James Evans <[EMAIL PROTECTED]> wrote: > When using the 'bar' plot command, unit information is lost when changing > the units for a given axis. The attached script demonstrates this.
> This is not the case for line plots because of the use of Line2D's 'recache' > method. While the script clearly reveals a bug, but I don't think it is the recache method (or its absence) that is the culprit. Rather it is the conversion of the Axe.bar arguments (left, bottom, etc...) to arrays before they can get stored array in their respective Rectangle instances. I removed this conversion, and bar now should create the Rectangle instances with unit info intact. But there is an additional problem -- bar specifies the width and bottom as optional scalar arguments, and to be safe, I suggest you pass in dimensional values for these as well when using a unitized bar chart. Otherwise they will be scalar and will default to the current units, which is probably not what you want under a unit change (your bar widths will be different under changes of units). Here is a modified test script that appears to be working properly under svn (r3844) with my recent change: from pylab import figure, show, nx cms = cm *nx.arange(0, 10, 2) bottom=0*cm width=0.8*cm fig = figure() ax1 = fig.add_subplot(2,2,1) ax1.bar(cms, cms, bottom=bottom) ax2 = fig.add_subplot(2,2,2) ax2.bar(cms, cms, bottom=bottom, width=width, xunits=cm, yunits=inch) ax3 = fig.add_subplot(2,2,3) ax3.bar(cms, cms, bottom=bottom, width=width, xunits=inch, yunits=cm) ax3.set_xlim(3, 6) # scalars are interpreted in current units ax4 = fig.add_subplot(2,2,4) ax4.bar(cms, cms, bottom=bottom, width=width, xunits=inch, yunits=inch) #fig.savefig('simple_conversion_plot.png') ax4.set_xlim(3*cm, 6*cm) # cm are converted to inches show() ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel