Option to have title and legend within main plot #1937
Hvass-Labs
started this conversation in
Ideas
Replies: 1 comment 1 reply
-
The cause is that Plot is not a layout engine; hence, we use the browser's capabilities with HTML to allow rich text where necessary (including italics etc, which are quite hard to do with SVG). One trick that I can give you is that it is completely legitimate to put SVG inside SVG, so you don't really need to create "fake marks" for adding a svg title, instead create a template:
You can even create this as a function of plot options, then extract the title from it, etc.
|
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Please explain why you have chosen to have the title and legend as separate HTML and SVG elements instead of being a part of the main plot?
I am not trying to challenge your design as I know you are masters of that. But this particular design choice is giving me several practical problems:
First is the difficulty of saving a single SVG file from the plot, as discussed in Save / export stand-alone SVG-file with legend #1936, whereas it is quite easy to save if the plot is a single SVG element.
The plot title renders as an
<h2>
element, but I am using Bootstrap styling where I normally use<h4>
headers, so the plot-title is much larger than the other headers in my page.I can add the title manually as a text-mark e.g.:
Plot.text(["Manual Title"], {frameAnchor: "top", textAnchor: "middle", dy: -20, fontSize: 14})
, but then I also need to increase the top-margin, and then the legend gets moved further away from the plot which looks bad.Alignment with surrounding HTML elements can also be challenging.
May I suggest that you make an option whether the title and legend are as now, or
they could be included inside the main plot, much like old-school Matplotlib plots.
Alternatively you could provide a legend-mark so I can insert it manually using e.g.
Plot.legend()
similar to the hack for adding the title manually withPlot.text()
.Thanks!
Beta Was this translation helpful? Give feedback.
All reactions