Re: Draw math formulas with ggplotd
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: 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. Generate data from those formulas (I like to do this with something like iota(0, 10, 0.05).map!(x => sqrt(x) / (1 + sin(x)^^2)) and then plot that. 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. Yes I want adding the formula onto the plot. Thanks.
Re: Draw math formulas with ggplotd
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: On Saturday, 17 September 2016 at 11:45:07 UTC, Edwin van Leeuwen wrote: But I assumed he meant adding the formula onto the plot. Hah, yes, I should have read the question better. Rereading the question I am actually not sure which of us interpreted the question correctly :) 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. 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.
Re: Draw math formulas with ggplotd
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: But I assumed he meant adding the formula onto the plot. Hah, yes, I should have read the question better. Rereading the question I am actually not sure which of us interpreted the question correctly :) 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.
Re: Draw math formulas with ggplotd
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: 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. Generate data from those formulas (I like to do this with something like iota(0, 10, 0.05).map!(x => sqrt(x) / (1 + sin(x)^^2)) and then plot that. 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. 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).
Re: Draw math formulas with ggplotd
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: 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. Generate data from those formulas (I like to do this with something like iota(0, 10, 0.05).map!(x => sqrt(x) / (1 + sin(x)^^2)) and then plot that. 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.
Re: Draw math formulas with ggplotd
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. Generate data from those formulas (I like to do this with something like iota(0, 10, 0.05).map!(x => sqrt(x) / (1 + sin(x)^^2)) and then plot that. If you want to use actual latex you would need a program to convert it to code. Mathematica can convert latex to C, which would then be easy to port to D. Either way, if I remember correctly there is a simple line plot example in ggplotd's README.md
Re: Draw math formulas with ggplotd
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: 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. When I say you can't I meant that this is not explicitly supported by ggplotd.
Re: Draw math formulas with ggplotd
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.
Draw math formulas with 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.