HTML-styled text in label and graph titles; improvements to graph

20 views
Skip to first unread message

Bruce Sherwood

unread,
Nov 1, 2017, 5:26:20 PM11/1/17
to Glowscript Users
In label objects and in graph titles (title, xtitle, ytitle) you can now use HTML styled text. In the documentation for the label object,


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.

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 description: 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.

None of this is in VPython 7 yet but will be soon.

Bruce

Bruce Sherwood

unread,
Nov 1, 2017, 9:57:14 PM11/1/17
to Glowscript Users
I forgot to mention that 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.

Bruce

Bennett Weaver

unread,
Nov 3, 2017, 5:22:55 PM11/3/17
to glowscri...@googlegroups.com
Thanks for the update and the additional capabilities.

Reply all
Reply to author
Forward
0 new messages