1

This question sounds more difficult than it actually is.

I wonder, how I can plot a mathematical function with julia?

Until now I used Gadfly to plot. I now want to play around with a function (constrained optimization on convex functions) but I can't find a way to define it.

E.g. I want to do:

plot( layer(y=x^2+1 …), layer(y=(x-4)+(x+3),…),…)

I know that there is a optimization package, however I want to understand and therefore do it myself. For that I just want to be able to draw any function (also multivariate functions).

So, how can I do this? Is this even possible in Gadfly or do I need to use another plotting library?

Any help is greatly appreciated.

ruffy
  • 291
  • 1
  • 3
  • 13

2 Answers2

3

See plotting functions and expressions in the Gadfly manual.

For your example, something like plot([x->x^2+1, x->(x-4)+(x+3)], -2, 2) should do the trick using anonymous functions.

example plot

It's not currently possible to do this with multivariate functions as far as I'm aware.

mbauman
  • 30,958
  • 4
  • 88
  • 123
  • But seriously, this "documentation" is so messy. I mean, from "plot(fs::Array, a, b, elements::Element...)" how can I abstract that "a" means x.minValue and "b" x.maxValue? How can I adjust the y-bounds and what is an "Element" type? It's not specified anywhere on Gadflys page. Is there a propper documentation, like any framework offers? I know that your are not responsible for that, but this is so annoying. – ruffy Jan 28 '15 at 08:24
1

You may also be interested in the Interact.jl package.

tholy
  • 11,882
  • 1
  • 29
  • 42