Closed cjwomack closed 7 months ago
Mentioned status in https://github.com/jupyter-xeus/xeus-octave/issues/13
Sorry.
Looks like it is easy to add a title using Plotly JSON, but hard to grab title of a plot from Octave - most likely iterating over children of graphics-object ... You can easily add the figure text as a title but not useful eg Figure 1 https://github.com/jupyter-xeus/xeus-octave/blob/main/src/tk_plotly.cpp to be placed after line 73 re useless figure title code...
std::string figureTitle = figureProperties.get_title(); // gives useless Figure X
plot["layout"]["title"]["text"] = "<b>" + figureTitle + "</b>"; // html for bold
plot["layout"]["title"]["x"] = 0.5; // Center the text horizontally
plot["layout"]["title"]["y"] = 0.875; // 1 is top of graph, 0 is bottom of graph
plot["layout"]["title"]["font"]["size"] = 18; //font size
You can get the title from the axis object.
However, it gets tricky when there are subplots in a figure these titles get mapped to annotations
Description
I was attempting to add a title eg [ title("Intensity of a doughnut-shaped laser beam")] to a plot using graphics_toolkit("plotly") . This doesn't work unless you use the notebook mode for graphics_toolkit.
What I Did
I was attempting to add a title to a plot using graphics_toolkit("plotly") . This doesn't work unless you use the notebook mode for graphics_toolkit.
Doesn't look like this is currently implemented when looking at https://github.com/jupyter-xeus/xeus-octave/blob/main/src/tk_plotly.cpp
Also looked at trying to use the text() function but didn't work in conjunction with plot. A rough solution is to use disp() with \n for a new line and spaces to roughly center it.
Anyway, it does say experimental re plotly in your binder book so no great issue.