Should gc.set_alpha accept strings?

Hi everybody,

Should the set_alpha method of a graphics context accept a string (instead of a number) as an argument? Currently, some backends (agg, ps, pdf) accept strings such as "0.2", whereas others (svg, cairo, Mac OS X) do not. Usually that is not a problem, since in almost all cases set_alpha is called with a number as the argument. However, the example axes_zoom_effect.py, which was recently added to examples/pylab_examples, has these lines:

    prop_patches["alpha"]="0.2"

which causes a call to gc.set_alpha of the form gc.set_alpha("0.2"). Backends that do not allow strings choke on that.

Whereas in general it may perhaps be useful to allow such strings, it adds complexity to the code, and I don't see a good use case for it.

--Michiel.

I committed the original example into the svn, and I admit that I was
not careful with the code. I agree that the arguments should be float
(the doc does say that set_alpha takes float).
The example is now updated to use floats (svn r7300).

Regards,

-JJ

···

On Mon, Jul 27, 2009 at 9:15 AM, Michiel de Hoon<mjldehoon@...42...> wrote:

Hi everybody,

Should the set_alpha method of a graphics context accept a string (instead of a number) as an argument? Currently, some backends (agg, ps, pdf) accept strings such as "0.2", whereas others (svg, cairo, Mac OS X) do not. Usually that is not a problem, since in almost all cases set_alpha is called with a number as the argument. However, the example axes_zoom_effect.py, which was recently added to examples/pylab_examples, has these lines:

prop_patches["alpha"]="0.2"

which causes a call to gc.set_alpha of the form gc.set_alpha("0.2"). Backends that do not allow strings choke on that.

Whereas in general it may perhaps be useful to allow such strings, it adds complexity to the code, and I don't see a good use case for it.

--Michiel.

------------------------------------------------------------------------------
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel