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