On Fri, Dec 9, 2011 at 4:11 PM, Daniel Hyams <dhy...@gmail.com> wrote:
> I'm sorry, I should have stated the version. I'm using 1.0.0, which just
> returns a list of rectangle artists.
>
>
> On Fri, Dec 9, 2011 at 4:08 PM, Benjamin Root <ben.r...@ou.edu> wrote:
>
>> On Fri, Dec 9, 2011 at 2:55 PM, Daniel Hyams <dhy...@gmail.com> wrote:
>>
>>> Tried, but unfortunately it did not make any difference :(
>>>
>>>
>> Just as an interesting point... don't know if it means anything. In
>> v1.1.x, we now return a "BarContainer" from the bar() function. This
>> container subclasses the tuple type, which is why you are still able to
>> treat it like a list. Anyway, this class does a bunch of things that I
>> wonder if it could be interfering with what you are trying to do. Probably
>> not, but still...
>>
>> Ben Root
>>
>>
>
>
> --
> Daniel Hyams
> dhy...@gmail.com
>
So I think the problem is that ``plt.bar`` assigns a transform to each
patch (as it should). But then when pass these patches to PatchCollection,
the collection applies it's own transform (but doesn't ignore the patch's
transform, apparently). The solution is to clear out the transform on each
patch---where "clearing" a transform translates to setting it to the
IdentityTransform.
Below is code that works *on my system*. It sounds like it will work
slightly differently on your system:
#!/usr/bin/env python
import numpy
import matplotlib.pyplot as plt
import matplotlib.collections
import matplotlib.transforms as transforms
# just generate some data to plot
x = numpy.linspace(0.0,2.0*numpy.pi,10)
y = numpy.sin(x)
# plot
axes = plt.gca()
bars = plt.bar(x,y,color='red',width=0.1)
axes.patches = []
for p in bars.patches:
p.set_transform(transforms.IdentityTransform())
## and create a collection for plotting the rectangles instead.
coll = matplotlib.collections.PatchCollection(bars.patches)
coll.set_transform(axes.transData)
axes.add_collection(coll, autolim=True)
plt.xlim(0.0,2.0*numpy.pi)
plt.grid(True)
plt.show()
------------------------------------------------------------------------------
Cloud Services Checklist: Pricing and Packaging Optimization
This white paper is intended to serve as a reference, checklist and point of
discussion for anyone considering optimizing the pricing and packaging model
of a cloud services business. Read Now!
http://www.accelacomm.com/jaw/sfnl/114/51491232/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users