Poll: Which objects should be plotted by default in the notebook?

89 views
Skip to first unread message

Nathann Cohen

unread,
Apr 29, 2015, 11:15:34 AM4/29/15
to Sage devel, Volker Braun, Vincent Delecroix, Karl-Dieter Crisman
Hello everybody,

In #18289 [2], Volker is improving the Notebook interface by making
some objects be automatically plotted by __repr__ [1]

graphs.PetersenGraph() # this graph is plotted

or

P = posets.ChainPoset(10) # no plot
P # here, P is plotted

So far he only implemented it for graphs (with <20 vertices), but more
objects should be added to the list. For instance:

- Posets
- Finite State Machine
- Permutations (?)
- Crystals (?)

Basically everything that has a .plot() command can appear there. I
expect that you would like some trees to be plotted too. Like
DyckWords, or something.

Whoever you are, name here the objects which you think should be
plotted (with some condition ensuring that the plot is 'small')

Thanks,

Nathann

[1] This is an oversimplification. Let us just say that whenever you
expect __repr__ to be called, you will see a drawing instead. The
actual mechanism is more complicated.
[2] http://trac.sagemath.org/ticket/18289#comment:87

leif

unread,
Apr 29, 2015, 12:38:29 PM4/29/15
to sage-...@googlegroups.com
Nathann Cohen wrote:
> Hello everybody,
>
> In #18289 [2], Volker is improving the Notebook interface by making
> some objects be automatically plotted by __repr__ [1]
>
> graphs.PetersenGraph() # this graph is plotted
>
> or
>
> P = posets.ChainPoset(10) # no plot
> P # here, P is plotted

I'm actually more interested in what happens in the console; I don't
want to get *any* pop-up windows unless I explicitly ask for them.

My 0.2e-15 ct,

-leif


┌────────────────────────────────────────────────────────────────────┐
│ SageMath Version 6.7.beta3, Release Date: 2015-04-28 │
│ Type "notebook()" for the browser-based notebook interface. │
│ Type "help()" for help. │
└────────────────────────────────────────────────────────────────────┘
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Warning: this is a prerelease version, and it may be unstable. ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
sage: graphs.PetersenGraph()
Launched png viewer for Petersen graph: Graph on 10 vertices
sage:

... and nothing happens, no error messages, no windows at all.
(Setting SAGE_BROWSER to e.g. xdg-open doesn't make a difference.)

sage: sage.misc.viewer.browser()
'sage-native-execute xdg-open'
sage: sage.misc.viewer.png_viewer()
'sage-native-execute xdg-open'
sage: !xdg-open
xdg-open - opens a file or URL in the user's preferred application

Synopsis

xdg-open { file | URL }

xdg-open { --help | --manual | --version }

Use 'man xdg-open' or 'xdg-open --manual' for additional info.
sage:

And yes, e.g.

$ xdg-open ~/.sage/ipython-3.1.0/kernels/sage_6_7_beta3/logo-64x64.png

works as expected.


kcrisman

unread,
Apr 29, 2015, 2:50:34 PM4/29/15
to sage-...@googlegroups.com
>
> In #18289 [2], Volker is improving the Notebook interface by making
> some objects be automatically plotted by __repr__ [1]
>
>     graphs.PetersenGraph() # this graph is plotted
>
> or
>
>     P = posets.ChainPoset(10) # no plot
>     P # here, P is plotted

I'm actually more interested in what happens in the console; I don't
want to get *any* pop-up windows unless I explicitly ask for them.


I think my views are already known to those thinking about this, but anyway:

There are lots of things that could have plots that should not have them unless specifically requested.  E.g. matrices, graphs, posets... This would be a pretty big change to start bringing up plots in such cases.  (Like matrices - yikes!)

On the other hand, things that *are* plots should be plotted (duh) and if you ask to "show" them, since the default behavior has been to plot and not LaTeX, that should probably continue.

Nathann Cohen

unread,
Apr 29, 2015, 3:47:03 PM4/29/15
to sage-...@googlegroups.com
Hello !

There are lots of things that could have plots that should not have them unless specifically requested.  E.g. matrices, graphs, posets... This would be a pretty big change to start bringing up plots in such cases.  (Like matrices - yikes!)

My opinion on this is simple: 
- I do not use the notebook
- I have no strong reason to oppose that change if people want it (the command-line is not affected)
- I do not want graphs to be the only objects that get printed automatically.

Either it is something relatively standard (and a behaviour that users can expect) or we just should not do it.

This being said, if nobody wants it, now is the time to voice your opinion: it is being implemented right now on #18289 [1].

Nathann

Justin C. Walker

unread,
Apr 29, 2015, 4:32:21 PM4/29/15
to sage-...@googlegroups.com, Volker Braun, Vincent Delecroix, Karl-Dieter Crisman

On Apr 29, 2015, at 08:15 , Nathann Cohen wrote:

> Hello everybody,
>
> In #18289 [2], Volker is improving the Notebook interface by making
> some objects be automatically plotted by __repr__ [1]
>
> graphs.PetersenGraph() # this graph is plotted
>
> or
>
> P = posets.ChainPoset(10) # no plot
> P # here, P is plotted
>
> So far he only implemented it for graphs (with <20 vertices), but more
> objects should be added to the list. For instance:
>
> - Posets
> - Finite State Machine
> - Permutations (?)
> - Crystals (?)
>
> Basically everything that has a .plot() command can appear there. I
> expect that you would like some trees to be plotted too. Like
> DyckWords, or something.

I'm not in favor of having plotting done by __repr__ automatically, for the reasons others have mentioned.

--
Justin C. Walker
Curmudgeon-at-large
--
Network, n., Difference between work
charged for and work done



Volker Braun

unread,
Apr 30, 2015, 12:03:29 AM4/30/15
to sage-...@googlegroups.com, vbrau...@gmail.com, vincent....@labri.fr, kcri...@gmail.com
So far the objections have already been discussed on trac. I know, TL;DR:

* You can turn it off: %display plot_graphs never

* The console has it turned off by default, this is only a question for UIs that can display inline graphics.

* Some graphs have displayed themselves graphically in the SageNB notebook since forever if you check "typeset" (as tkz latex)


Nathann Cohen

unread,
Apr 30, 2015, 5:09:49 AM4/30/15
to Sage devel
> On the other hand, things that *are* plots should be plotted (duh) and if
> you ask to "show" them, since the default behavior has been to plot and not
> LaTeX, that should probably continue.

Not exactly related, but here is the behaviour in beta3 (see [1] and [2]):

sage: show(posets.ChainPoset(5))
\newcommand{\Bold}[1]{\mathbf{#1}}0 1 2 3 4

[1] https://groups.google.com/d/topic/sage-devel/LA9xlmOjzn0/discussion
[2] http://trac.sagemath.org/ticket/17821
Reply all
Reply to author
Forward
0 new messages