How to draw cobweb in gnuplot

233 Views Asked by At

I want to make cobweb plot in c with gnuplot but the curve is not plotted well.

Here are the code.

#include <stdio.h>

int main(void){

int i, n=100; // Time

double r=3.80; // Initial condition of maximum rate of increase
double x[102]; // Increase rate
x[0]=0.7; // Initial condition

/*--- making data ---*/
for(i=0;i<=n;i++){
        x[i+1]=r*(1-x[i])*x[i];
        printf("%lf\t%lf\n",x[i],x[i+1]);
}

return 0;

}

plotted curve

Then, plot "chaos2.plt" with line in gnuplot.

I'd like to plot a graph from coordinates, but it is plotted like this. How do I fix the code ?

expected graph

0

There are 0 best solutions below