path effects question

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

path effects question

John Hunter-4
I do not understand why in the following example, if I set patch_alpha=1.0, I do not see the shadow effect.  I would expect to see it for the the rightmost four bars, where the original bars do not entirely occlude the shadow, so even if alpha is 1.0, there are parts of the shadow that are not behind the original bars and should still be visible.


import matplotlib.pyplot as plt
import matplotlib.patheffects as PathEffects
import numpy as np

np.random.seed(2358)
fig = plt.figure()

# sime bar shadows
x = np.random.randn(1000)

n, bins, patches = plt.hist(x, bins=7)
shadow = PathEffects.withSimplePatchShadow(offset_xy=(10,-10), patch_alpha=0.8, shadow_rgbFace=(0.25,0.25,0.25))
for p in patches:
    p.set_path_effects([shadow])

plt.show()

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Reply | Threaded
Open this post in threaded view
|

Re: path effects question

John Hunter-4


On Sat, Jul 14, 2012 at 11:48 AM, John Hunter <[hidden email]> wrote:
I do not understand why in the following example, if I set patch_alpha=1.0, I do not see the shadow effect.  I would expect to see it for the the rightmost four bars, where the original bars do not entirely occlude the shadow, so even if alpha is 1.0, there are parts of the shadow that are not behind the original bars and should still be visible.




I now see that this line explains the behavior


 gc0.set_alpha(1.-self._patch_alpha)

so maybe I should amend my question: is this desirable that the shadow alpha is 1-patch_alpha, since an alpha of 1 on the patch does not imply that there is no visible shadow? 



------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Reply | Threaded
Open this post in threaded view
|

Re: path effects question

Benjamin Root-2


On Saturday, July 14, 2012, John Hunter wrote:


On Sat, Jul 14, 2012 at 11:48 AM, John Hunter <<a href="javascript:_e({}, &#39;cvml&#39;, &#39;jdh2358@gmail.com&#39;);" target="_blank">jdh2358@...> wrote:
I do not understand why in the following example, if I set patch_alpha=1.0, I do not see the shadow effect.  I would expect to see it for the the rightmost four bars, where the original bars do not entirely occlude the shadow, so even if alpha is 1.0, there are parts of the shadow that are not behind the original bars and should still be visible.




I now see that this line explains the behavior


 gc0.set_alpha(1.-self._patch_alpha)

so maybe I should amend my question: is this desirable that the shadow alpha is 1-patch_alpha, since an alpha of 1 on the patch does not imply that there is no visible shadow? 



I would argue that the shadow's alpha should equal the patch's alpha.  The more opaque the patch, the less light that should get through.  Could there have been an alpha blending reason for this?

Ben Root 

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Reply | Threaded
Open this post in threaded view
|

Re: path effects question

Damon McDougall
On Sat, Jul 14, 2012 at 04:09:48PM -0400, Benjamin Root wrote:

> On Saturday, July 14, 2012, John Hunter wrote:
>
> >
> >
> > On Sat, Jul 14, 2012 at 11:48 AM, John Hunter <[hidden email]<javascript:_e({}, 'cvml', '[hidden email]');>
> > > wrote:
> >
> >> I do not understand why in the following example, if I set
> >> patch_alpha=1.0, I do not see the shadow effect.  I would expect to see it
> >> for the the rightmost four bars, where the original bars do not entirely
> >> occlude the shadow, so even if alpha is 1.0, there are parts of the shadow
> >> that are not behind the original bars and should still be visible.
> >>
> >>
> >>
> >
> > I now see that this line explains the behavior
> >
> >
> > https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/patheffects.py#L183
> >
> >  gc0.set_alpha(1.-self._patch_alpha)
> >
> > so maybe I should amend my question: is this desirable that the shadow
> > alpha is 1-patch_alpha, since an alpha of 1 on the patch does not imply
> > that there is no visible shadow?
> >
> >
>
> I would argue that the shadow's alpha should equal the patch's alpha.  The
> more opaque the patch, the less light that should get through.  Could there

I am inclined to agree here. Should it instead be:

gc0.set_alpha(self._patch_alpha)?

> have been an alpha blending reason for this?
>
> Ben Root


--
Damon McDougall
http://damon-is-a-geek.com
B2.39
Mathematics Institute
University of Warwick
Coventry
West Midlands
CV4 7AL
United Kingdom

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Reply | Threaded
Open this post in threaded view
|

Re: path effects question

Jae-Joon Lee
In reply to this post by John Hunter-4
I think it is me who put that code there. But I cannot recall why I did it.
I may have copied that behavior from other code, but cannot find which.

Yes, I agree that the current behavior is not very desirable.
So, anyone who have an idea how this should behave, please go ahead
and fix this.

Regards,

-JJ


On Sun, Jul 15, 2012 at 1:54 AM, John Hunter <[hidden email]> wrote:

>
>
> On Sat, Jul 14, 2012 at 11:48 AM, John Hunter <[hidden email]> wrote:
>>
>> I do not understand why in the following example, if I set
>> patch_alpha=1.0, I do not see the shadow effect.  I would expect to see it
>> for the the rightmost four bars, where the original bars do not entirely
>> occlude the shadow, so even if alpha is 1.0, there are parts of the shadow
>> that are not behind the original bars and should still be visible.
>>
>>
>
>
> I now see that this line explains the behavior
>
> https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/patheffects.py#L183
>
>  gc0.set_alpha(1.-self._patch_alpha)
>
> so maybe I should amend my question: is this desirable that the shadow alpha
> is 1-patch_alpha, since an alpha of 1 on the patch does not imply that there
> is no visible shadow?
>
>

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users