Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate the opacity argument for plot3d and use alpha #21984

Open
mathzeta opened this issue Nov 28, 2016 · 7 comments
Open

Deprecate the opacity argument for plot3d and use alpha #21984

mathzeta opened this issue Nov 28, 2016 · 7 comments

Comments

@mathzeta
Copy link

Most 3d plot functions use the "opacity" keyword argument to set the transparency of the plot. On the other hand, most 2d plot functions use the "alpha" keyword argument.

It seems that the "opacity" keyword argument is also not well-documented. It sometimes appears only in the Examples sections, and not in the Input section. This is the case, at least in the following:

  • plot3d()
  • line()
  • circle()
  • parametric_plot3d()
  • revolution_plot3d()

Harmonizing the 2d plot and 3d plot functions would be a better UI. For example, changing a single letter of obj.plot2d(some_args, alpha=0.5) to obj.plot3d(some_args, alpha=0.5) (or vice versa) should "just work", without ignoring arguments.

Depends on #25095

CC: @yuan-zhou @mkoeppe @slel @jcamp0x2a @paulmasson

Component: graphics

Keywords: days79

Issue created by migration from https://trac.sagemath.org/ticket/21984

@mathzeta mathzeta added this to the sage-7.5 milestone Nov 28, 2016
@yuan-zhou
Copy link

comment:1

See #25095. In the plot3d functions, the argument "alpha" is equivalent to "opacity" now.

@yuan-zhou
Copy link

Dependencies: #25095

@mkoeppe mkoeppe modified the milestones: sage-7.5, sage-9.2 Jul 22, 2020
@paulmasson
Copy link
Mannequin

paulmasson mannequin commented Jul 22, 2020

comment:4

If alpha and opacity are equivalent after #25095 then why deprecate anything? The term "opacity" is by far more common in the HTML world. I vote we deprecate this ticket...

@paulmasson paulmasson mannequin removed this from the sage-9.2 milestone Jul 22, 2020
@paulmasson paulmasson mannequin added the s: needs review label Jul 22, 2020
@mkoeppe
Copy link
Member

mkoeppe commented Jul 22, 2020

comment:6

I haven't checked but it sounds to me that there is a discrepancy between 2d and 3d, and also possibly a documentation issue.

@mathzeta
Copy link
Author

comment:7

I do not remember the original code that caused me to report this problem, but here is an example that works as expected:

sage: C = circle((0,0), 1, fill=True, alpha=0.5)
sage: C.plot()
Launched png viewer for Graphics object consisting of 1 graphics primitive
sage: C.plot3d()
Launched html viewer for Graphics3d Object

and one that does not (at least in version 9.1):

sage: C = circle((0,0), 1, fill=True, opacity=0.5)
sage: C.plot() # opacity is 1 here
verbose 0 (163: primitive.py, options) WARNING: Ignoring option 'opacity'=0.500000000000000
[...]
Launched png viewer for Graphics object consisting of 1 graphics primitive
sage: C.plot3d()
verbose 0 (163: primitive.py, options) WARNING: Ignoring option 'opacity'=0.500000000000000
[...]
NotImplementedError: Unknown plot3d equivalent for opacity

Between the terms "alpha" and "opacity" I have no strong preference (both are common, e.g. opacity in CSS and alpha in RGBA). If "opacity" is now more common in Sage, then deprecating "alpha" sounds fine. The doc for that circle function still uses alpha.

I just prefer consistency across the graphics function of Sage, and in particular that it will be easy to change obj.plot() to obj.plot3d(). It is not artificial to plot something complicated in 2d, with keywords computed from different places, and then trying to plot it again in 3d.

More generally, it is a problem of not having proper tests for graphics.

@slel
Copy link
Member

slel commented Sep 11, 2020

comment:8

Repurpose the ticket to "Make 'opacity' and 'alpha'
synonyms in all 2D and 3D plotting functions"?

@mathzeta
Copy link
Author

comment:9

Replying to @slel:

Repurpose the ticket to "Make 'opacity' and 'alpha'
synonyms in all 2D and 3D plotting functions"?

Sure, sounds sensible, but I still prefer to (also) emphasize a consistent API. For example, in the EXAMPLES section across all plotting functions mainly use just one of them, say 'opacity'.

What will happen if both 'opacity' and 'alpha' are given? Raising an error or ignoring one argument are the go-to options. Other options?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants