Update to VPython 7.1.4. Thanks to Matt Craig for building the installers.
You can get the latest version this way: pip install vpython --upgrade
Or if using Anaconda, conda update -c vpython vpython
1) A long-standing error has been fixed. You can now say “ev = scene.pause()” or “ev = scene.waitfor(....)” and “ev” contains the expected information (e.g. ev.event may have the value “mousedown”).
2) Keyboard events now work in VPython 7 when not using a Jupyter notebook. It is hoped that keyboard events will work soon in a Jupyter notebook.
3) In label objects and in graph titles (title, xtitle, ytitle) you can now use HTML styled text. You can get the latest version this way:
pip install vpython --upgrade
Or if using Anaconda, conda update -c vpython vpython
In the documentation for the label object,
http://www.glowscript.org/docs/VPythonDocs/label.html
is this description of label text, which also applies to graph titles:
You can give a number or numerical expression; it will be
converted to a string.You can include the HTML styles for italic (<i> or
<em>), bold (<b> or <strong>), superscript (<sup>), or
subscript (<sub>). For example, the string
'The <b>mass
<i>M</i></b><sub>sys</sub> =
10<sup>3</sup> kg.
displays as
'The mass Msys = 103 kg.
Multiple lines can be displayed by inserting line breaks (\n), as
in "Three\nlines\nof text" and you can insert <br> or
<br/> instead of \n. You can also create multiple lines by using triple
quotes There is a restriction
on graph titles, in that you cannot insert line breaks in xtitles or ytitles.
By default a graph title is left-adjusted above the graph, as has been true in the past. Now you can set title_align to "center" or "right" as well as "left". When you specify "center" the title is centered above the grid.
In addition to this new graph titling capability, there are two other significant improvements. The title (which is at the top of a graph) now is fully bound to the graph. In particular, it stays with the graph when the graph is aligned "right". Secondly, I discovered that the flot graphing machinery was replotting all the titles every time you added data to the graph, which surely affected graph performance. This is no longer the case.
Technical note: A graph object is now a 2D canvas in which the graphing grid and data are confined to a subarea of the canvas, with the title, xtitle, and ytitle outside that subarea. In that way, changes to the graph do not affect the titles, which do not have to be replotted.
Bruce
gd = vp.graph(width=600, height=150)
gd.title+="<p style='color:DodgerBlue;'>theta(t)</p>"
xtitle='<i>t</i>', ytitle='<i>theta(t)</i>', #ϑ ϑ #φ φ φ
<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script> <script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
Tables to organize content, e.g. having two graphs side by side like subplots ...
text The texYou can give a number or numerical expression; it will be converted to a string.You can include the HTML styles for italic (<i> or <em>), bold (<b> or <strong>), superscript (<sup>), or subscript (<sub>). For example, the string
'The <b>mass <i>M</i></b><sub>sys</sub> = 10<sup>3</sup> kg.
displays as
'The mass Msys = 103 kg.
Multiple lines can be displayed by inserting line breaks (\n), as in "Three\nlines\nof text" and you can insert <br> or <br/> instead of \n. You can also create multiple lines by using triple quotes:
L = label()
L.text = """The quick brown fox
jumps over the lazy dog."""
HTML: You can include html directives such as this: <b>This is bold.</b>
You can append more text to the title or caption (you can also use this form initially, as the caption and title start out as zero-length strings):
scene.append_to_title("Now <b>click the box</b>.")
scene.append_to_caption("See the <i>effect?</i>")
You can align a graph to the left or right of another graph or a canvas:
align Set to "left" (graph forced to left side of window), "right" (graph forced to right side of window), or "none" (the default alignment). If you want to place a graph to the right of a canvas, set the canvas align attribute to the string "left" and the graph align attribute to the string "right". If the window is too narrow, the object that is on the right will be displayed below the other object. If you want to place a graph to the right of the canvas but keep the canvas caption underneath the canvas, create the graph first with align set to "right" and activate the graph by plotting something in it, then create the canvas without specifying its value of align. Another option is to specify align='left' for all canvases and graphs, in which case they will abut each other.