vispy 0.14.0__cp311-cp311-macosx_11_0_arm64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of vispy might be problematic. Click here for more details.

Files changed (519) hide show
  1. vispy/__init__.py +33 -0
  2. vispy/app/__init__.py +15 -0
  3. vispy/app/_default_app.py +76 -0
  4. vispy/app/_detect_eventloop.py +148 -0
  5. vispy/app/application.py +263 -0
  6. vispy/app/backends/__init__.py +52 -0
  7. vispy/app/backends/_egl.py +264 -0
  8. vispy/app/backends/_glfw.py +513 -0
  9. vispy/app/backends/_jupyter_rfb.py +278 -0
  10. vispy/app/backends/_offscreen_util.py +121 -0
  11. vispy/app/backends/_osmesa.py +235 -0
  12. vispy/app/backends/_pyglet.py +451 -0
  13. vispy/app/backends/_pyqt4.py +36 -0
  14. vispy/app/backends/_pyqt5.py +36 -0
  15. vispy/app/backends/_pyqt6.py +40 -0
  16. vispy/app/backends/_pyside.py +37 -0
  17. vispy/app/backends/_pyside2.py +52 -0
  18. vispy/app/backends/_pyside6.py +53 -0
  19. vispy/app/backends/_qt.py +968 -0
  20. vispy/app/backends/_sdl2.py +444 -0
  21. vispy/app/backends/_template.py +244 -0
  22. vispy/app/backends/_test.py +8 -0
  23. vispy/app/backends/_tk.py +800 -0
  24. vispy/app/backends/_wx.py +476 -0
  25. vispy/app/backends/tests/__init__.py +0 -0
  26. vispy/app/backends/tests/test_offscreen_util.py +52 -0
  27. vispy/app/backends/tests/test_rfb.py +77 -0
  28. vispy/app/base.py +294 -0
  29. vispy/app/canvas.py +828 -0
  30. vispy/app/qt.py +92 -0
  31. vispy/app/tests/__init__.py +0 -0
  32. vispy/app/tests/qt-designer.ui +58 -0
  33. vispy/app/tests/test_app.py +442 -0
  34. vispy/app/tests/test_backends.py +164 -0
  35. vispy/app/tests/test_canvas.py +122 -0
  36. vispy/app/tests/test_context.py +92 -0
  37. vispy/app/tests/test_qt.py +47 -0
  38. vispy/app/tests/test_simultaneous.py +134 -0
  39. vispy/app/timer.py +174 -0
  40. vispy/color/__init__.py +17 -0
  41. vispy/color/_color_dict.py +193 -0
  42. vispy/color/color_array.py +447 -0
  43. vispy/color/color_space.py +181 -0
  44. vispy/color/colormap.py +1134 -0
  45. vispy/color/tests/__init__.py +0 -0
  46. vispy/color/tests/test_color.py +352 -0
  47. vispy/conftest.py +12 -0
  48. vispy/ext/__init__.py +0 -0
  49. vispy/ext/cocoapy.py +1542 -0
  50. vispy/ext/cubehelix.py +138 -0
  51. vispy/ext/egl.py +375 -0
  52. vispy/ext/fontconfig.py +118 -0
  53. vispy/ext/gdi32plus.py +206 -0
  54. vispy/ext/osmesa.py +105 -0
  55. vispy/geometry/__init__.py +23 -0
  56. vispy/geometry/_triangulation_debugger.py +171 -0
  57. vispy/geometry/calculations.py +134 -0
  58. vispy/geometry/curves.py +399 -0
  59. vispy/geometry/generation.py +643 -0
  60. vispy/geometry/isocurve.py +175 -0
  61. vispy/geometry/isosurface.py +465 -0
  62. vispy/geometry/meshdata.py +698 -0
  63. vispy/geometry/normals.py +78 -0
  64. vispy/geometry/parametric.py +56 -0
  65. vispy/geometry/polygon.py +137 -0
  66. vispy/geometry/rect.py +210 -0
  67. vispy/geometry/tests/__init__.py +0 -0
  68. vispy/geometry/tests/test_calculations.py +23 -0
  69. vispy/geometry/tests/test_generation.py +56 -0
  70. vispy/geometry/tests/test_meshdata.py +106 -0
  71. vispy/geometry/tests/test_triangulation.py +506 -0
  72. vispy/geometry/torusknot.py +142 -0
  73. vispy/geometry/triangulation.py +876 -0
  74. vispy/gloo/__init__.py +56 -0
  75. vispy/gloo/buffer.py +505 -0
  76. vispy/gloo/context.py +272 -0
  77. vispy/gloo/framebuffer.py +257 -0
  78. vispy/gloo/gl/__init__.py +234 -0
  79. vispy/gloo/gl/_constants.py +332 -0
  80. vispy/gloo/gl/_es2.py +986 -0
  81. vispy/gloo/gl/_gl2.py +1365 -0
  82. vispy/gloo/gl/_proxy.py +499 -0
  83. vispy/gloo/gl/_pyopengl2.py +362 -0
  84. vispy/gloo/gl/dummy.py +24 -0
  85. vispy/gloo/gl/es2.py +62 -0
  86. vispy/gloo/gl/gl2.py +98 -0
  87. vispy/gloo/gl/glplus.py +168 -0
  88. vispy/gloo/gl/pyopengl2.py +97 -0
  89. vispy/gloo/gl/tests/__init__.py +0 -0
  90. vispy/gloo/gl/tests/test_basics.py +282 -0
  91. vispy/gloo/gl/tests/test_functionality.py +566 -0
  92. vispy/gloo/gl/tests/test_names.py +246 -0
  93. vispy/gloo/gl/tests/test_use.py +71 -0
  94. vispy/gloo/glir.py +1816 -0
  95. vispy/gloo/globject.py +101 -0
  96. vispy/gloo/preprocessor.py +67 -0
  97. vispy/gloo/program.py +543 -0
  98. vispy/gloo/tests/__init__.py +0 -0
  99. vispy/gloo/tests/test_buffer.py +558 -0
  100. vispy/gloo/tests/test_context.py +119 -0
  101. vispy/gloo/tests/test_framebuffer.py +195 -0
  102. vispy/gloo/tests/test_glir.py +307 -0
  103. vispy/gloo/tests/test_globject.py +35 -0
  104. vispy/gloo/tests/test_program.py +302 -0
  105. vispy/gloo/tests/test_texture.py +732 -0
  106. vispy/gloo/tests/test_use_gloo.py +187 -0
  107. vispy/gloo/tests/test_util.py +60 -0
  108. vispy/gloo/tests/test_wrappers.py +261 -0
  109. vispy/gloo/texture.py +1045 -0
  110. vispy/gloo/util.py +129 -0
  111. vispy/gloo/wrappers.py +762 -0
  112. vispy/glsl/__init__.py +42 -0
  113. vispy/glsl/antialias/antialias.glsl +7 -0
  114. vispy/glsl/antialias/cap-butt.glsl +31 -0
  115. vispy/glsl/antialias/cap-round.glsl +29 -0
  116. vispy/glsl/antialias/cap-square.glsl +30 -0
  117. vispy/glsl/antialias/cap-triangle-in.glsl +30 -0
  118. vispy/glsl/antialias/cap-triangle-out.glsl +30 -0
  119. vispy/glsl/antialias/cap.glsl +67 -0
  120. vispy/glsl/antialias/caps.glsl +67 -0
  121. vispy/glsl/antialias/filled.glsl +50 -0
  122. vispy/glsl/antialias/outline.glsl +40 -0
  123. vispy/glsl/antialias/stroke.glsl +43 -0
  124. vispy/glsl/arrowheads/angle.glsl +99 -0
  125. vispy/glsl/arrowheads/arrowheads.frag +60 -0
  126. vispy/glsl/arrowheads/arrowheads.glsl +12 -0
  127. vispy/glsl/arrowheads/arrowheads.vert +83 -0
  128. vispy/glsl/arrowheads/curved.glsl +48 -0
  129. vispy/glsl/arrowheads/inhibitor.glsl +26 -0
  130. vispy/glsl/arrowheads/stealth.glsl +46 -0
  131. vispy/glsl/arrowheads/triangle.glsl +97 -0
  132. vispy/glsl/arrowheads/util.glsl +13 -0
  133. vispy/glsl/arrows/angle-30.glsl +12 -0
  134. vispy/glsl/arrows/angle-60.glsl +12 -0
  135. vispy/glsl/arrows/angle-90.glsl +12 -0
  136. vispy/glsl/arrows/arrow.frag +39 -0
  137. vispy/glsl/arrows/arrow.vert +49 -0
  138. vispy/glsl/arrows/arrows.glsl +17 -0
  139. vispy/glsl/arrows/common.glsl +187 -0
  140. vispy/glsl/arrows/curved.glsl +63 -0
  141. vispy/glsl/arrows/stealth.glsl +50 -0
  142. vispy/glsl/arrows/triangle-30.glsl +12 -0
  143. vispy/glsl/arrows/triangle-60.glsl +12 -0
  144. vispy/glsl/arrows/triangle-90.glsl +12 -0
  145. vispy/glsl/arrows/util.glsl +98 -0
  146. vispy/glsl/build_spatial_filters.py +660 -0
  147. vispy/glsl/collections/agg-fast-path.frag +20 -0
  148. vispy/glsl/collections/agg-fast-path.vert +78 -0
  149. vispy/glsl/collections/agg-glyph.frag +60 -0
  150. vispy/glsl/collections/agg-glyph.vert +33 -0
  151. vispy/glsl/collections/agg-marker.frag +35 -0
  152. vispy/glsl/collections/agg-marker.vert +48 -0
  153. vispy/glsl/collections/agg-path.frag +55 -0
  154. vispy/glsl/collections/agg-path.vert +166 -0
  155. vispy/glsl/collections/agg-point.frag +21 -0
  156. vispy/glsl/collections/agg-point.vert +35 -0
  157. vispy/glsl/collections/agg-segment.frag +32 -0
  158. vispy/glsl/collections/agg-segment.vert +75 -0
  159. vispy/glsl/collections/marker.frag +38 -0
  160. vispy/glsl/collections/marker.vert +48 -0
  161. vispy/glsl/collections/raw-path.frag +15 -0
  162. vispy/glsl/collections/raw-path.vert +24 -0
  163. vispy/glsl/collections/raw-point.frag +14 -0
  164. vispy/glsl/collections/raw-point.vert +31 -0
  165. vispy/glsl/collections/raw-segment.frag +18 -0
  166. vispy/glsl/collections/raw-segment.vert +26 -0
  167. vispy/glsl/collections/raw-triangle.frag +13 -0
  168. vispy/glsl/collections/raw-triangle.vert +26 -0
  169. vispy/glsl/collections/sdf-glyph-ticks.vert +69 -0
  170. vispy/glsl/collections/sdf-glyph.frag +80 -0
  171. vispy/glsl/collections/sdf-glyph.vert +59 -0
  172. vispy/glsl/collections/tick-labels.vert +71 -0
  173. vispy/glsl/colormaps/autumn.glsl +20 -0
  174. vispy/glsl/colormaps/blues.glsl +20 -0
  175. vispy/glsl/colormaps/color-space.glsl +17 -0
  176. vispy/glsl/colormaps/colormaps.glsl +24 -0
  177. vispy/glsl/colormaps/cool.glsl +20 -0
  178. vispy/glsl/colormaps/fire.glsl +21 -0
  179. vispy/glsl/colormaps/gray.glsl +20 -0
  180. vispy/glsl/colormaps/greens.glsl +20 -0
  181. vispy/glsl/colormaps/hot.glsl +22 -0
  182. vispy/glsl/colormaps/ice.glsl +20 -0
  183. vispy/glsl/colormaps/icefire.glsl +23 -0
  184. vispy/glsl/colormaps/parse.py +40 -0
  185. vispy/glsl/colormaps/reds.glsl +20 -0
  186. vispy/glsl/colormaps/spring.glsl +20 -0
  187. vispy/glsl/colormaps/summer.glsl +20 -0
  188. vispy/glsl/colormaps/user.glsl +22 -0
  189. vispy/glsl/colormaps/util.glsl +41 -0
  190. vispy/glsl/colormaps/wheel.glsl +21 -0
  191. vispy/glsl/colormaps/winter.glsl +20 -0
  192. vispy/glsl/lines/agg.frag +320 -0
  193. vispy/glsl/lines/agg.vert +241 -0
  194. vispy/glsl/markers/arrow.glsl +12 -0
  195. vispy/glsl/markers/asterisk.glsl +16 -0
  196. vispy/glsl/markers/chevron.glsl +14 -0
  197. vispy/glsl/markers/clover.glsl +20 -0
  198. vispy/glsl/markers/club.glsl +31 -0
  199. vispy/glsl/markers/cross.glsl +17 -0
  200. vispy/glsl/markers/diamond.glsl +12 -0
  201. vispy/glsl/markers/disc.glsl +9 -0
  202. vispy/glsl/markers/ellipse.glsl +67 -0
  203. vispy/glsl/markers/hbar.glsl +9 -0
  204. vispy/glsl/markers/heart.glsl +15 -0
  205. vispy/glsl/markers/infinity.glsl +15 -0
  206. vispy/glsl/markers/marker-sdf.frag +74 -0
  207. vispy/glsl/markers/marker-sdf.vert +41 -0
  208. vispy/glsl/markers/marker.frag +36 -0
  209. vispy/glsl/markers/marker.vert +46 -0
  210. vispy/glsl/markers/markers.glsl +24 -0
  211. vispy/glsl/markers/pin.glsl +18 -0
  212. vispy/glsl/markers/ring.glsl +11 -0
  213. vispy/glsl/markers/spade.glsl +28 -0
  214. vispy/glsl/markers/square.glsl +10 -0
  215. vispy/glsl/markers/tag.glsl +11 -0
  216. vispy/glsl/markers/triangle.glsl +14 -0
  217. vispy/glsl/markers/vbar.glsl +9 -0
  218. vispy/glsl/math/circle-through-2-points.glsl +30 -0
  219. vispy/glsl/math/constants.glsl +48 -0
  220. vispy/glsl/math/double.glsl +114 -0
  221. vispy/glsl/math/functions.glsl +20 -0
  222. vispy/glsl/math/point-to-line-distance.glsl +31 -0
  223. vispy/glsl/math/point-to-line-projection.glsl +29 -0
  224. vispy/glsl/math/signed-line-distance.glsl +27 -0
  225. vispy/glsl/math/signed-segment-distance.glsl +30 -0
  226. vispy/glsl/misc/regular-grid.frag +244 -0
  227. vispy/glsl/misc/spatial-filters.frag +1407 -0
  228. vispy/glsl/misc/viewport-NDC.glsl +20 -0
  229. vispy/glsl/transforms/azimuthal-equal-area.glsl +32 -0
  230. vispy/glsl/transforms/azimuthal-equidistant.glsl +38 -0
  231. vispy/glsl/transforms/hammer.glsl +44 -0
  232. vispy/glsl/transforms/identity.glsl +6 -0
  233. vispy/glsl/transforms/identity_forward.glsl +23 -0
  234. vispy/glsl/transforms/identity_inverse.glsl +23 -0
  235. vispy/glsl/transforms/linear-scale.glsl +127 -0
  236. vispy/glsl/transforms/log-scale.glsl +126 -0
  237. vispy/glsl/transforms/mercator-transverse-forward.glsl +40 -0
  238. vispy/glsl/transforms/mercator-transverse-inverse.glsl +40 -0
  239. vispy/glsl/transforms/panzoom.glsl +10 -0
  240. vispy/glsl/transforms/polar.glsl +41 -0
  241. vispy/glsl/transforms/position.glsl +44 -0
  242. vispy/glsl/transforms/power-scale.glsl +139 -0
  243. vispy/glsl/transforms/projection.glsl +7 -0
  244. vispy/glsl/transforms/pvm.glsl +13 -0
  245. vispy/glsl/transforms/rotate.glsl +45 -0
  246. vispy/glsl/transforms/trackball.glsl +15 -0
  247. vispy/glsl/transforms/translate.glsl +35 -0
  248. vispy/glsl/transforms/transverse_mercator.glsl +38 -0
  249. vispy/glsl/transforms/viewport-clipping.glsl +14 -0
  250. vispy/glsl/transforms/viewport-transform.glsl +16 -0
  251. vispy/glsl/transforms/viewport.glsl +50 -0
  252. vispy/glsl/transforms/x.glsl +24 -0
  253. vispy/glsl/transforms/y.glsl +19 -0
  254. vispy/glsl/transforms/z.glsl +14 -0
  255. vispy/io/__init__.py +20 -0
  256. vispy/io/_data/spatial-filters.npy +0 -0
  257. vispy/io/datasets.py +94 -0
  258. vispy/io/image.py +231 -0
  259. vispy/io/mesh.py +122 -0
  260. vispy/io/stl.py +167 -0
  261. vispy/io/tests/__init__.py +0 -0
  262. vispy/io/tests/test_image.py +47 -0
  263. vispy/io/tests/test_io.py +121 -0
  264. vispy/io/wavefront.py +350 -0
  265. vispy/plot/__init__.py +36 -0
  266. vispy/plot/fig.py +58 -0
  267. vispy/plot/plotwidget.py +522 -0
  268. vispy/plot/tests/__init__.py +0 -0
  269. vispy/plot/tests/test_plot.py +46 -0
  270. vispy/scene/__init__.py +43 -0
  271. vispy/scene/cameras/__init__.py +27 -0
  272. vispy/scene/cameras/_base.py +38 -0
  273. vispy/scene/cameras/arcball.py +106 -0
  274. vispy/scene/cameras/base_camera.py +538 -0
  275. vispy/scene/cameras/fly.py +474 -0
  276. vispy/scene/cameras/magnify.py +163 -0
  277. vispy/scene/cameras/panzoom.py +308 -0
  278. vispy/scene/cameras/perspective.py +333 -0
  279. vispy/scene/cameras/tests/__init__.py +0 -0
  280. vispy/scene/cameras/tests/test_cameras.py +27 -0
  281. vispy/scene/cameras/tests/test_link.py +53 -0
  282. vispy/scene/cameras/tests/test_perspective.py +122 -0
  283. vispy/scene/cameras/turntable.py +173 -0
  284. vispy/scene/canvas.py +639 -0
  285. vispy/scene/events.py +85 -0
  286. vispy/scene/node.py +644 -0
  287. vispy/scene/subscene.py +20 -0
  288. vispy/scene/tests/__init__.py +0 -0
  289. vispy/scene/tests/test_canvas.py +119 -0
  290. vispy/scene/tests/test_node.py +142 -0
  291. vispy/scene/tests/test_visuals.py +141 -0
  292. vispy/scene/visuals.py +276 -0
  293. vispy/scene/widgets/__init__.py +18 -0
  294. vispy/scene/widgets/anchor.py +25 -0
  295. vispy/scene/widgets/axis.py +88 -0
  296. vispy/scene/widgets/colorbar.py +176 -0
  297. vispy/scene/widgets/console.py +351 -0
  298. vispy/scene/widgets/grid.py +509 -0
  299. vispy/scene/widgets/label.py +50 -0
  300. vispy/scene/widgets/tests/__init__.py +0 -0
  301. vispy/scene/widgets/tests/test_colorbar.py +47 -0
  302. vispy/scene/widgets/viewbox.py +199 -0
  303. vispy/scene/widgets/widget.py +478 -0
  304. vispy/testing/__init__.py +51 -0
  305. vispy/testing/_runners.py +446 -0
  306. vispy/testing/_testing.py +416 -0
  307. vispy/testing/image_tester.py +473 -0
  308. vispy/testing/rendered_array_tester.py +85 -0
  309. vispy/testing/tests/__init__.py +0 -0
  310. vispy/testing/tests/test_testing.py +20 -0
  311. vispy/util/__init__.py +17 -0
  312. vispy/util/bunch.py +15 -0
  313. vispy/util/check_environment.py +57 -0
  314. vispy/util/config.py +490 -0
  315. vispy/util/dpi/__init__.py +19 -0
  316. vispy/util/dpi/_linux.py +69 -0
  317. vispy/util/dpi/_quartz.py +26 -0
  318. vispy/util/dpi/_win32.py +34 -0
  319. vispy/util/dpi/tests/__init__.py +0 -0
  320. vispy/util/dpi/tests/test_dpi.py +16 -0
  321. vispy/util/eq.py +41 -0
  322. vispy/util/event.py +774 -0
  323. vispy/util/fetching.py +276 -0
  324. vispy/util/filter.py +44 -0
  325. vispy/util/fonts/__init__.py +14 -0
  326. vispy/util/fonts/_freetype.py +73 -0
  327. vispy/util/fonts/_quartz.py +192 -0
  328. vispy/util/fonts/_triage.py +36 -0
  329. vispy/util/fonts/_vispy_fonts.py +20 -0
  330. vispy/util/fonts/_win32.py +105 -0
  331. vispy/util/fonts/data/OpenSans-Bold.ttf +0 -0
  332. vispy/util/fonts/data/OpenSans-BoldItalic.ttf +0 -0
  333. vispy/util/fonts/data/OpenSans-Italic.ttf +0 -0
  334. vispy/util/fonts/data/OpenSans-Regular.ttf +0 -0
  335. vispy/util/fonts/tests/__init__.py +0 -0
  336. vispy/util/fonts/tests/test_font.py +45 -0
  337. vispy/util/fourier.py +69 -0
  338. vispy/util/frozen.py +25 -0
  339. vispy/util/gallery_scraper.py +268 -0
  340. vispy/util/keys.py +91 -0
  341. vispy/util/logs.py +358 -0
  342. vispy/util/osmesa_gl.py +17 -0
  343. vispy/util/profiler.py +135 -0
  344. vispy/util/ptime.py +16 -0
  345. vispy/util/quaternion.py +229 -0
  346. vispy/util/svg/__init__.py +18 -0
  347. vispy/util/svg/base.py +20 -0
  348. vispy/util/svg/color.py +219 -0
  349. vispy/util/svg/element.py +51 -0
  350. vispy/util/svg/geometry.py +478 -0
  351. vispy/util/svg/group.py +66 -0
  352. vispy/util/svg/length.py +81 -0
  353. vispy/util/svg/number.py +25 -0
  354. vispy/util/svg/path.py +332 -0
  355. vispy/util/svg/shapes.py +57 -0
  356. vispy/util/svg/style.py +59 -0
  357. vispy/util/svg/svg.py +40 -0
  358. vispy/util/svg/transform.py +223 -0
  359. vispy/util/svg/transformable.py +28 -0
  360. vispy/util/svg/viewport.py +73 -0
  361. vispy/util/tests/__init__.py +0 -0
  362. vispy/util/tests/test_config.py +58 -0
  363. vispy/util/tests/test_docstring_parameters.py +123 -0
  364. vispy/util/tests/test_emitter_group.py +262 -0
  365. vispy/util/tests/test_event_emitter.py +743 -0
  366. vispy/util/tests/test_fourier.py +35 -0
  367. vispy/util/tests/test_gallery_scraper.py +112 -0
  368. vispy/util/tests/test_import.py +127 -0
  369. vispy/util/tests/test_key.py +22 -0
  370. vispy/util/tests/test_logging.py +45 -0
  371. vispy/util/tests/test_run.py +14 -0
  372. vispy/util/tests/test_transforms.py +42 -0
  373. vispy/util/tests/test_vispy.py +48 -0
  374. vispy/util/transforms.py +201 -0
  375. vispy/util/wrappers.py +155 -0
  376. vispy/version.py +4 -0
  377. vispy/visuals/__init__.py +50 -0
  378. vispy/visuals/_scalable_textures.py +485 -0
  379. vispy/visuals/axis.py +678 -0
  380. vispy/visuals/border.py +208 -0
  381. vispy/visuals/box.py +79 -0
  382. vispy/visuals/collections/__init__.py +30 -0
  383. vispy/visuals/collections/agg_fast_path_collection.py +219 -0
  384. vispy/visuals/collections/agg_path_collection.py +197 -0
  385. vispy/visuals/collections/agg_point_collection.py +52 -0
  386. vispy/visuals/collections/agg_segment_collection.py +142 -0
  387. vispy/visuals/collections/array_list.py +401 -0
  388. vispy/visuals/collections/base_collection.py +482 -0
  389. vispy/visuals/collections/collection.py +253 -0
  390. vispy/visuals/collections/path_collection.py +23 -0
  391. vispy/visuals/collections/point_collection.py +19 -0
  392. vispy/visuals/collections/polygon_collection.py +25 -0
  393. vispy/visuals/collections/raw_path_collection.py +119 -0
  394. vispy/visuals/collections/raw_point_collection.py +113 -0
  395. vispy/visuals/collections/raw_polygon_collection.py +77 -0
  396. vispy/visuals/collections/raw_segment_collection.py +112 -0
  397. vispy/visuals/collections/raw_triangle_collection.py +78 -0
  398. vispy/visuals/collections/segment_collection.py +19 -0
  399. vispy/visuals/collections/triangle_collection.py +16 -0
  400. vispy/visuals/collections/util.py +168 -0
  401. vispy/visuals/colorbar.py +699 -0
  402. vispy/visuals/cube.py +41 -0
  403. vispy/visuals/ellipse.py +163 -0
  404. vispy/visuals/filters/__init__.py +10 -0
  405. vispy/visuals/filters/base_filter.py +242 -0
  406. vispy/visuals/filters/clipper.py +60 -0
  407. vispy/visuals/filters/clipping_planes.py +122 -0
  408. vispy/visuals/filters/color.py +181 -0
  409. vispy/visuals/filters/markers.py +28 -0
  410. vispy/visuals/filters/mesh.py +796 -0
  411. vispy/visuals/filters/picking.py +60 -0
  412. vispy/visuals/filters/tests/__init__.py +3 -0
  413. vispy/visuals/filters/tests/test_primitive_picking_filters.py +70 -0
  414. vispy/visuals/filters/tests/test_wireframe_filter.py +16 -0
  415. vispy/visuals/glsl/__init__.py +1 -0
  416. vispy/visuals/glsl/antialiasing.py +133 -0
  417. vispy/visuals/glsl/color.py +63 -0
  418. vispy/visuals/graphs/__init__.py +1 -0
  419. vispy/visuals/graphs/graph.py +240 -0
  420. vispy/visuals/graphs/layouts/__init__.py +55 -0
  421. vispy/visuals/graphs/layouts/circular.py +49 -0
  422. vispy/visuals/graphs/layouts/force_directed.py +211 -0
  423. vispy/visuals/graphs/layouts/networkx_layout.py +87 -0
  424. vispy/visuals/graphs/layouts/random.py +52 -0
  425. vispy/visuals/graphs/tests/__init__.py +1 -0
  426. vispy/visuals/graphs/tests/test_layouts.py +139 -0
  427. vispy/visuals/graphs/tests/test_networkx_layout.py +47 -0
  428. vispy/visuals/graphs/util.py +120 -0
  429. vispy/visuals/gridlines.py +105 -0
  430. vispy/visuals/gridmesh.py +98 -0
  431. vispy/visuals/histogram.py +58 -0
  432. vispy/visuals/image.py +688 -0
  433. vispy/visuals/image_complex.py +130 -0
  434. vispy/visuals/infinite_line.py +199 -0
  435. vispy/visuals/instanced_mesh.py +152 -0
  436. vispy/visuals/isocurve.py +213 -0
  437. vispy/visuals/isoline.py +241 -0
  438. vispy/visuals/isosurface.py +113 -0
  439. vispy/visuals/line/__init__.py +6 -0
  440. vispy/visuals/line/arrow.py +289 -0
  441. vispy/visuals/line/dash_atlas.py +90 -0
  442. vispy/visuals/line/line.py +545 -0
  443. vispy/visuals/line_plot.py +135 -0
  444. vispy/visuals/linear_region.py +199 -0
  445. vispy/visuals/markers.py +810 -0
  446. vispy/visuals/mesh.py +373 -0
  447. vispy/visuals/mesh_normals.py +159 -0
  448. vispy/visuals/plane.py +54 -0
  449. vispy/visuals/polygon.py +145 -0
  450. vispy/visuals/rectangle.py +196 -0
  451. vispy/visuals/regular_polygon.py +56 -0
  452. vispy/visuals/scrolling_lines.py +197 -0
  453. vispy/visuals/shaders/__init__.py +17 -0
  454. vispy/visuals/shaders/compiler.py +206 -0
  455. vispy/visuals/shaders/expression.py +99 -0
  456. vispy/visuals/shaders/function.py +788 -0
  457. vispy/visuals/shaders/multiprogram.py +145 -0
  458. vispy/visuals/shaders/parsing.py +140 -0
  459. vispy/visuals/shaders/program.py +161 -0
  460. vispy/visuals/shaders/shader_object.py +162 -0
  461. vispy/visuals/shaders/tests/__init__.py +0 -0
  462. vispy/visuals/shaders/tests/test_function.py +486 -0
  463. vispy/visuals/shaders/tests/test_multiprogram.py +78 -0
  464. vispy/visuals/shaders/tests/test_parsing.py +57 -0
  465. vispy/visuals/shaders/variable.py +272 -0
  466. vispy/visuals/spectrogram.py +169 -0
  467. vispy/visuals/sphere.py +80 -0
  468. vispy/visuals/surface_plot.py +192 -0
  469. vispy/visuals/tests/__init__.py +0 -0
  470. vispy/visuals/tests/test_arrows.py +109 -0
  471. vispy/visuals/tests/test_axis.py +120 -0
  472. vispy/visuals/tests/test_collections.py +15 -0
  473. vispy/visuals/tests/test_colorbar.py +179 -0
  474. vispy/visuals/tests/test_colormap.py +97 -0
  475. vispy/visuals/tests/test_ellipse.py +122 -0
  476. vispy/visuals/tests/test_histogram.py +24 -0
  477. vispy/visuals/tests/test_image.py +390 -0
  478. vispy/visuals/tests/test_image_complex.py +36 -0
  479. vispy/visuals/tests/test_infinite_line.py +53 -0
  480. vispy/visuals/tests/test_instanced_mesh.py +50 -0
  481. vispy/visuals/tests/test_isosurface.py +22 -0
  482. vispy/visuals/tests/test_linear_region.py +152 -0
  483. vispy/visuals/tests/test_markers.py +54 -0
  484. vispy/visuals/tests/test_mesh.py +261 -0
  485. vispy/visuals/tests/test_mesh_normals.py +218 -0
  486. vispy/visuals/tests/test_polygon.py +112 -0
  487. vispy/visuals/tests/test_rectangle.py +163 -0
  488. vispy/visuals/tests/test_regular_polygon.py +111 -0
  489. vispy/visuals/tests/test_scalable_textures.py +180 -0
  490. vispy/visuals/tests/test_sdf.py +73 -0
  491. vispy/visuals/tests/test_spectrogram.py +42 -0
  492. vispy/visuals/tests/test_text.py +95 -0
  493. vispy/visuals/tests/test_volume.py +542 -0
  494. vispy/visuals/tests/test_windbarb.py +33 -0
  495. vispy/visuals/text/__init__.py +7 -0
  496. vispy/visuals/text/_sdf_cpu.cpython-311-darwin.so +0 -0
  497. vispy/visuals/text/_sdf_cpu.pyx +110 -0
  498. vispy/visuals/text/_sdf_gpu.py +316 -0
  499. vispy/visuals/text/text.py +675 -0
  500. vispy/visuals/transforms/__init__.py +34 -0
  501. vispy/visuals/transforms/_util.py +191 -0
  502. vispy/visuals/transforms/base_transform.py +233 -0
  503. vispy/visuals/transforms/chain.py +300 -0
  504. vispy/visuals/transforms/interactive.py +98 -0
  505. vispy/visuals/transforms/linear.py +564 -0
  506. vispy/visuals/transforms/nonlinear.py +398 -0
  507. vispy/visuals/transforms/tests/__init__.py +0 -0
  508. vispy/visuals/transforms/tests/test_transforms.py +243 -0
  509. vispy/visuals/transforms/transform_system.py +339 -0
  510. vispy/visuals/tube.py +173 -0
  511. vispy/visuals/visual.py +923 -0
  512. vispy/visuals/volume.py +1335 -0
  513. vispy/visuals/windbarb.py +291 -0
  514. vispy/visuals/xyz_axis.py +34 -0
  515. vispy-0.14.0.dist-info/LICENSE.txt +36 -0
  516. vispy-0.14.0.dist-info/METADATA +218 -0
  517. vispy-0.14.0.dist-info/RECORD +519 -0
  518. vispy-0.14.0.dist-info/WHEEL +5 -0
  519. vispy-0.14.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,1134 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright (c) Vispy Development Team. All Rights Reserved.
