ASKSAGE: Sage Q&A Forum - Individual question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Fri, 03 Apr 2020 13:05:31 -0500Interactive plotshttps://ask.sagemath.org/question/48984/interactive-plots/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
Tue, 10 Dec 2019 02:01:04 -0600https://ask.sagemath.org/question/48984/interactive-plots/Answer by eric_g for <p>Dear all,</p>
<p>I am new to Python and sagemath as well, I am however a skilled coder in other languages such as C/C++, Matlab, etc.</p>
<p>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.</p>
<p>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.</p>
<p>Best regards,
Mike</p>
https://ask.sagemath.org/question/48984/interactive-plots/?answer=48990#post-id-48990Welcome to ask.sagemath!
Actually there is some interactivity for 3D plots in SageMath, in particular in the Jupyter notebook, with the [three.js](https://doc.sagemath.org/html/en/reference/plot3d/threejs.html) 3d viewer, which shall become the default viewer in the next stable release of SageMath (9.0): the interactivity is (cf. the [reference manual](https://doc.sagemath.org/html/en/reference/plot3d/threejs.html))
- 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](https://nbviewer.jupyter.org/github/sagemanifolds/SageManifolds/blob/master/Notebooks/SM_anti_de_Sitter.ipynb) 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!Tue, 10 Dec 2019 15:04:04 -0600https://ask.sagemath.org/question/48984/interactive-plots/?answer=48990#post-id-48990Comment by Mika007 for <p>Welcome to ask.sagemath!</p>
<p>Actually there is some interactivity for 3D plots in SageMath, in particular in the Jupyter notebook, with the <a href="https://doc.sagemath.org/html/en/reference/plot3d/threejs.html">three.js</a> 3d viewer, which shall become the default viewer in the next stable release of SageMath (9.0): the interactivity is (cf. the <a href="https://doc.sagemath.org/html/en/reference/plot3d/threejs.html">reference manual</a>)</p>
<ul>
<li>Zooming in or out with the mouse wheel or pinching on a touch pad</li>
<li>Rotation by clicking and dragging with the mouse or swiping on a touch pad</li>
<li>Panning by right-clicking and dragging with the mouse or swiping with three fingers on a touch pad</li>
</ul>
<p>See e.g. the 3d plots in <a href="https://nbviewer.jupyter.org/github/sagemanifolds/SageManifolds/blob/master/Notebooks/SM_anti_de_Sitter.ipynb">this notebook</a> to play with some examples.</p>
<p>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!</p>
https://ask.sagemath.org/question/48984/interactive-plots/?comment=50500#post-id-50500Thank you for your answer. I am sorry to answer so late, I wes not notified (for any reason ?) by the site.Fri, 03 Apr 2020 13:05:31 -0500https://ask.sagemath.org/question/48984/interactive-plots/?comment=50500#post-id-50500Answer by Emmanuel Charpentier for <p>Dear all,</p>
<p>I am new to Python and sagemath as well, I am however a skilled coder in other languages such as C/C++, Matlab, etc.</p>
<p>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.</p>
<p>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.</p>
<p>Best regards,
Mike</p>
https://ask.sagemath.org/question/48984/interactive-plots/?answer=48991#post-id-48991To 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.Tue, 10 Dec 2019 16:01:45 -0600https://ask.sagemath.org/question/48984/interactive-plots/?answer=48991#post-id-48991Comment by Mika007 for <p>To complement Eric's answer:</p>
<p>Three-dimensional graphics have a built-in interactivity, aimed at exploring a given (fixed) 3D figure.</p>
<p>The <em>programmable</em> interacivity of interact widgets isn't limited to 2D plots. It allows to vary the parameters of a computation (<em>a priori</em> <strong>any</strong> 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.</p>
<p>The fact that most of its examples are 2D graphics-oriented is not a built-in limitation of the widgets' interactivity.</p>
https://ask.sagemath.org/question/48984/interactive-plots/?comment=50499#post-id-50499Thank you for your answer. I am sorry to answer so late, I wes not notified (for any reason ?) by the site.Fri, 03 Apr 2020 13:05:26 -0500https://ask.sagemath.org/question/48984/interactive-plots/?comment=50499#post-id-50499