skip to Main Content

partially solved : Works in jmol trough Sage CLI

3D plot remains blank in SageMath in Jupyter Notebook

Edit: This problem still remains unsolved, I have tried to even boot into a different OS (Debian instead of Kali) (not using anaconda, will (hopefully) get more time to try that)

As the title describes and illustrated by this screenshot:

Command for 3D plot produces white instead of interactive 3D plot

Instead of the expected 3D plot, just a white plain background with a question mark in it, that, when clicked, displays a menu like this:

Menu obtained when clicking the empty plot

I have now experimented quite a bit on this example (on my system) and… to give an example:

This shows just a black square (while it’s supposed to show a sphere):

sage: u = var('u')
sage: circle = (cos(u), sin(u))
sage: rp = revolution_plot3d
sage: rp(circle, (u, 0, 2*pi), axis=(0, 0),
....:    show_curve=True, opacity=0.5).show(aspect_ratio=(1, 1, 1))

The following code is (I guess) a bit better, but still not really "as it should be", or "as expected":

sage: u = var('u')
sage: circle = (cos(u), sin(u))
sage: rp = revolution_plot3d
sage: rp(circle, (u, 0, 2*pi), axis=(0, 0), frame=False,
....:    show_curve=True, opacity=0.5).show(aspect_ratio=(1, 1, 1))

(Change: include frame=False somewhere in the last line).

Inspiration

I am trying to recreate this 3D plot from the SageMath documentation:

Sphere 3D plot from SageMath documentation

Info/Logs:

  • SageMath version:

    SageMath version 9.2, Release Date: 2020-10-24
    
  • OS: Kali Linux

  • SageMath installed via apt:

    sudo apt-get install sagemath
    

I do not need to "get" this solved anytime soon, Right now I am mostly doing matrix operations, and such. so – there is no "hurry" with coming up with a solution here! It would just be a [plus+] to be able to do as the problem describe, but it is not necessary.

Any help is greatly appreciated!
Thanks!

4

Answers


  1. Chosen as BEST ANSWER

    MAJOR UPDATE:

    To not introduce false hope to the future readers: I have NOT solved it in Jupyter notebook.

    But

    I have (probably) fixed it with a viewer, my system had Jmol pre installed; (probably because I liked it before, and did some exercises with it, as in Matlab)

    The (partial) solution:

    But here is the thing, when I access a SAGE terminal (bash -> sage) and for example, plotting something that normally would just result in either white - or a black screen in Jupyter whatever I tried to do to make it work;

    It opens up a jmol window (the, actual application - Jmol)

    and plots it.

    I did not know it was this easy to get Jmol and sage math to work together (a actual fact; I did not even know this was possible.

    Screenshots

    here are a few screenshots (Jupyter - black screen, and the exact same code - but run from Sage Terminal

    In Jupyter

    Same code, but in Sage terminal:

    (Identical results) (Which, was for me impossible, even at times where I could (In Jupyter) (ugly)-plot it, it didn't show the expected results, (colors were a bit distorted, and the form had very little in common with the actual plot Sage Docs was showing)

    Jmol Window  Same code - From Sage Terminal

    To be honest, I think - I like this more, even if Jupyter would've got to work (maybe some time in the future) This - jmol application has some really neat properties, (color, axis's, and animations (rotation) and other stuff) I did really not know this at all; In Jupyter one maybe could rotate it with the mouse and zoom in, but not really change color, easily - (Not saying this is more expected result, but In my opinion - in my scenario - This was one, (*)good workaround, If not a actual solution, (In my case I will continue this way, it's flawless)

    Hopefully this is helpful for someone in the future!


  2. Like the OP (original poster), I had the same error with show3d() in a Jupyter notebook under SageMath 9.6. I was not using JMOL. In SageMath 9.7, compiled from source under Ubunto 20.10 in WSL2 on a Windows 10 system, an attempt to use show3d() in a Jupyter notebook, for example

        # Franklin Graph
        Frank = graphs.FranklinGraph()
        Frank.show3d()
    

    resulted in the following error.

        $HOME/sage/sage-9.7/src/sage/repl/rich_output/display_manager.py:610: 
        RichReprWarning: Exception in _rich_repr_ while displaying object:
        [Errno 2] No such file or directory:
        '$HOME/sage/local/lib/sage/ext_data/threejs/threejs-version.txt'
        warnings.warn(
    

    (reformatted for typographical clarity.)

    My workaround was to copy the source from $HOME/sage/sage-9.7/src/sage/ext_data/threejs to $HOME/sage/local/lib/sage/ext_data/threejs.

    This is not entirely satisfactory as the directory naming suggests that the installation of threejs did not proceed as intended. I may take this up with the SageMath development list.

    enter image description here

    Login or Signup to reply.
  3. Adding another answer because this is both quite awhile ago but also, a quite different solution

    by adding Frame=False, works flawlessly and to be sure this really, works I have tested this on numerous previous problems I had previously and it seems to work, I do not know for sure what this is about but, at least it works

    
    u = var('u')
    circle = (cos(u), sin(u))
    revolution_plot3d(circle, (u,0,2*pi), axis=(0,0), 
                      show_curve=True, opacity=0.5).show(aspect_ratio=(1,1,1),
                                                         frame=False)
    

    plot 1

    I also experimented a bit with opacity=1

    plot 2

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search