0
$\begingroup$

A user has this nice graph of f(x) on his profile and I want to learn how to do it in matlab or Gnu octave.

enter image description here

f(x) = -(x*x*x +x + 1)
(0,0) = center
color(x,y) = arctan2(x, f(x))
lum(x,y) = sin(hypot(x, f(x))/alpha)

But when I try in matlab I fail:

>> y= -(x.*x.*x+x+1)

>> x = linspace(0,2*pi,100);

>> plot(x,y)

The matlab code does not make a plot that resembles the nice visual graph. I understand that I must also accomplish the effects, but can you help me on the way? Is there a program that is more or less suitable to make a plot like the above?

$\endgroup$
  • 3
    $\begingroup$ Why don't you ask the user from whose site you copied the picture? $\endgroup$ – Wolfgang Bangerth Jun 3 '16 at 4:01
  • 1
    $\begingroup$ I may misunderstood but your three MATLAB code lines are completely off topic. You need at least a contour command to reproduce the isocontour lines you have displayed, not a plot command. Only then you can focus on the colormap used for obtaining such a graph but it seems to have been postprocessed with another software. $\endgroup$ – Coriolis Jun 3 '16 at 7:43
4
$\begingroup$

Using Python and mpmath:

import matplotlib
import mpmath
f = lambda z: z**3-z+1
mpmath.cplot(f, points=100000)

Easy peasy.... See here for the documentation on mpmath.cplot

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.