## digitalmars.D.learn - Draw math formulas with ggplotd

- brocolis (4/4) Sep 16 2016 How do I draw math formulas programmatically? I want to do on
- Edwin van Leeuwen (7/11) Sep 17 2016 You can't at the moment. Parsing latex equations is not a trivial
- Edwin van Leeuwen (4/12) Sep 17 2016 When I say you can't I meant that this is not explicitly
- John Colvin (9/13) Sep 17 2016 Generate data from those formulas (I like to do this with
- Edwin van Leeuwen (6/15) Sep 17 2016 For this part ggplotd does have a helper function:
- John Colvin (7/24) Sep 17 2016 Hah, yes, I should have read the question better. Do you support
- Edwin van Leeuwen (6/14) Sep 17 2016 Rereading the question I am actually not sure which of us
- John Colvin (7/23) Sep 17 2016 You just get back an alpha mask as an array of arrays, so it
- brocolis (3/20) Sep 18 2016 Yes I want adding the formula onto the plot. Thanks.

How do I draw math formulas programmatically? I want to do on screen what latex does on .pdf. And I want to draw a math formula in the image generated with ggplotd.

Sep 16 2016

On Saturday, 17 September 2016 at 02:41:15 UTC, brocolis wrote:How do I draw math formulas programmatically? I want to do on screen what latex does on .pdf. And I want to draw a math formula in the image generated with ggplotd.You can't at the moment. Parsing latex equations is not a trivial task. One possible approach would be to convert part of the equations (greek alphabet etc.) to utf and use geomLabel to "simulate" sub/super script. One caveat with this is that I am not sure how well cairo(d) supports utf.

Sep 17 2016

On Saturday, 17 September 2016 at 09:56:09 UTC, Edwin van Leeuwen wrote:On Saturday, 17 September 2016 at 02:41:15 UTC, brocolis wrote:When I say you can't I meant that this is not explicitly supported by ggplotd.How do I draw math formulas programmatically? I want to do on screen what latex does on .pdf. And I want to draw a math formula in the image generated with ggplotd.You can't at the moment. Parsing latex equations is not a trivial task.

Sep 17 2016

On Saturday, 17 September 2016 at 02:41:15 UTC, brocolis wrote:

Sep 17 2016

On Saturday, 17 September 2016 at 11:22:04 UTC, John Colvin wrote:On Saturday, 17 September 2016 at 02:41:15 UTC, brocolis wrote:For this part ggplotd does have a helper function: http://blackedder.github.io/ggplotd/ggplotd/stat.html#statFunction auto gg = statFunction(x => sqrt(x) / (1 + sin(x)^^2), 0.0, 10).geomLine().putIn(GGPlotD()); But I assumed he meant adding the formula onto the plot.

Sep 17 2016

On Saturday, 17 September 2016 at 11:45:07 UTC, Edwin van Leeuwen wrote:On Saturday, 17 September 2016 at 11:22:04 UTC, John Colvin wrote:Hah, yes, I should have read the question better. Do you support embedding outside images? When I wanted nice mathematical notation generated quickly in D I have used pyd to call matplotlib's builtin math rendering (much quicker than a full latex roundtrip).On Saturday, 17 September 2016 at 02:41:15 UTC, brocolis wrote:For this part ggplotd does have a helper function: http://blackedder.github.io/ggplotd/ggplotd/stat.html#statFunction auto gg = statFunction(x => sqrt(x) / (1 + sin(x)^^2), 0.0, 10).geomLine().putIn(GGPlotD()); But I assumed he meant adding the formula onto the plot.

Sep 17 2016

On Saturday, 17 September 2016 at 11:57:17 UTC, John Colvin wrote:On Saturday, 17 September 2016 at 11:45:07 UTC, Edwin van Leeuwen wrote:Rereading the question I am actually not sure which of us interpreted the question correctly :)But I assumed he meant adding the formula onto the plot.Hah, yes, I should have read the question better.Do you support embedding outside images? When I wanted nice mathematical notation generated quickly in D I have used pyd to call matplotlib's builtin math rendering (much quicker than a full latex roundtrip).You can draw onto any cairo surface, so this should be possible. You'd just need to figure out how to cast/convert a matplotlib image to a cairo image.

Sep 17 2016

On Saturday, 17 September 2016 at 12:09:04 UTC, Edwin van Leeuwen wrote:On Saturday, 17 September 2016 at 11:57:17 UTC, John Colvin wrote:You just get back an alpha mask as an array of arrays, so it should be straightforward from there. What would be useful would be integration with ggplotd so it could be placed appropriately. Would be even better if e.g. the user could specify a function to render text and ggplotd would call it with tick label strings etc.On Saturday, 17 September 2016 at 11:45:07 UTC, Edwin van Leeuwen wrote:Rereading the question I am actually not sure which of us interpreted the question correctly :)But I assumed he meant adding the formula onto the plot.Hah, yes, I should have read the question better.Do you support embedding outside images? When I wanted nice mathematical notation generated quickly in D I have used pyd to call matplotlib's builtin math rendering (much quicker than a full latex roundtrip).You can draw onto any cairo surface, so this should be possible. You'd just need to figure out how to cast/convert a matplotlib image to a cairo image.

Sep 17 2016

On Saturday, 17 September 2016 at 11:45:07 UTC, Edwin van Leeuwen wrote:On Saturday, 17 September 2016 at 11:22:04 UTC, John Colvin wrote:Yes I want adding the formula onto the plot. Thanks.On Saturday, 17 September 2016 at 02:41:15 UTC, brocolis wrote:For this part ggplotd does have a helper function: http://blackedder.github.io/ggplotd/ggplotd/stat.html#statFunction auto gg = statFunction(x => sqrt(x) / (1 + sin(x)^^2), 0.0, 10).geomLine().putIn(GGPlotD()); But I assumed he meant adding the formula onto the plot.

Sep 18 2016