Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- size(12cm,12cm);
- import graph;
- import palette;
- int n=256;
- real ninv=2pi/n;
- real[][] v=new real[n][n];
- for(int i=0; i < n; ++i)
- for(int j=0; j < n; ++j)
- v[i][j]=sin(i*ninv)*cos(j*ninv);
- pen[] Palette=BWRainbow();
- picture bar;
- bounds range=image(v,(0,0),(1,1),Palette);
- palette(bar,"$A$",range,(0,0),(0.5cm,8cm),Right,Palette,
- PaletteTicks("$%+#.1f$"));
- add(bar.fit(),point(E),30E);
- documentclass{article}
- usepackage[pdftex]{graphicx}
- usepackage[inline]{asymptote}
- begin{document}
- begin{figure}[!h]
- begin{asy}
- import graph;
- import contour;
- import palette;
- defaultpen(fontsize(10pt));
- size(14cm,8cm,IgnoreAspect);
- // Load my height function:
- file Z=input("dataZ.dat").line();
- real[][] z= Z;
- z = transpose(z);
- pair xyMin=(1,74);
- pair xyMax=(3,86);
- // original function
- real f(real x, real y) {return -2.051^3*1000/(2*3.1415*(2.99*10^2)^2)/(x^2*Cos(y)^2);}
- int N=200;
- int Levels=16;
- defaultpen(1bp);
- bounds range=bounds(-3,-0.10);
- real[] Cvals=uniform(range.min,range.max,Levels);
- // Original
- // guide[][] g=contour(f,xyMin,xyMax,Cvals,100,operator --);
- // Modified
- guide[][] g=contour(z,xyMin,xyMax,Cvals,100,operator --);
- pen[] Palette=Gradient(Levels,rgb(0.3,0.06,0.5),rgb(0.9,0.9,0.85));
- for(int i=0;i<g.length-1;++i){
- filldraw(g[i][0]--xyMin--(xyMax.x,xyMin.y)--xyMax--cycle,Palette[i],darkblue+0.2bp);
- }
- xaxis("$x$",BottomTop,1,3,darkblue+0.5bp,RightTicks(Step=0.2,step=0.05),above=true);
- yaxis("$y$",LeftRight,74,86,darkblue+0.5bp,LeftTicks(Step=2,step=0.5),above=true);
- palette("$f(x,y)$",range,point(SE)+(0.2,0),point(NE)+(0.3,0),Right,Palette,
- PaletteTicks("$%+#0.1f$",N=Levels,olive+0.1bp));
- end{asy}
- caption{A contour plot.}
- end{figure}
- end{document}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement