__init__.py 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. """Plotting module that can plot 2D and 3D functions
  2. """
  3. from sympy.utilities.decorator import doctest_depends_on
  4. @doctest_depends_on(modules=('pyglet',))
  5. def PygletPlot(*args, **kwargs):
  6. """
  7. Plot Examples
  8. =============
  9. See examples/advanced/pyglet_plotting.py for many more examples.
  10. >>> from sympy.plotting.pygletplot import PygletPlot as Plot
  11. >>> from sympy.abc import x, y, z
  12. >>> Plot(x*y**3-y*x**3)
  13. [0]: -x**3*y + x*y**3, 'mode=cartesian'
  14. >>> p = Plot()
  15. >>> p[1] = x*y
  16. >>> p[1].color = z, (0.4,0.4,0.9), (0.9,0.4,0.4)
  17. >>> p = Plot()
  18. >>> p[1] = x**2+y**2
  19. >>> p[2] = -x**2-y**2
  20. Variable Intervals
  21. ==================
  22. The basic format is [var, min, max, steps], but the
  23. syntax is flexible and arguments left out are taken
  24. from the defaults for the current coordinate mode:
  25. >>> Plot(x**2) # implies [x,-5,5,100]
  26. [0]: x**2, 'mode=cartesian'
  27. >>> Plot(x**2, [], []) # [x,-1,1,40], [y,-1,1,40]
  28. [0]: x**2, 'mode=cartesian'
  29. >>> Plot(x**2-y**2, [100], [100]) # [x,-1,1,100], [y,-1,1,100]
  30. [0]: x**2 - y**2, 'mode=cartesian'
  31. >>> Plot(x**2, [x,-13,13,100])
  32. [0]: x**2, 'mode=cartesian'
  33. >>> Plot(x**2, [-13,13]) # [x,-13,13,100]
  34. [0]: x**2, 'mode=cartesian'
  35. >>> Plot(x**2, [x,-13,13]) # [x,-13,13,100]
  36. [0]: x**2, 'mode=cartesian'
  37. >>> Plot(1*x, [], [x], mode='cylindrical')
  38. ... # [unbound_theta,0,2*Pi,40], [x,-1,1,20]
  39. [0]: x, 'mode=cartesian'
  40. Coordinate Modes
  41. ================
  42. Plot supports several curvilinear coordinate modes, and
  43. they independent for each plotted function. You can specify
  44. a coordinate mode explicitly with the 'mode' named argument,
  45. but it can be automatically determined for Cartesian or
  46. parametric plots, and therefore must only be specified for
  47. polar, cylindrical, and spherical modes.
  48. Specifically, Plot(function arguments) and Plot[n] =
  49. (function arguments) will interpret your arguments as a
  50. Cartesian plot if you provide one function and a parametric
  51. plot if you provide two or three functions. Similarly, the
  52. arguments will be interpreted as a curve if one variable is
  53. used, and a surface if two are used.
  54. Supported mode names by number of variables:
  55. 1: parametric, cartesian, polar
  56. 2: parametric, cartesian, cylindrical = polar, spherical
  57. >>> Plot(1, mode='spherical')
  58. Calculator-like Interface
  59. =========================
  60. >>> p = Plot(visible=False)
  61. >>> f = x**2
  62. >>> p[1] = f
  63. >>> p[2] = f.diff(x)
  64. >>> p[3] = f.diff(x).diff(x)
  65. >>> p
  66. [1]: x**2, 'mode=cartesian'
  67. [2]: 2*x, 'mode=cartesian'
  68. [3]: 2, 'mode=cartesian'
  69. >>> p.show()
  70. >>> p.clear()
  71. >>> p
  72. <blank plot>
  73. >>> p[1] = x**2+y**2
  74. >>> p[1].style = 'solid'
  75. >>> p[2] = -x**2-y**2
  76. >>> p[2].style = 'wireframe'
  77. >>> p[1].color = z, (0.4,0.4,0.9), (0.9,0.4,0.4)
  78. >>> p[1].style = 'both'
  79. >>> p[2].style = 'both'
  80. >>> p.close()
  81. Plot Window Keyboard Controls
  82. =============================
  83. Screen Rotation:
  84. X,Y axis Arrow Keys, A,S,D,W, Numpad 4,6,8,2
  85. Z axis Q,E, Numpad 7,9
  86. Model Rotation:
  87. Z axis Z,C, Numpad 1,3
  88. Zoom: R,F, PgUp,PgDn, Numpad +,-
  89. Reset Camera: X, Numpad 5
  90. Camera Presets:
  91. XY F1
  92. XZ F2
  93. YZ F3
  94. Perspective F4
  95. Sensitivity Modifier: SHIFT
  96. Axes Toggle:
  97. Visible F5
  98. Colors F6
  99. Close Window: ESCAPE
  100. =============================
  101. """
  102. from sympy.plotting.pygletplot.plot import PygletPlot
  103. return PygletPlot(*args, **kwargs)