Advertisement
Guest User

Untitled

a guest
Jul 21st, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1. size(12cm,12cm);
  2.  
  3. import graph;
  4. import palette;
  5.  
  6. int n=256;
  7. real ninv=2pi/n;
  8. real[][] v=new real[n][n];
  9.  
  10. for(int i=0; i < n; ++i)
  11. for(int j=0; j < n; ++j)
  12. v[i][j]=sin(i*ninv)*cos(j*ninv);
  13.  
  14. pen[] Palette=BWRainbow();
  15.  
  16. picture bar;
  17.  
  18. bounds range=image(v,(0,0),(1,1),Palette);
  19. palette(bar,"$A$",range,(0,0),(0.5cm,8cm),Right,Palette,
  20. PaletteTicks("$%+#.1f$"));
  21. add(bar.fit(),point(E),30E);
  22.  
  23. documentclass{article}
  24. usepackage[pdftex]{graphicx}
  25. usepackage[inline]{asymptote}
  26. begin{document}
  27.  
  28. begin{figure}[!h]
  29. begin{asy}
  30. import graph;
  31. import contour;
  32. import palette;
  33. defaultpen(fontsize(10pt));
  34. size(14cm,8cm,IgnoreAspect);
  35. // Load my height function:
  36. file Z=input("dataZ.dat").line();
  37. real[][] z= Z;
  38. z = transpose(z);
  39. pair xyMin=(1,74);
  40. pair xyMax=(3,86);
  41. // original function
  42. real f(real x, real y) {return -2.051^3*1000/(2*3.1415*(2.99*10^2)^2)/(x^2*Cos(y)^2);}
  43. int N=200;
  44. int Levels=16;
  45. defaultpen(1bp);
  46. bounds range=bounds(-3,-0.10);
  47. real[] Cvals=uniform(range.min,range.max,Levels);
  48. // Original
  49. // guide[][] g=contour(f,xyMin,xyMax,Cvals,100,operator --);
  50. // Modified
  51. guide[][] g=contour(z,xyMin,xyMax,Cvals,100,operator --);
  52. pen[] Palette=Gradient(Levels,rgb(0.3,0.06,0.5),rgb(0.9,0.9,0.85));
  53. for(int i=0;i<g.length-1;++i){
  54. filldraw(g[i][0]--xyMin--(xyMax.x,xyMin.y)--xyMax--cycle,Palette[i],darkblue+0.2bp);
  55. }
  56. xaxis("$x$",BottomTop,1,3,darkblue+0.5bp,RightTicks(Step=0.2,step=0.05),above=true);
  57. yaxis("$y$",LeftRight,74,86,darkblue+0.5bp,LeftTicks(Step=2,step=0.5),above=true);
  58. palette("$f(x,y)$",range,point(SE)+(0.2,0),point(NE)+(0.3,0),Right,Palette,
  59. PaletteTicks("$%+#0.1f$",N=Levels,olive+0.1bp));
  60. end{asy}
  61. caption{A contour plot.}
  62. end{figure}
  63.  
  64. end{document}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement