Ask Your Question
1

Interactive plots

asked 2019-12-10 09:01:04 +0100

Mika007 gravatar image

Dear all,

I am new to Python and sagemath as well, I am however a skilled coder in other languages such as C/C++, Matlab, etc.

I work in a university and we think about switching from matlab to python, and I have found in sagemath a very intersting use of python for scientific computing. I explore the possibilities of python for that purpose. Something that misses in the tries I made is the mouse interactivity with plots (such as zoom for 2d plot or rotation for 3d plot). I used basic Matplotlib. I have read that it is possible with python itself and what limits mouse interactivity seems to come from the web-page orientation of jupyter. I have seen somewhere that in Jupyter, the following : %matplotlib notebook may enable the interactivity. However it does not seem to work in Sagemath.

So I have questions : I want to have interactivity. Is it possible with Matplotlib in Sagemath or is planed for a future version ? Else : may I use another library than Matplotlib, and which one may I use ? My typical needs are large amount of points plotting (experimental data), and 3d plotting.

Best regards, Mike

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2019-12-10 23:01:45 +0100

Emmanuel Charpentier gravatar image

To complement Eric's answer:

Three-dimensional graphics have a built-in interactivity, aimed at exploring a given (fixed) 3D figure.

The programmable interacivity of interact widgets isn't limited to 2D plots. It allows to vary the parameters of a computation (a priori any computation). For example, you may envision to control the scale, range and precision of some statistical estimation or simulation, as well as the visual parameters of its representation.

The fact that most of its examples are 2D graphics-oriented is not a built-in limitation of the widgets' interactivity.

edit flag offensive delete link more

Comments

Thank you for your answer. I am sorry to answer so late, I wes not notified (for any reason ?) by the site.

Mika007 gravatar imageMika007 ( 2020-04-03 20:05:26 +0100 )edit
1

answered 2019-12-10 22:04:04 +0100

eric_g gravatar image

Welcome to ask.sagemath!

Actually there is some interactivity for 3D plots in SageMath, in particular in the Jupyter notebook, with the three.js 3d viewer, which shall become the default viewer in the next stable release of SageMath (9.0): the interactivity is (cf. the reference manual)

  • Zooming in or out with the mouse wheel or pinching on a touch pad
  • Rotation by clicking and dragging with the mouse or swiping on a touch pad
  • Panning by right-clicking and dragging with the mouse or swiping with three fingers on a touch pad

See e.g. the 3d plots in this notebook to play with some examples.

On the other side, there is no interactivity on 2D plots (except for those explicitly constructed with the interact widget). As a skilled coder, if you would like to implement such a functionality in SageMath, you are most welcome!

edit flag offensive delete link more

Comments

Thank you for your answer. I am sorry to answer so late, I wes not notified (for any reason ?) by the site.

Mika007 gravatar imageMika007 ( 2020-04-03 20:05:31 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2019-12-10 09:01:04 +0100

Seen: 1,236 times

Last updated: Dec 10 '19