3
+ # Distributed under the (new) BSD License. See LICENSE.txt for more info.
4
+
5
+ from __future__ import division # just to be safe...
6
+ import warnings
7
+
8
+ import numpy as np
9
+
10
+ from .color_array import ColorArray
11
+ from ..ext.cubehelix import cubehelix
12
+ from hsluv import hsluv_to_rgb
13
+ from ..util.check_environment import has_matplotlib
14
+ import vispy.gloo
15
+
16
+ ###############################################################################
17
+ # Color maps
18
+
19
+ # Length of the texture map used for luminance to RGBA conversion
20
+ LUT_len = 1024
21
+
22
+
23
+ # Utility functions for interpolation in NumPy.
24
+ def _vector_or_scalar(x, type='row'):
25
+ """Convert an object to either a scalar or a row or column vector."""
26
+ if isinstance(x, (list, tuple)):
27
+ x = np.array(x)
28
+ if isinstance(x, np.ndarray):
29
+ assert x.ndim == 1
30
+ if type == 'column':
31
+ x = x[:, None]
32
+ return x
33
+
34
+
35
+ def _vector(x, type='row'):
36
+ """Convert an object to a row or column vector."""
37
+ if isinstance(x, (list, tuple)):
38
+ x = np.array(x, dtype=np.float32)
39
+ elif not isinstance(x, np.ndarray):
40
+ x = np.array([x], dtype=np.float32)
41
+ assert x.ndim == 1
42
+ if type == 'column':
43
+ x = x[:, None]
44
+ return x
45
+
46
+
47
+ def _find_controls(x, controls=None, clip=None):
48
+ x_controls = np.clip(np.searchsorted(controls, x) - 1, 0, clip)
49
+ return x_controls.astype(np.int32)
50
+
51
+
52
+ # Normalization
53
+ def _normalize(x, cmin=None, cmax=None, clip=True):
54
+ """Normalize an array from the range [cmin, cmax] to [0,1],
55
+ with optional clipping.
56
+ """
57
+ if not isinstance(x, np.ndarray):
58
+ x = np.array(x)
59
+ if cmin is None:
60
+ cmin = x.min()
61
+ if cmax is None:
62
+ cmax = x.max()
63
+ if cmin == cmax:
64
+ return .5 * np.ones(x.shape)
65
+ else:
66
+ cmin, cmax = float(cmin), float(cmax)
67
+ y = (x - cmin) * 1. / (cmax - cmin)
68
+ if clip:
69
+ y = np.clip(y, 0., 1.)
70
+ return y
71
+
72
+
73
+ # Interpolation functions in NumPy.
74
+ def _mix_simple(a, b, x):
75
+ """Mix b (with proportion x) with a."""
76
+ x = np.clip(x, 0.0, 1.0)
77
+ return (1.0 - x)*a + x*b
78
+
79
+
80
+ def _interpolate_multi(colors, x, controls):
81
+ x = x.ravel()
82
+ n = len(colors)
83
+ # For each element in x, the control index of its bin's left boundary.
84
+ x_step = _find_controls(x, controls, n-2)
85
+ # The length of each bin.
86
+ controls_length = np.diff(controls).astype(np.float32)
87
+ # Prevent division by zero error.
88
+ controls_length[controls_length == 0.] = 1.
89
+ # Like x, but relative to each bin.
90
+ _to_clip = x - controls[x_step]
91
+ _to_clip /= controls_length[x_step]
92
+ x_rel = np.clip(_to_clip, 0., 1.)
93
+ return (colors[x_step],
94
+ colors[x_step + 1],
95
+ x_rel[:, None])
96
+
97
+
98
+ def mix(colors, x, controls=None):
99
+ a, b, x_rel = _interpolate_multi(colors, x, controls)
100
+ return _mix_simple(a, b, x_rel)
101
+
102
+
103
+ def smoothstep(edge0, edge1, x):
104
+ """Performs smooth Hermite interpolation
105
+ between 0 and 1 when edge0 < x < edge1.
106
+ """
107
+ # Scale, bias and saturate x to 0..1 range
108
+ x = np.clip((x - edge0)/(edge1 - edge0), 0.0, 1.0)
109
+ # Evaluate polynomial
110
+ return x*x*(3 - 2*x)
111
+
112
+
113
+ def step(colors, x, controls=None):
114
+ x = x.ravel()
115
+ """Step interpolation from a set of colors. x belongs in [0, 1]."""
116
+ assert (controls[0], controls[-1]) == (0., 1.)
117
+ ncolors = len(colors)
118
+ assert ncolors == len(controls) - 1
119
+ assert ncolors >= 2
120
+ x_step = _find_controls(x, controls, ncolors-1)
121
+ return colors[x_step, ...]
122
+
123
+
124
+ # GLSL interpolation functions.
125
+ def _glsl_mix(controls=None, colors=None, texture_map_data=None):
126
+ """Generate a GLSL template function from a given interpolation patterns
127
+ and control points.
128
+
129
+ Parameters
130
+ ----------
131
+ colors : array-like, shape (n_colors, 4)
132
+ The control colors used by the colormap.
133
+ Elements of colors must be convertible to an instance of Color-class.
134
+
135
+ controls : list
136
+ The list of control points for the given colors. It should be
137
+ an increasing list of floating-point number between 0.0 and 1.0.
138
+ The first control point must be 0.0. The last control point must be
139
+ 1.0. The number of control points depends on the interpolation scheme.
140
+
141
+ texture_map_data : ndarray, shape(texture_len, 4)
142
+ Numpy array of size of 1D texture lookup data
143
+ for luminance to RGBA conversion.
144
+ """
145
+ assert (controls[0], controls[-1]) == (0., 1.)
146
+ ncolors = len(controls)
147
+ assert ncolors >= 2
148
+ assert (texture_map_data is not None)
149
+
150
+ LUT = texture_map_data
151
+ texture_len = texture_map_data.shape[0]
152
+
153
+ # Perform linear interpolation for each RGBA color component.
154
+ c_rgba = ColorArray(colors)._rgba
155
+ x = np.linspace(0.0, 1.0, texture_len)
156
+ LUT[:, 0, 0] = np.interp(x, controls, c_rgba[:, 0])
157
+ LUT[:, 0, 1] = np.interp(x, controls, c_rgba[:, 1])
158
+ LUT[:, 0, 2] = np.interp(x, controls, c_rgba[:, 2])
159
+ LUT[:, 0, 3] = np.interp(x, controls, c_rgba[:, 3])
160
+
161
+ s2 = "uniform sampler2D texture2D_LUT;"
162
+ s = "{\n return texture2D(texture2D_LUT, \
163
+ vec2(0.0, clamp(t, 0.0, 1.0)));\n} "
164
+
165
+ return "%s\nvec4 colormap(float t) {\n%s\n}" % (s2, s)
166
+
167
+
168
+ def _glsl_step(controls=None, colors=None, texture_map_data=None):
169
+ assert (controls[0], controls[-1]) == (0., 1.)
170
+ ncolors = len(controls) - 1
171
+ assert ncolors >= 2
172
+ assert (texture_map_data is not None)
173
+
174
+ LUT = texture_map_data
175
+ texture_len = texture_map_data.shape[0]
176
+ LUT_tex_idx = np.linspace(0.0, 1.0, texture_len)
177
+
178
+ # Replicate indices to colormap texture.
179
+ # The resulting matrix has size of (texture_len,len(controls)).
180
+ # It is used to perform piecewise constant interpolation
181
+ # for each RGBA color component.
182
+ t2 = np.repeat(LUT_tex_idx[:, np.newaxis], len(controls), 1)
183
+
184
+ # Perform element-wise comparison to find
185
+ # control points for all LUT colors.
186
+ bn = np.sum(controls.transpose() <= t2, axis=1)
187
+
188
+ j = np.clip(bn-1, 0, ncolors-1)
189
+
190
+ # Copying color data from ColorArray to array-like
191
+ # makes data assignment to LUT faster.
192
+ colors_rgba = ColorArray(colors[:])._rgba
193
+ LUT[:, 0, :] = colors_rgba[j]
194
+
195
+ s2 = "uniform sampler2D texture2D_LUT;"
196
+ s = "{\n return texture2D(texture2D_LUT, \
197
+ vec2(0.0, clamp(t, 0.0, 1.0)));\n} "
198
+
199
+ return "%s\nvec4 colormap(float t) {\n%s\n}" % (s2, s)
200
+
201
+
202
+ # Mini GLSL template system for colors.
203
+ def _process_glsl_template(template, colors):
204
+ """Replace $color_i by color #i in the GLSL template."""
205
+ for i in range(len(colors) - 1, -1, -1):
206
+ color = colors[i]
207
+ assert len(color) == 4
208
+ vec4_color = 'vec4(%.3f, %.3f, %.3f, %.3f)' % tuple(color)
209
+ template = template.replace('$color_%d' % i, vec4_color)
210
+ return template
211
+
212
+
213
+ class BaseColormap(object):
214
+ u"""Class representing a colormap:
215
+
216
+ t in [0, 1] --> rgba_color
217
+
218
+ Parameters
219
+ ----------
220
+ colors : list of lists, tuples, or ndarrays
221
+ The control colors used by the colormap (shape = (ncolors, 4)).
222
+
223
+ Notes
224
+ -----
225
+ Must be overriden. Child classes need to implement:
226
+
227
+ glsl_map : string
228
+ The GLSL function for the colormap. Use $color_0 to refer
229
+ to the first color in `colors`, and so on. These are vec4 vectors.
230
+ map(item) : function
231
+ Takes a (N, 1) vector of values in [0, 1], and returns a rgba array
232
+ of size (N, 4).
233
+ """
234
+
235
+ # Control colors used by the colormap.
236
+ colors = None
237
+
238
+ # GLSL string with a function implementing the color map.
239
+ glsl_map = None
240
+
241
+ # Texture map data used by the 'colormap' GLSL function
242
+ # for luminance to RGBA conversion.
243
+ texture_map_data = None
244
+
245
+ def __init__(self, colors=None):
246
+ # Ensure the colors are arrays.
247
+ if colors is not None:
248
+ self.colors = colors
249
+ if not isinstance(self.colors, ColorArray):
250
+ self.colors = ColorArray(self.colors)
251
+ # Process the GLSL map function by replacing $color_i by the
252
+ if len(self.colors) > 0:
253
+ self.glsl_map = _process_glsl_template(self.glsl_map,
254
+ self.colors.rgba)
255
+
256
+ def map(self, item):
257
+ """Return a rgba array for the requested items.
258
+
259
+ This function must be overriden by child classes.
260
+
261
+ This function doesn't need to implement argument checking on `item`.
262
+ It can always assume that `item` is a (N, 1) array of values between
263
+ 0 and 1.
264
+
265
+ Parameters
266
+ ----------
267
+ item : ndarray
268
+ An array of values in [0,1].
269
+
270
+ Returns
271
+ -------
272
+ rgba : ndarray
273
+ An array with rgba values, with one color per item. The shape
274
+ should be ``item.shape + (4,)``.
275
+
276
+ Notes
277
+ -----
278
+ Users are expected to use a colormap with ``__getitem__()`` rather
279
+ than ``map()`` (which implements a lower-level API).
280
+
281
+ """
282
+ raise NotImplementedError()
283
+
284
+ def texture_lut(self):
285
+ """Return a texture2D object for LUT after its value is set. Can be None."""
286
+ return None
287
+
288
+ def __getitem__(self, item):
289
+ if isinstance(item, tuple):
290
+ raise ValueError('ColorArray indexing is only allowed along '
291
+ 'the first dimension.')
292
+ # Ensure item is either a scalar or a column vector.
293
+ item = _vector(item, type='column')
294
+ # Clip the values in [0, 1].
295
+ item = np.clip(item, 0., 1.)
296
+ colors = self.map(item)
297
+ return ColorArray(colors)
298
+
299
+ def __setitem__(self, item, value):
300
+ raise RuntimeError("It is not possible to set items to "
301
+ "BaseColormap instances.")
302
+
303
+ def _repr_html_(self):
304
+ n = 100
305
+ html = ("""
306
+ <style>
307
+ table.vispy_colormap {
308
+ height: 30px;
309
+ border: 0;
310
+ margin: 0;
311
+ padding: 0;
312
+ }
313
+
314
+ table.vispy_colormap td {
315
+ width: 3px;
316
+ border: 0;
317
+ margin: 0;
318
+ padding: 0;
319
+ }
320
+ </style>
321
+ <table class="vispy_colormap">
322
+ """ +
323
+ '\n'.join([(("""<td style="background-color: %s;"
324
+ title="%s"></td>""") % (color, color))
325
+ for color in self[np.linspace(0., 1., n)].hex]) +
326
+ """
327
+ </table>
328
+ """)
329
+ return html
330
+
331
+
332
+ def _default_controls(ncolors):
333
+ """Generate linearly spaced control points from a set of colors."""
334
+ return np.linspace(0., 1., ncolors)
335
+
336
+
337
+ # List the parameters of every supported interpolation mode.
338
+ _interpolation_info = {
339
+ 'linear': {
340
+ 'ncontrols': lambda ncolors: ncolors, # take ncolors as argument
341
+ 'glsl_map': _glsl_mix, # take 'controls' and 'colors' as arguments
342
+ 'map': mix,
343
+ },
344
+ 'zero': {
345
+ 'ncontrols': lambda ncolors: (ncolors+1),
346
+ 'glsl_map': _glsl_step,
347
+ 'map': step,
348
+ }
349
+ }
350
+
351
+
352
+ class Colormap(BaseColormap):
353
+ """A colormap defining several control colors and an interpolation scheme.
354
+
355
+ Parameters
356
+ ----------
357
+ colors : list of colors | ColorArray
358
+ The list of control colors. If not a ``ColorArray``, a new
359
+ ``ColorArray`` instance is created from this list. See the
360
+ documentation of ``ColorArray``.
361
+ controls : array-like
362
+ The list of control points for the given colors. It should be
363
+ an increasing list of floating-point number between 0.0 and 1.0.
364
+ The first control point must be 0.0. The last control point must be
365
+ 1.0. The number of control points depends on the interpolation scheme.
366
+ interpolation : str
367
+ The interpolation mode of the colormap. Default: 'linear'. Can also
368
+ be 'zero'.
369
+ If 'linear', ncontrols = ncolors (one color per control point).
370
+ If 'zero', ncontrols = ncolors+1 (one color per bin).
371
+
372
+ Examples
373
+ --------
374
+ Here is a basic example:
375
+
376
+ >>> from vispy.color import Colormap
377
+ >>> cm = Colormap(['r', 'g', 'b'])
378
+ >>> cm[0.], cm[0.5], cm[np.linspace(0., 1., 100)]
379
+
380
+ """
381
+
382
+ def __init__(self, colors, controls=None, interpolation='linear'):
383
+ self.interpolation = interpolation
384
+ ncontrols = self._ncontrols(len(colors))
385
+ # Default controls.
386
+ if controls is None:
387
+ controls = _default_controls(ncontrols)
388
+ assert len(controls) == ncontrols
389
+ self._controls = np.array(controls, dtype=np.float32)
390
+ # use texture map for luminance to RGBA conversion
391
+ self.texture_map_data = np.zeros((LUT_len, 1, 4), dtype=np.float32)
392
+ self.glsl_map = self._glsl_map_generator(self._controls, colors,
393
+ self.texture_map_data)
394
+ super(Colormap, self).__init__(colors)
395
+
396
+ @property
397
+ def interpolation(self):
398
+ """The interpolation mode of the colormap"""
399
+ return self._interpolation
400
+
401
+ @interpolation.setter
402
+ def interpolation(self, val):
403
+ if val not in _interpolation_info:
404
+ raise ValueError('The interpolation mode can only be one of: ' +
405
+ ', '.join(sorted(_interpolation_info.keys())))
406
+ # Get the information of the interpolation mode.
407
+ info = _interpolation_info[val]
408
+ # Get the function that generates the GLSL map, as a function of the
409
+ # controls array.
410
+ self._glsl_map_generator = info['glsl_map']
411
+ # Number of controls as a function of the number of colors.
412
+ self._ncontrols = info['ncontrols']
413
+ # Python map function.
414
+ self._map_function = info['map']
415
+ self._interpolation = val
416
+
417
+ def map(self, x):
418
+ """The Python mapping function from the [0,1] interval to a
419
+ list of rgba colors
420
+
421
+ Parameters
422
+ ----------
423
+ x : array-like
424
+ The values to map.
425
+
426
+ Returns
427
+ -------
428
+ colors : list
429
+ List of rgba colors.
430
+ """
431
+ return self._map_function(self.colors.rgba, x, self._controls)
432
+
433
+ def texture_lut(self):
434
+ """Return a texture2D object for LUT after its value is set. Can be None."""
435
+ if self.texture_map_data is None:
436
+ return None
437
+ interp = 'linear' if self.interpolation == 'linear' else 'nearest'
438
+ texture_LUT = vispy.gloo.Texture2D(np.zeros(self.texture_map_data.shape, dtype=np.float32),
439
+ interpolation=interp)
440
+ texture_LUT.set_data(self.texture_map_data, offset=None, copy=True)
441
+ return texture_LUT
442
+
443
+
444
+ class MatplotlibColormap(Colormap):
445
+ """Use matplotlib colormaps if installed.
446
+
447
+ Parameters
448
+ ----------
449
+ name : string
450
+ Name of the colormap.
451
+ """
452
+
453
+ def __init__(self, name):
454
+ from matplotlib.cm import ScalarMappable
455
+
456
+ vec = ScalarMappable(cmap=name).to_rgba(np.arange(LUT_len))
457
+ Colormap.__init__(self, vec)
458
+
459
+
460
+ class CubeHelixColormap(Colormap):
461
+ def __init__(self, start=0.5, rot=1, gamma=1.0, reverse=True, nlev=32,
462
+ minSat=1.2, maxSat=1.2, minLight=0., maxLight=1., **kwargs):
463
+ """Cube helix colormap
464
+
465
+ A full implementation of Dave Green's "cubehelix" for Matplotlib.
466
+ Based on the FORTRAN 77 code provided in
467
+ D.A. Green, 2011, BASI, 39, 289.
468
+
469
+ http://adsabs.harvard.edu/abs/2011arXiv1108.5083G
470
+
471
+ User can adjust all parameters of the cubehelix algorithm.
472
+ This enables much greater flexibility in choosing color maps, while
473
+ always ensuring the color map scales in intensity from black
474
+ to white. A few simple examples:
475
+
476
+ Default color map settings produce the standard "cubehelix".
477
+
478
+ Create color map in only blues by setting rot=0 and start=0.
479
+
480
+ Create reverse (white to black) backwards through the rainbow once
481
+ by setting rot=1 and reverse=True.
482
+
483
+ Parameters
484
+ ----------
485
+ start : scalar, optional
486
+ Sets the starting position in the color space. 0=blue, 1=red,
487
+ 2=green. Defaults to 0.5.
488
+ rot : scalar, optional
489
+ The number of rotations through the rainbow. Can be positive
490
+ or negative, indicating direction of rainbow. Negative values
491
+ correspond to Blue->Red direction. Defaults to -1.5
492
+ gamma : scalar, optional
493
+ The gamma correction for intensity. Defaults to 1.0
494
+ reverse : boolean, optional
495
+ Set to True to reverse the color map. Will go from black to
496
+ white. Good for density plots where shade~density. Defaults to
497
+ False
498
+ nlev : scalar, optional
499
+ Defines the number of discrete levels to render colors at.
500
+ Defaults to 32.
501
+ sat : scalar, optional
502
+ The saturation intensity factor. Defaults to 1.2
503
+ NOTE: this was formerly known as "hue" parameter
504
+ minSat : scalar, optional
505
+ Sets the minimum-level saturation. Defaults to 1.2
506
+ maxSat : scalar, optional
507
+ Sets the maximum-level saturation. Defaults to 1.2
508
+ startHue : scalar, optional
509
+ Sets the starting color, ranging from [0, 360], as in
510
+ D3 version by @mbostock
511
+ NOTE: overrides values in start parameter
512
+ endHue : scalar, optional
513
+ Sets the ending color, ranging from [0, 360], as in
514
+ D3 version by @mbostock
515
+ NOTE: overrides values in rot parameter
516
+ minLight : scalar, optional
517
+ Sets the minimum lightness value. Defaults to 0.
518
+ maxLight : scalar, optional
519
+ Sets the maximum lightness value. Defaults to 1.
520
+ """
521
+ super(CubeHelixColormap, self).__init__(
522
+ cubehelix(start=start, rot=rot, gamma=gamma, reverse=reverse,
523
+ nlev=nlev, minSat=minSat, maxSat=maxSat,
524
+ minLight=minLight, maxLight=maxLight, **kwargs))
525
+
526
+
527
+ class _Fire(BaseColormap):
528
+ colors = [(1.0, 1.0, 1.0, 1.0),
529
+ (1.0, 1.0, 0.0, 1.0),
530
+ (1.0, 0.0, 0.0, 1.0)]
531
+
532
+ glsl_map = """
533
+ vec4 fire(float t) {
534
+ return mix(mix($color_0, $color_1, t),
535
+ mix($color_1, $color_2, t*t), t);
536
+ }
537
+ """
538
+
539
+ def map(self, t):
540
+ a, b, d = self.colors.rgba
541
+ c = _mix_simple(a, b, t)
542
+ e = _mix_simple(b, d, t**2)
543
+ return _mix_simple(c, e, t)
544
+
545
+
546
+ class _Grays(BaseColormap):
547
+ glsl_map = """
548
+ vec4 grays(float t) {
549
+ return vec4(t, t, t, 1.0);
550
+ }
551
+ """
552
+
553
+ def map(self, t):
554
+ if isinstance(t, np.ndarray):
555
+ return np.hstack([t, t, t, np.ones(t.shape)]).astype(np.float32)
556
+ else:
557
+ return np.array([t, t, t, 1.0], dtype=np.float32)
558
+
559
+
560
+ class _Ice(BaseColormap):
561
+ glsl_map = """
562
+ vec4 ice(float t) {
563
+ return vec4(t, t, 1.0, 1.0);
564
+ }
565
+ """
566
+
567
+ def map(self, t):
568
+ if isinstance(t, np.ndarray):
569
+ return np.hstack([t, t, np.ones(t.shape),
570
+ np.ones(t.shape)]).astype(np.float32)
571
+ else:
572
+ return np.array([t, t, 1.0, 1.0], dtype=np.float32)
573
+
574
+
575
+ class _Hot(BaseColormap):
576
+ colors = [(0., .33, .66, 1.0),
577
+ (.33, .66, 1., 1.0)]
578
+
579
+ glsl_map = """
580
+ vec4 hot(float t) {
581
+ return vec4(smoothstep($color_0.rgb, $color_1.rgb, vec3(t, t, t)),
582
+ 1.0);
583
+ }
584
+ """
585
+
586
+ def map(self, t):
587
+ rgba = self.colors.rgba
588
+ smoothed = smoothstep(rgba[0, :3], rgba[1, :3], t)
589
+ return np.hstack((smoothed, np.ones((len(t), 1))))
590
+
591
+
592
+ class _Winter(BaseColormap):
593
+ colors = [(0.0, 0.0, 1.0, 1.0),
594
+ (0.0, 1.0, 0.5, 1.0)]
595
+
596
+ glsl_map = """
597
+ vec4 winter(float t) {
598
+ return mix($color_0, $color_1, sqrt(t));
599
+ }
600
+ """
601
+
602
+ def map(self, t):
603
+ return _mix_simple(self.colors.rgba[0],
604
+ self.colors.rgba[1],
605
+ np.sqrt(t))
606
+
607
+
608
+ class SingleHue(Colormap):
609
+ """A colormap which is solely defined by the given hue and value.
610
+
611
+ Given the color hue and value, this color map increases the saturation
612
+ of a color. The start color is almost white but still contains a hint of
613
+ the given color, and at the end the color is fully saturated.
614
+
615
+ Parameters
616
+ ----------
617
+ hue : scalar, optional
618
+ The hue refers to a "true" color, without any shading or tinting.
619
+ Must be in the range [0, 360]. Defaults to 200 (blue).
620
+ saturation_range : array-like, optional
621
+ The saturation represents how "pure" a color is. Less saturation means
622
+ more white light mixed in the color. A fully saturated color means
623
+ the pure color defined by the hue. No saturation means completely
624
+ white. This colormap changes the saturation, and with this parameter
625
+ you can specify the lower and upper bound. Default is [0.2, 0.8].
626
+ value : scalar, optional
627
+ The value defines the "brightness" of a color: a value of 0.0 means
628
+ completely black while a value of 1.0 means the color defined by the
629
+ hue without shading. Must be in the range [0, 1.0]. The default value
630
+ is 1.0.
631
+
632
+ Notes
633
+ -----
634
+ For more information about the hue values see the `wikipedia page`_.
635
+
636
+ .. _wikipedia page: https://en.wikipedia.org/wiki/Hue
637
+ """
638
+
639
+ def __init__(self, hue=200, saturation_range=[0.1, 0.8], value=1.0):
640
+ colors = ColorArray([
641
+ (hue, saturation_range[0], value),
642
+ (hue, saturation_range[1], value)
643
+ ], color_space='hsv')
644
+ super(SingleHue, self).__init__(colors)
645
+
646
+
647
+ class HSL(Colormap):
648
+ """A colormap which is defined by n evenly spaced points in a circular color space.
649
+
650
+ This means that we change the hue value while keeping the
651
+ saturation and value constant.
652
+
653
+ Parameters
654
+ ----------
655
+ n_colors : int, optional
656
+ The number of colors to generate.
657
+ hue_start : int, optional
658
+ The hue start value. Must be in the range [0, 360], the default is 0.
659
+ saturation : float, optional
660
+ The saturation component of the colors to generate. The default is
661
+ fully saturated (1.0). Must be in the range [0, 1.0].
662
+ value : float, optional
663
+ The value (brightness) component of the colors to generate. Must
664
+ be in the range [0, 1.0], and the default is 1.0
665
+ controls : array-like, optional
666
+ The list of control points for the colors to generate. It should be
667
+ an increasing list of floating-point number between 0.0 and 1.0.
668
+ The first control point must be 0.0. The last control point must be
669
+ 1.0. The number of control points depends on the interpolation scheme.
670
+ interpolation : str, optional
671
+ The interpolation mode of the colormap. Default: 'linear'. Can also
672
+ be 'zero'.
673
+ If 'linear', ncontrols = ncolors (one color per control point).
674
+ If 'zero', ncontrols = ncolors+1 (one color per bin).
675
+ """
676
+
677
+ def __init__(self, ncolors=6, hue_start=0, saturation=1.0, value=1.0,
678
+ controls=None, interpolation='linear'):
679
+ hues = np.linspace(0, 360, ncolors + 1)[:-1]
680
+ hues += hue_start
681
+ hues %= 360
682
+
683
+ colors = ColorArray([(hue, saturation, value) for hue in hues],
684
+ color_space='hsv')
685
+
686
+ super(HSL, self).__init__(colors, controls=controls,
687
+ interpolation=interpolation)
688
+
689
+
690
+ class HSLuv(Colormap):
691
+ """A colormap which is defined by n evenly spaced points in the HSLuv space.
692
+
693
+ Parameters
694
+ ----------
695
+ n_colors : int, optional
696
+ The number of colors to generate.
697
+ hue_start : int, optional
698
+ The hue start value. Must be in the range [0, 360], the default is 0.
699
+ saturation : float, optional
700
+ The saturation component of the colors to generate. The default is
701
+ fully saturated (1.0). Must be in the range [0, 1.0].
702
+ value : float, optional
703
+ The value component of the colors to generate or "brightness". Must
704
+ be in the range [0, 1.0], and the default is 0.7.
705
+ controls : array-like, optional
706
+ The list of control points for the colors to generate. It should be
707
+ an increasing list of floating-point number between 0.0 and 1.0.
708
+ The first control point must be 0.0. The last control point must be
709
+ 1.0. The number of control points depends on the interpolation scheme.
710
+ interpolation : str, optional
711
+ The interpolation mode of the colormap. Default: 'linear'. Can also
712
+ be 'zero'.
713
+ If 'linear', ncontrols = ncolors (one color per control point).
714
+ If 'zero', ncontrols = ncolors+1 (one color per bin).
715
+
716
+ Notes
717
+ -----
718
+ For more information about HSLuv colors see https://www.hsluv.org/
719
+ """
720
+
721
+ def __init__(self, ncolors=6, hue_start=0, saturation=1.0, value=0.7,
722
+ controls=None, interpolation='linear'):
723
+ hues = np.linspace(0, 360, ncolors + 1)[:-1]
724
+ hues += hue_start
725
+ hues %= 360
726
+
727
+ saturation *= 99
728
+ value *= 99
729
+
730
+ colors = ColorArray(
731
+ [hsluv_to_rgb([hue, saturation, value]) for hue in hues],
732
+ )
733
+
734
+ super(HSLuv, self).__init__(colors, controls=controls,
735
+ interpolation=interpolation)
736
+
737
+
738
+ class _HUSL(HSLuv):
739
+ """Deprecated."""
740
+
741
+ def __init__(self, *args, **kwargs):
742
+ warnings.warn("_HUSL Colormap is deprecated. Please use 'HSLuv' instead.")
743
+ super().__init__(*args, **kwargs)
744
+
745
+
746
+ class Diverging(Colormap):
747
+
748
+ def __init__(self, h_pos=20, h_neg=250, saturation=1.0, value=0.7,
749
+ center="light"):
750
+ saturation *= 99
751
+ value *= 99
752
+
753
+ start = hsluv_to_rgb([h_neg, saturation, value])
754
+ mid = ((0.133, 0.133, 0.133) if center == "dark" else
755
+ (0.92, 0.92, 0.92))
756
+ end = hsluv_to_rgb([h_pos, saturation, value])
757
+
758
+ colors = ColorArray([start, mid, end])
759
+
760
+ super(Diverging, self).__init__(colors)
761
+
762
+
763
+ class RedYellowBlueCyan(Colormap):
764
+ """A colormap which goes red-yellow positive and blue-cyan negative
765
+
766
+ Parameters
767
+ ----------
768
+ limits : array-like, optional
769
+ The limits for the fully transparent, opaque red, and yellow points.
770
+ """
771
+
772
+ def __init__(self, limits=(0.33, 0.66, 1.0)):
773
+ limits = np.array(limits, float).ravel()
774
+ if len(limits) != 3:
775
+ raise ValueError('limits must have 3 values')
776
+ if (np.diff(limits) < 0).any() or (limits <= 0).any():
777
+ raise ValueError('limits must be strictly increasing and positive')
778
+ controls = np.array([-limits[2], -limits[1], -limits[0],
779
+ limits[0], limits[1], limits[2]])
780
+ controls = ((controls / limits[2]) + 1) / 2.
781
+ colors = [(0., 1., 1., 1.), (0., 0., 1., 1.), (0., 0., 1., 0.),
782
+ (1., 0., 0., 0.), (1., 0., 0., 1.), (1., 1., 0., 1.)]
783
+ colors = ColorArray(colors)
784
+ super(RedYellowBlueCyan, self).__init__(
785
+ colors, controls=controls, interpolation='linear')
786
+
787
+
788
+ # https://github.com/matplotlib/matplotlib/pull/4707/files#diff-893cf0348279e9f4570488a7a297ab1eR774 # noqa
789
+ # Taken from original Viridis colormap data in matplotlib implementation
790
+ #
791
+ # Issue #1331 https://github.com/vispy/vispy/issues/1331 explains that the
792
+ # 128 viridis sample size fails on some GPUs
793
+ # but lowering to 64 samples allows more GPUs to use viridis.
794
+ #
795
+ # VisPy has beem updated to use a texture map lookup.
796
+ # Thus, sampling of the Viridis colormap data is no longer necessary.
797
+ _viridis_data = [[0.267004, 0.004874, 0.329415],
798
+ [0.268510, 0.009605, 0.335427],
799
+ [0.269944, 0.014625, 0.341379],
800
+ [0.271305, 0.019942, 0.347269],
801
+ [0.272594, 0.025563, 0.353093],
802
+ [0.273809, 0.031497, 0.358853],
803
+ [0.274952, 0.037752, 0.364543],
804
+ [0.276022, 0.044167, 0.370164],
805
+ [0.277018, 0.050344, 0.375715],
806
+ [0.277941, 0.056324, 0.381191],
807
+ [0.278791, 0.062145, 0.386592],
808
+ [0.279566, 0.067836, 0.391917],
809
+ [0.280267, 0.073417, 0.397163],
810
+ [0.280894, 0.078907, 0.402329],
811
+ [0.281446, 0.084320, 0.407414],
812
+ [0.281924, 0.089666, 0.412415],
813
+ [0.282327, 0.094955, 0.417331],
814
+ [0.282656, 0.100196, 0.422160],
815
+ [0.282910, 0.105393, 0.426902],
816
+ [0.283091, 0.110553, 0.431554],
817
+ [0.283197, 0.115680, 0.436115],
818
+ [0.283229, 0.120777, 0.440584],
819
+ [0.283187, 0.125848, 0.444960],
820
+ [0.283072, 0.130895, 0.449241],
821
+ [0.282884, 0.135920, 0.453427],
822
+ [0.282623, 0.140926, 0.457517],
823
+ [0.282290, 0.145912, 0.461510],
824
+ [0.281887, 0.150881, 0.465405],
825
+ [0.281412, 0.155834, 0.469201],
826
+ [0.280868, 0.160771, 0.472899],
827
+ [0.280255, 0.165693, 0.476498],
828
+ [0.279574, 0.170599, 0.479997],
829
+ [0.278826, 0.175490, 0.483397],
830
+ [0.278012, 0.180367, 0.486697],
831
+ [0.277134, 0.185228, 0.489898],
832
+ [0.276194, 0.190074, 0.493001],
833
+ [0.275191, 0.194905, 0.496005],
834
+ [0.274128, 0.199721, 0.498911],
835
+ [0.273006, 0.204520, 0.501721],
836
+ [0.271828, 0.209303, 0.504434],
837
+ [0.270595, 0.214069, 0.507052],
838
+ [0.269308, 0.218818, 0.509577],
839
+ [0.267968, 0.223549, 0.512008],
840
+ [0.266580, 0.228262, 0.514349],
841
+ [0.265145, 0.232956, 0.516599],
842
+ [0.263663, 0.237631, 0.518762],
843
+ [0.262138, 0.242286, 0.520837],
844
+ [0.260571, 0.246922, 0.522828],
845
+ [0.258965, 0.251537, 0.524736],
846
+ [0.257322, 0.256130, 0.526563],
847
+ [0.255645, 0.260703, 0.528312],
848
+ [0.253935, 0.265254, 0.529983],
849
+ [0.252194, 0.269783, 0.531579],
850
+ [0.250425, 0.274290, 0.533103],
851
+ [0.248629, 0.278775, 0.534556],
852
+ [0.246811, 0.283237, 0.535941],
853
+ [0.244972, 0.287675, 0.537260],
854
+ [0.243113, 0.292092, 0.538516],
855
+ [0.241237, 0.296485, 0.539709],
856
+ [0.239346, 0.300855, 0.540844],
857
+ [0.237441, 0.305202, 0.541921],
858
+ [0.235526, 0.309527, 0.542944],
859
+ [0.233603, 0.313828, 0.543914],
860
+ [0.231674, 0.318106, 0.544834],
861
+ [0.229739, 0.322361, 0.545706],
862
+ [0.227802, 0.326594, 0.546532],
863
+ [0.225863, 0.330805, 0.547314],
864
+ [0.223925, 0.334994, 0.548053],
865
+ [0.221989, 0.339161, 0.548752],
866
+ [0.220057, 0.343307, 0.549413],
867
+ [0.218130, 0.347432, 0.550038],
868
+ [0.216210, 0.351535, 0.550627],
869
+ [0.214298, 0.355619, 0.551184],
870
+ [0.212395, 0.359683, 0.551710],
871
+ [0.210503, 0.363727, 0.552206],
872
+ [0.208623, 0.367752, 0.552675],
873
+ [0.206756, 0.371758, 0.553117],
874
+ [0.204903, 0.375746, 0.553533],
875
+ [0.203063, 0.379716, 0.553925],
876
+ [0.201239, 0.383670, 0.554294],
877
+ [0.199430, 0.387607, 0.554642],
878
+ [0.197636, 0.391528, 0.554969],
879
+ [0.195860, 0.395433, 0.555276],
880
+ [0.194100, 0.399323, 0.555565],
881
+ [0.192357, 0.403199, 0.555836],
882
+ [0.190631, 0.407061, 0.556089],
883
+ [0.188923, 0.410910, 0.556326],
884
+ [0.187231, 0.414746, 0.556547],
885
+ [0.185556, 0.418570, 0.556753],
886
+ [0.183898, 0.422383, 0.556944],
887
+ [0.182256, 0.426184, 0.557120],
888
+ [0.180629, 0.429975, 0.557282],
889
+ [0.179019, 0.433756, 0.557430],
890
+ [0.177423, 0.437527, 0.557565],
891
+ [0.175841, 0.441290, 0.557685],
892
+ [0.174274, 0.445044, 0.557792],
893
+ [0.172719, 0.448791, 0.557885],
894
+ [0.171176, 0.452530, 0.557965],
895
+ [0.169646, 0.456262, 0.558030],
896
+ [0.168126, 0.459988, 0.558082],
897
+ [0.166617, 0.463708, 0.558119],
898
+ [0.165117, 0.467423, 0.558141],
899
+ [0.163625, 0.471133, 0.558148],
900
+ [0.162142, 0.474838, 0.558140],
901
+ [0.160665, 0.478540, 0.558115],
902
+ [0.159194, 0.482237, 0.558073],
903
+ [0.157729, 0.485932, 0.558013],
904
+ [0.156270, 0.489624, 0.557936],
905
+ [0.154815, 0.493313, 0.557840],
906
+ [0.153364, 0.497000, 0.557724],
907
+ [0.151918, 0.500685, 0.557587],
908
+ [0.150476, 0.504369, 0.557430],
909
+ [0.149039, 0.508051, 0.557250],
910
+ [0.147607, 0.511733, 0.557049],
911
+ [0.146180, 0.515413, 0.556823],
912
+ [0.144759, 0.519093, 0.556572],
913
+ [0.143343, 0.522773, 0.556295],
914
+ [0.141935, 0.526453, 0.555991],
915
+ [0.140536, 0.530132, 0.555659],
916
+ [0.139147, 0.533812, 0.555298],
917
+ [0.137770, 0.537492, 0.554906],
918
+ [0.136408, 0.541173, 0.554483],
919
+ [0.135066, 0.544853, 0.554029],
920
+ [0.133743, 0.548535, 0.553541],
921
+ [0.132444, 0.552216, 0.553018],
922
+ [0.131172, 0.555899, 0.552459],
923
+ [0.129933, 0.559582, 0.551864],
924
+ [0.128729, 0.563265, 0.551229],
925
+ [0.127568, 0.566949, 0.550556],
926
+ [0.126453, 0.570633, 0.549841],
927
+ [0.125394, 0.574318, 0.549086],
928
+ [0.124395, 0.578002, 0.548287],
929
+ [0.123463, 0.581687, 0.547445],
930
+ [0.122606, 0.585371, 0.546557],
931
+ [0.121831, 0.589055, 0.545623],
932
+ [0.121148, 0.592739, 0.544641],
933
+ [0.120565, 0.596422, 0.543611],
934
+ [0.120092, 0.600104, 0.542530],
935
+ [0.119738, 0.603785, 0.541400],
936
+ [0.119512, 0.607464, 0.540218],
937
+ [0.119423, 0.611141, 0.538982],
938
+ [0.119483, 0.614817, 0.537692],
939
+ [0.119699, 0.618490, 0.536347],
940
+ [0.120081, 0.622161, 0.534946],
941
+ [0.120638, 0.625828, 0.533488],
942
+ [0.121380, 0.629492, 0.531973],
943
+ [0.122312, 0.633153, 0.530398],
944
+ [0.123444, 0.636809, 0.528763],
945
+ [0.124780, 0.640461, 0.527068],
946
+ [0.126326, 0.644107, 0.525311],
947
+ [0.128087, 0.647749, 0.523491],
948
+ [0.130067, 0.651384, 0.521608],
949
+ [0.132268, 0.655014, 0.519661],
950
+ [0.134692, 0.658636, 0.517649],
951
+ [0.137339, 0.662252, 0.515571],
952
+ [0.140210, 0.665859, 0.513427],
953
+ [0.143303, 0.669459, 0.511215],
954
+ [0.146616, 0.673050, 0.508936],
955
+ [0.150148, 0.676631, 0.506589],
956
+ [0.153894, 0.680203, 0.504172],
957
+ [0.157851, 0.683765, 0.501686],
958
+ [0.162016, 0.687316, 0.499129],
959
+ [0.166383, 0.690856, 0.496502],
960
+ [0.170948, 0.694384, 0.493803],
961
+ [0.175707, 0.697900, 0.491033],
962
+ [0.180653, 0.701402, 0.488189],
963
+ [0.185783, 0.704891, 0.485273],
964
+ [0.191090, 0.708366, 0.482284],
965
+ [0.196571, 0.711827, 0.479221],
966
+ [0.202219, 0.715272, 0.476084],
967
+ [0.208030, 0.718701, 0.472873],
968
+ [0.214000, 0.722114, 0.469588],
969
+ [0.220124, 0.725509, 0.466226],
970
+ [0.226397, 0.728888, 0.462789],
971
+ [0.232815, 0.732247, 0.459277],
972
+ [0.239374, 0.735588, 0.455688],
973
+ [0.246070, 0.738910, 0.452024],
974
+ [0.252899, 0.742211, 0.448284],
975
+ [0.259857, 0.745492, 0.444467],
976
+ [0.266941, 0.748751, 0.440573],
977
+ [0.274149, 0.751988, 0.436601],
978
+ [0.281477, 0.755203, 0.432552],
979
+ [0.288921, 0.758394, 0.428426],
980
+ [0.296479, 0.761561, 0.424223],
981
+ [0.304148, 0.764704, 0.419943],
982
+ [0.311925, 0.767822, 0.415586],
983
+ [0.319809, 0.770914, 0.411152],
984
+ [0.327796, 0.773980, 0.406640],
985
+ [0.335885, 0.777018, 0.402049],
986
+ [0.344074, 0.780029, 0.397381],
987
+ [0.352360, 0.783011, 0.392636],
988
+ [0.360741, 0.785964, 0.387814],
989
+ [0.369214, 0.788888, 0.382914],
990
+ [0.377779, 0.791781, 0.377939],
991
+ [0.386433, 0.794644, 0.372886],
992
+ [0.395174, 0.797475, 0.367757],
993
+ [0.404001, 0.800275, 0.362552],
994
+ [0.412913, 0.803041, 0.357269],
995
+ [0.421908, 0.805774, 0.351910],
996
+ [0.430983, 0.808473, 0.346476],
997
+ [0.440137, 0.811138, 0.340967],
998
+ [0.449368, 0.813768, 0.335384],
999
+ [0.458674, 0.816363, 0.329727],
1000
+ [0.468053, 0.818921, 0.323998],
1001
+ [0.477504, 0.821444, 0.318195],
1002
+ [0.487026, 0.823929, 0.312321],
1003
+ [0.496615, 0.826376, 0.306377],
1004
+ [0.506271, 0.828786, 0.300362],
1005
+ [0.515992, 0.831158, 0.294279],
1006
+ [0.525776, 0.833491, 0.288127],
1007
+ [0.535621, 0.835785, 0.281908],
1008
+ [0.545524, 0.838039, 0.275626],
1009
+ [0.555484, 0.840254, 0.269281],
1010
+ [0.565498, 0.842430, 0.262877],
1011
+ [0.575563, 0.844566, 0.256415],
1012
+ [0.585678, 0.846661, 0.249897],
1013
+ [0.595839, 0.848717, 0.243329],
1014
+ [0.606045, 0.850733, 0.236712],
1015
+ [0.616293, 0.852709, 0.230052],
1016
+ [0.626579, 0.854645, 0.223353],
1017
+ [0.636902, 0.856542, 0.216620],
1018
+ [0.647257, 0.858400, 0.209861],
1019
+ [0.657642, 0.860219, 0.203082],
1020
+ [0.668054, 0.861999, 0.196293],
1021
+ [0.678489, 0.863742, 0.189503],
1022
+ [0.688944, 0.865448, 0.182725],
1023
+ [0.699415, 0.867117, 0.175971],
1024
+ [0.709898, 0.868751, 0.169257],
1025
+ [0.720391, 0.870350, 0.162603],
1026
+ [0.730889, 0.871916, 0.156029],
1027
+ [0.741388, 0.873449, 0.149561],
1028
+ [0.751884, 0.874951, 0.143228],
1029
+ [0.762373, 0.876424, 0.137064],
1030
+ [0.772852, 0.877868, 0.131109],
1031
+ [0.783315, 0.879285, 0.125405],
1032
+ [0.793760, 0.880678, 0.120005],
1033
+ [0.804182, 0.882046, 0.114965],
1034
+ [0.814576, 0.883393, 0.110347],
1035
+ [0.824940, 0.884720, 0.106217],
1036
+ [0.835270, 0.886029, 0.102646],
1037
+ [0.845561, 0.887322, 0.099702],
1038
+ [0.855810, 0.888601, 0.097452],
1039
+ [0.866013, 0.889868, 0.095953],
1040
+ [0.876168, 0.891125, 0.095250],
1041
+ [0.886271, 0.892374, 0.095374],
1042
+ [0.896320, 0.893616, 0.096335],
1043
+ [0.906311, 0.894855, 0.098125],
1044
+ [0.916242, 0.896091, 0.100717],
1045
+ [0.926106, 0.897330, 0.104071],
1046
+ [0.935904, 0.898570, 0.108131],
1047
+ [0.945636, 0.899815, 0.112838],
1048
+ [0.955300, 0.901065, 0.118128],
1049
+ [0.964894, 0.902323, 0.123941],
1050
+ [0.974417, 0.903590, 0.130215],
1051
+ [0.983868, 0.904867, 0.136897],
1052
+ [0.993248, 0.906157, 0.143936]]
1053
+
1054
+
1055
+ _colormaps = dict(
1056
+ # Some colormap presets
1057
+ autumn=Colormap([(1., 0., 0., 1.), (1., 1., 0., 1.)]),
1058
+ blues=Colormap([(1., 1., 1., 1.), (0., 0., 1., 1.)]),
1059
+ cool=Colormap([(0., 1., 1., 1.), (1., 0., 1., 1.)]),
1060
+ greens=Colormap([(1., 1., 1., 1.), (0., 1., 0., 1.)]),
1061
+ reds=Colormap([(1., 1., 1., 1.), (1., 0., 0., 1.)]),
1062
+ spring=Colormap([(1., 0., 1., 1.), (1., 1., 0., 1.)]),
1063
+ summer=Colormap([(0., .5, .4, 1.), (1., 1., .4, 1.)]),
1064
+ fire=_Fire(),
1065
+ grays=_Grays(),
1066
+ hot=_Hot(),
1067
+ ice=_Ice(),
1068
+ winter=_Winter(),
1069
+ light_blues=SingleHue(),
1070
+ orange=SingleHue(hue=35),
1071
+ viridis=Colormap(ColorArray(_viridis_data)),
1072
+ # Diverging presets
1073
+ coolwarm=Colormap(ColorArray(
1074
+ [
1075
+ (226, 0.59, 0.92), (222, 0.44, 0.99), (218, 0.26, 0.97),
1076
+ (30, 0.01, 0.87),
1077
+ (20, 0.3, 0.96), (15, 0.5, 0.95), (8, 0.66, 0.86)
1078
+ ],
1079
+ color_space="hsv"
1080
+ )),
1081
+ PuGr=Diverging(145, 280, 0.85, 0.30),
1082
+ GrBu=Diverging(255, 133, 0.75, 0.6),
1083
+ GrBu_d=Diverging(255, 133, 0.75, 0.6, "dark"),
1084
+ RdBu=Diverging(220, 20, 0.75, 0.5),
1085
+
1086
+ cubehelix=CubeHelixColormap(),
1087
+ single_hue=SingleHue(),
1088
+ hsl=HSL(),
1089
+ husl=HSLuv(),
1090
+ diverging=Diverging(),
1091
+ RdYeBuCy=RedYellowBlueCyan(),
1092
+ )
1093
+
1094
+
1095
+ def get_colormap(name):
1096
+ """Obtain a colormap by name.
1097
+
1098
+ Parameters
1099
+ ----------
1100
+ name : str | Colormap
1101
+ Colormap name. Can also be a Colormap for pass-through.
1102
+
1103
+ Examples
1104
+ --------
1105
+ >>> get_colormap('autumn')
1106
+ >>> get_colormap('single_hue')
1107
+
1108
+ .. versionchanged: 0.7
1109
+
1110
+ Additional args/kwargs are no longer accepted. Colormap instances are
1111
+ no longer created on the fly.
1112
+
1113
+ """
1114
+ if isinstance(name, BaseColormap):
1115
+ return name
1116
+
1117
+ if not isinstance(name, str):
1118
+ raise TypeError('colormap must be a Colormap or string name')
1119
+ if name in _colormaps: # vispy cmap
1120
+ cmap = _colormaps[name]
1121
+
1122
+ elif has_matplotlib(): # matplotlib cmap
1123
+ try:
1124
+ cmap = MatplotlibColormap(name)
1125
+ except ValueError:
1126
+ raise KeyError('colormap name %s not found' % name)
1127
+ else:
1128
+ raise KeyError('colormap name %s not found' % name)
1129
+ return cmap
1130
+
1131
+
1132
+ def get_colormaps():
1133
+ """Return the list of colormap names."""
1134
+ return _colormaps.copy()