## Re: [Matplotlib-users] Plot only inside a disc

 Re: [Matplotlib-users] Plot only inside a disc From: John Hunter - 2009-01-30 16:29:18 On Fri, Jan 30, 2009 at 10:27 AM, wrote: > Hmm ... this doesn't quite give me what I'm looking for. When I do that, I get a semitransparent circle that is clipped to a rectangle. What I need is a semi-transparent rectangle (with a hole cut out of the middle) that overlays the plot. The attached graphic demonstrates the concept. It sounds like what you want is a complex path and may not need to muck with clipping at all. Take a look at http://matplotlib.sourceforge.net/examples/api/donut_demo.html

 Re: [Matplotlib-users] Plot only inside a disc From: - 2009-01-29 19:40:51 Flashmail

Thanks, your example works but what I must do so to plot for example y=cos x ? I'm a very beginner.

Christophe.

----Message d'origine----
>Date: Thu, 29 Jan 2009 09:34:11 -0600
>Sujet: Re: [Matplotlib-users] Plot only inside a disc
>De: John Hunter
>A: projetmbc@...
>Copie à: matplotlib-users@...
>
>On Thu, Jan 29, 2009 at 9:19 AM, wrote:
>> Hello,
>> I would like to make a kind of magnifying glass. So I need to have a piece of
>> a graph and I would like it to have the form of a disc rather than of a box.
>> So is-it possible to only draw in a disc (I'm searching for a fast way to do
>> that) ?
>
>You can turn off the rendering of the normal axes and axis, and clip
>your data to an arbitrary patch or path; eg
>
>
> """
> Clipping to arbitrary patches and paths
> """
> import numpy as np
> import matplotlib.pyplot as plt
> import matplotlib.path as path
> import matplotlib. patches as patches
>
>
> fig = plt.figure()
> ax = fig.add_subplot(111, frameon=False, xticks=[], yticks=[])
>
> im = ax.imshow(np.random.rand(10,10))
>