You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I offer one piece of the puzzle, namely a function that turns a string
containing latex formula
into a `pict`:
https://github.com/soegaard/latex-pict
It relies on `racket-poppler` which contains bindings for Poppler (a
library for
drawing pdfs using Cairo - which is the graphics engine Racket uses).
Note that `plot` offers `plot/dc` which allows you to draw the plot on a
drawing context `dc`.
This makes it possible to combine picts and plots. For approximate
placement of labels,
I think this is enough.
If you need to place labels using plot coordinates, then some work needs to
be done:
a function to convert dc coordinates to plot coordinates (and vice versa)
needs to be written.
The tricky bit is that plot (when given a width and height) uses some of
the same
for margins and labels. How much space is determined here(ish):
https://github.com/racket/plot/blob/9823d1ab9ff9144a8a3114afc0af6a69a0fbc4b7/plot-lib/plot/private/plot2d/plot-area.rkt#L533
I think, this needs to be added to `plot` itself (correct me if I am wrong).
/Jens Axel
As for the implementation, the #label argument to the plot functions can be extended to accept a pict argument in addition to a string. There is already a point-pict function which can display pict objects on a plot.
This way, the latex-pict package suggested above could be used to render the labels.
The plot package has been extended to support pictures for legend entries, names for axes and plot titles. This allows formatting these elements using pretty much anything that can be rendered. In particular it would allow the use of latex-pict to render LaTeX formulas.
As I noted previously, you can also use Unicode for the strings, which allows some limited mathematical notation. E.g. you can use x² directly.
This functionality will be available in the next Racket version (7.9).
Activity
soegaard commentedon Feb 15, 2020
alex-hhh commentedon Jun 25, 2020
You can use unicode characters for some math notation. this is not as flexible as using TeX, but can be useful in a lot of cases:
Produces:
alex-hhh commentedon Jun 25, 2020
As for the implementation, the
#labelargument to the plot functions can be extended to accept apictargument in addition to a string. There is already a point-pict function which can displaypictobjects on a plot.This way, the latex-pict package suggested above could be used to render the labels.
Allow pict's to be used as legend entries in plots
Allow pict's to be used as legend entries in plots
Allow pictures to be used as legend entries in plots
Allow picts to be used as legend entries in plots (#64)
Allow pictures to be used as title and axis labels in plots
Allow pictures to be used as title and axis labels in plots (#65)
alex-hhh commentedon Aug 28, 2020
The plot package has been extended to support pictures for legend entries, names for axes and plot titles. This allows formatting these elements using pretty much anything that can be rendered. In particular it would allow the use of
latex-pictto render LaTeX formulas.As I noted previously, you can also use Unicode for the strings, which allows some limited mathematical notation. E.g. you can use
x²directly.This functionality will be available in the next Racket version (7.9).