Color scales in Python for humans

Overview

colorlover

Color scales for humans

IPython notebook: https://plot.ly/ipython-notebooks/color-scales/

import colorlover as cl
from IPython.display import HTML
HTML(cl.to_html( cl.flipper()['seq']['3'] ))

alt tag

Install

sudo pip install colorlover

IPython notebook (demo)

https://plot.ly/ipython-notebooks/color-scales/

Docs

cl.scales

All of the color scales in colorlover

>>> import colorlover as cl
>>> cl.scales['3']['div']['RdYlBu']

['rgb(252,141,89)', 'rgb(255,255,191)', 'rgb(145,191,219)']

cl.to_numeric( scale )

Converts scale of RGB or HSL strings to list of tuples with RGB integer values

>>> cl.to_numeric( cl.scales['3']['div']['RdYlBu'] )

[(252.0, 141.0, 89.0), (255.0, 255.0, 191.0), (145.0, 191.0, 219.0)]

cl.to_hsl( scale )

Converts a string RGB or numeric RGB colorscale to HSL

>>> cl.to_hsl( cl.scales['3']['div']['RdYlBu'] )

['hsl(19.0, 96.0%, 67.0%)', 'hsl(60.0, 100.0%, 87.0%)', 'hsl(203.0, 51.0%, 71.0%)']

cl.to_rgb( scale )

Convert an HSL or numeric RGB color scale to string RGB color scale

>>> cl.to_rgb( cl.scales['3']['div']['RdYlBu'] )

['rgb(252,141,89)', 'rgb(255,255,191)', 'rgb(145,191,219)']

cl.to_html( scale )

Traverse color scale dictionary and return available color scales as HTML string

'">
>>> cl.to_html( cl.scales['3']['div']['RdYlBu'] )

'
  
'

cl.flipper( scale=None )

Return the inverse of the color scale dictionary cl.scale

>>> cl.flipper()['div']['3']['RdYlBu']

['rgb(252,141,89)', 'rgb(255,255,191)', 'rgb(145,191,219)']

cl.interp( scale, r )

def interp(scl, r):

Interpolate a color scale "scale" to a new one with length "r"

# fun usage in IPython notebook
from IPython.display import HTML
HTML( to_html( to_hsl( interp( cl.scales['11']['qual']['Paired'], 5000 ) ) ) )

All colors in cl.scales

# (in IPython notebook)
from IPython.display import HTML
HTML(cl.to_html( cl.scales ))
Comments
  • cl.interp throwing

    cl.interp throwing "IndexError: list index out of range"

    Trying to use cl.interp function. It throws an IndexError depending on the length of the new color list. Steps to reproduce:

    >>> colors = ['rgb(27,158,119)',
     'rgb(217,95,2)',
     'rgb(117,112,179)',
     'rgb(231,41,138)',
     'rgb(102,166,30)',
     'rgb(230,171,2)',
     'rgb(166,118,29)']
    >>> works = cl.interp(colors, 10)
    >>> fails = cl.interp(colors, 11)
    /usr/local/lib/python2.7/dist-packages/colorlover/__init__.pyc in interp(scl, r)
       1821         c_i = int(i*math.floor(SCL_FI)/round(r[-1])) # start color index
       1822         hsl_o = rgb_to_hsl( scl[c_i] ) # convert rgb to hls
    -> 1823         hsl_f = rgb_to_hsl( scl[c_i+1] )
       1824         section_min = c_i*r[-1]/SCL_FI
       1825         section_max = (c_i+1)*(r[-1]/SCL_FI)
    
    IndexError: list index out of range
    

    The problem is that c_i can round to len(scl)-1 depending on the length of r, hence scl[c_i+1] will end up being out of bounds. A naive solution would imply checking for that specific corner case (I'm sure there's a more elegant way though).

    opened by spalaciob 8
  • Interpolation bug

    Interpolation bug

    cl.interp(cl.scales['9']['seq']['Reds'], 100) #Works
    cl.interp(cl.scales['9']['seq']['Reds'], 101) #Exception
    cl.interp(cl.scales['9']['seq']['Reds'], 110) #Works
    

    I don't see why this should happen.

    opened by rohan-shah 4
  • Avoid negative HSL angle values

    Avoid negative HSL angle values

    See https://github.com/plotly/plotly.py/issues/1212

    Though it is technically valid (https://www.w3.org/wiki/CSS3/Color/HSL), it would be helpful if colorlover didn't produce HSL color values with negative angles (e.g. 'hsl(-5, 37%, 73%)'), but instead wrapped these angles into the interval [0, 360] (e.g. 'hsl(355, 37%, 73%)' in the case above). These negative HSL values are not supported by the tinycolor2 library that Plotly.js relies on for color handling. See https://github.com/plotly/plotly.py/issues/1212#issuecomment-426981965 for more details.

    Here's an example that produces negative hsl angle values

    import colorlover as cl
    markercl = cl.scales['11']['qual']['Paired']
    cl.interp(markercl, 16)
    
    ['hsl(76.0, 52.0%, 77.0%)',
     'hsl(157.33333333333334, 64.0%, 53.0%)',
     'hsl(162.33333333333331, 65.66666666666666%, 50.66666666666667%)',
     'hsl(90.99999999999996, 56.99999999999999%, 70.00000000000001%)',
     'hsl(107.66666666666669, 56.333333333333336%, 49.999999999999986%)',
     'hsl(124.33333333333334, 55.666666666666664%, 29.999999999999986%)',
     'hsl(-7.105427357601002e-14, 92.00000000000003%, 79.00000000000003%)',
     'hsl(-77.33333333333343, 116.00000000000003%, 105.00000000000003%)',
     'hsl(478.66666666666674, 74.66666666666666%, 38.99999999999999%)',
     'hsl(718.0, 66.0%, 19.0%)',
     'hsl(-184.3333333333336, 109.00000000000001%, 85.66666666666669%)',
     'hsl(-401.6666666666673, 121.00000000000003%, 100.33333333333337%)',
     'hsl(24.999999999999996, 103.0%, 28.99999999999998%)',
     'hsl(22.333333333333336, 105.0%, 15.0%)',
     'hsl(-59.66666666666674, -63.33333333333346%, 110.66666666666671%)',
     'hsl(-85.00000000000006, -110.00000000000009%, 128.00000000000003%)']
    
    opened by jonmmease 2
  • List index out of range in call to interp with certain bin counts

    List index out of range in call to interp with certain bin counts

    When trying to interpolate a 9-color divergent ramp to 32 bins, I noticed a 'list index out of range' error being thrown on line 1823 of init.py. Intrigued, I ran a loop to see which bin counts worked and which didn't. Those results are posted in the space below.

    If this is an expected behavior, a better error message should be thrown. If this is a bug, it will need to be investigated.

    Error message:

    yc in interp(scl, r)
        1821         c_i = int(i*math.floor(SCL_FI)/round(r[-1])) # start color index
        1822         hsl_o = rgb_to_hsl( scl[c_i] ) # convert rgb to hls
     -> 1823         hsl_f = rgb_to_hsl( scl[c_i+1] )
        1824         section_min = c_i*r[-1]/SCL_FI
        1825         section_max = (c_i+1)*(r[-1]/SCL_FI)
    

    Test code:

    for i in xrange(1, 1000):
        try:
            scale = cl.interp(cl.scales["9"]["div"]["RdBu"], i)
        except:
            print "{0}. Failed".format(i)
        else:
            print "{0}. Passed".format(i)
    
    1. Failed
    2. Failed
    3. Failed
    4. Failed
    5. Failed
    6. Passed
    7. Passed
    8. Passed
    9. Passed
    10. Passed
    11. Failed
    12. Failed
    13. Failed
    14. Failed
    15. Failed
    16. Passed
    17. Passed
    18. Passed
    19. Passed
    20. Passed
    21. Failed
    22. Failed
    23. Failed
    24. Failed
    25. Failed
    26. Passed
    27. Passed
    28. Passed
    29. Passed
    30. Passed
    31. Failed
    32. Failed
    33. Failed
    34. Failed
    35. Failed
    36. Passed
    37. Passed
    38. Passed
    39. Passed
    40. Passed
    41. Failed
    42. Failed
    43. Failed
    44. Failed
    45. Failed
    46. Passed
    47. Passed
    48. Passed
    49. Passed
    50. Passed
    51. Failed
    52. Failed
    53. Failed
    54. Failed
    55. Failed
    56. Passed
    57. Passed
    58. Passed
    59. Passed
    60. Passed
    61. Failed
    62. Failed
    63. Failed
    64. Failed
    65. Failed
    66. Passed
    67. Passed
    68. Passed
    69. Passed
    70. Passed
    71. Failed
    72. Failed
    73. Failed
    74. Failed
    75. Failed
    76. Passed
    77. Passed
    78. Passed
    79. Passed
    80. Passed
    81. Failed
    82. Failed
    83. Failed
    84. Failed
    85. Failed
    86. Passed
    87. Passed
    88. Passed
    89. Passed
    90. Passed
    91. Failed
    92. Failed
    93. Failed
    94. Failed
    95. Failed
    96. Passed
    97. Passed
    98. Passed
    99. Passed
    100. Passed
    101. Failed
    102. Failed
    103. Failed
    104. Failed
    105. Failed
    106. Passed
    107. Passed
    108. Passed
    109. Passed
    110. Passed
    111. Failed
    112. Failed
    113. Failed
    114. Failed
    115. Failed
    116. Passed
    117. Passed
    118. Passed
    119. Passed
    120. Passed
    121. Failed
    122. Failed
    123. Failed
    124. Failed
    125. Failed
    126. Passed
    127. Passed
    128. Passed
    129. Passed
    130. Passed
    131. Failed
    132. Failed
    133. Failed
    134. Failed
    135. Failed
    136. Passed
    137. Passed
    138. Passed
    139. Passed
    140. Passed
    141. Failed
    142. Failed
    143. Failed
    144. Failed
    145. Failed
    146. Passed
    147. Passed
    148. Passed
    149. Passed
    150. Passed
    151. Failed
    152. Failed
    153. Failed
    154. Failed
    155. Failed
    156. Passed
    157. Passed
    158. Passed
    159. Passed
    160. Passed
    161. Failed
    162. Failed
    163. Failed
    164. Failed
    165. Failed
    166. Passed
    167. Passed
    168. Passed
    169. Passed
    170. Passed
    171. Failed
    172. Failed
    173. Failed
    174. Failed
    175. Failed
    176. Passed
    177. Passed
    178. Passed
    179. Passed
    180. Passed
    181. Failed
    182. Failed
    183. Failed
    184. Failed
    185. Failed
    186. Passed
    187. Passed
    188. Passed
    189. Passed
    190. Passed
    191. Failed
    192. Failed
    193. Failed
    194. Failed
    195. Failed
    196. Passed
    197. Passed
    198. Passed
    199. Passed
    200. Passed
    201. Failed
    202. Failed
    203. Failed
    204. Failed
    205. Failed
    206. Passed
    207. Passed
    208. Passed
    209. Passed
    210. Passed
    211. Failed
    212. Failed
    213. Failed
    214. Failed
    215. Failed
    216. Passed
    217. Passed
    218. Passed
    219. Passed
    220. Passed
    221. Failed
    222. Failed
    223. Failed
    224. Failed
    225. Failed
    226. Passed
    227. Passed
    228. Passed
    229. Passed
    230. Passed
    231. Failed
    232. Failed
    233. Failed
    234. Failed
    235. Failed
    236. Passed
    237. Passed
    238. Passed
    239. Passed
    240. Passed
    241. Failed
    242. Failed
    243. Failed
    244. Failed
    245. Failed
    246. Passed
    247. Passed
    248. Passed
    249. Passed
    250. Passed
    251. Failed
    252. Failed
    253. Failed
    254. Failed
    255. Failed
    256. Passed
    257. Passed
    258. Passed
    259. Passed
    260. Passed
    261. Failed
    262. Failed
    263. Failed
    264. Failed
    265. Failed
    266. Passed
    267. Passed
    268. Passed
    269. Passed
    270. Passed
    271. Failed
    272. Failed
    273. Failed
    274. Failed
    275. Failed
    276. Passed
    277. Passed
    278. Passed
    279. Passed
    280. Passed
    281. Failed
    282. Failed
    283. Failed
    284. Failed
    285. Failed
    286. Passed
    287. Passed
    288. Passed
    289. Passed
    290. Passed
    291. Failed
    292. Failed
    293. Failed
    294. Failed
    295. Failed
    296. Passed
    297. Passed
    298. Passed
    299. Passed
    300. Passed
    301. Failed
    302. Failed
    303. Failed
    304. Failed
    305. Failed
    306. Passed
    307. Passed
    308. Passed
    309. Passed
    310. Passed
    311. Failed
    312. Failed
    313. Failed
    314. Failed
    315. Failed
    316. Passed
    317. Passed
    318. Passed
    319. Passed
    320. Passed
    321. Failed
    322. Failed
    323. Failed
    324. Failed
    325. Failed
    326. Passed
    327. Passed
    328. Passed
    329. Passed
    330. Passed
    331. Failed
    332. Failed
    333. Failed
    334. Failed
    335. Failed
    336. Passed
    337. Passed
    338. Passed
    339. Passed
    340. Passed
    341. Failed
    342. Failed
    343. Failed
    344. Failed
    345. Failed
    346. Passed
    347. Passed
    348. Passed
    349. Passed
    350. Passed
    351. Failed
    352. Failed
    353. Failed
    354. Failed
    355. Failed
    356. Passed
    357. Passed
    358. Passed
    359. Passed
    360. Passed
    361. Failed
    362. Failed
    363. Failed
    364. Failed
    365. Failed
    366. Passed
    367. Passed
    368. Passed
    369. Passed
    370. Passed
    371. Failed
    372. Failed
    373. Failed
    374. Failed
    375. Failed
    376. Passed
    377. Passed
    378. Passed
    379. Passed
    380. Passed
    381. Failed
    382. Failed
    383. Failed
    384. Failed
    385. Failed
    386. Passed
    387. Passed
    388. Passed
    389. Passed
    390. Passed
    391. Failed
    392. Failed
    393. Failed
    394. Failed
    395. Failed
    396. Passed
    397. Passed
    398. Passed
    399. Passed
    400. Passed
    401. Failed
    402. Failed
    403. Failed
    404. Failed
    405. Failed
    406. Passed
    407. Passed
    408. Passed
    409. Passed
    410. Passed
    411. Failed
    412. Failed
    413. Failed
    414. Failed
    415. Failed
    416. Passed
    417. Passed
    418. Passed
    419. Passed
    420. Passed
    421. Failed
    422. Failed
    423. Failed
    424. Failed
    425. Failed
    426. Passed
    427. Passed
    428. Passed
    429. Passed
    430. Passed
    431. Failed
    432. Failed
    433. Failed
    434. Failed
    435. Failed
    436. Passed
    437. Passed
    438. Passed
    439. Passed
    440. Passed
    441. Failed
    442. Failed
    443. Failed
    444. Failed
    445. Failed
    446. Passed
    447. Passed
    448. Passed
    449. Passed
    450. Passed
    451. Failed
    452. Failed
    453. Failed
    454. Failed
    455. Failed
    456. Passed
    457. Passed
    458. Passed
    459. Passed
    460. Passed
    461. Failed
    462. Failed
    463. Failed
    464. Failed
    465. Failed
    466. Passed
    467. Passed
    468. Passed
    469. Passed
    470. Passed
    471. Failed
    472. Failed
    473. Failed
    474. Failed
    475. Failed
    476. Passed
    477. Passed
    478. Passed
    479. Passed
    480. Passed
    481. Failed
    482. Failed
    483. Failed
    484. Failed
    485. Failed
    486. Passed
    487. Passed
    488. Passed
    489. Passed
    490. Passed
    491. Failed
    492. Failed
    493. Failed
    494. Failed
    495. Failed
    496. Passed
    497. Passed
    498. Passed
    499. Passed
    500. Passed
    501. Failed
    502. Failed
    503. Failed
    504. Failed
    505. Failed
    506. Passed
    507. Passed
    508. Passed
    509. Passed
    510. Passed
    511. Failed
    512. Failed
    513. Failed
    514. Failed
    515. Failed
    516. Passed
    517. Passed
    518. Passed
    519. Passed
    520. Passed
    521. Failed
    522. Failed
    523. Failed
    524. Failed
    525. Failed
    526. Passed
    527. Passed
    528. Passed
    529. Passed
    530. Passed
    531. Failed
    532. Failed
    533. Failed
    534. Failed
    535. Failed
    536. Passed
    537. Passed
    538. Passed
    539. Passed
    540. Passed
    541. Failed
    542. Failed
    543. Failed
    544. Failed
    545. Failed
    546. Passed
    547. Passed
    548. Passed
    549. Passed
    550. Passed
    551. Failed
    552. Failed
    553. Failed
    554. Failed
    555. Failed
    556. Passed
    557. Passed
    558. Passed
    559. Passed
    560. Passed
    561. Failed
    562. Failed
    563. Failed
    564. Failed
    565. Failed
    566. Passed
    567. Passed
    568. Passed
    569. Passed
    570. Passed
    571. Failed
    572. Failed
    573. Failed
    574. Failed
    575. Failed
    576. Passed
    577. Passed
    578. Passed
    579. Passed
    580. Passed
    581. Failed
    582. Failed
    583. Failed
    584. Failed
    585. Failed
    586. Passed
    587. Passed
    588. Passed
    589. Passed
    590. Passed
    591. Failed
    592. Failed
    593. Failed
    594. Failed
    595. Failed
    596. Passed
    597. Passed
    598. Passed
    599. Passed
    600. Passed
    601. Failed
    602. Failed
    603. Failed
    604. Failed
    605. Failed
    606. Passed
    607. Passed
    608. Passed
    609. Passed
    610. Passed
    611. Failed
    612. Failed
    613. Failed
    614. Failed
    615. Failed
    616. Passed
    617. Passed
    618. Passed
    619. Passed
    620. Passed
    621. Failed
    622. Failed
    623. Failed
    624. Failed
    625. Failed
    626. Passed
    627. Passed
    628. Passed
    629. Passed
    630. Passed
    631. Failed
    632. Failed
    633. Failed
    634. Failed
    635. Failed
    636. Passed
    637. Passed
    638. Passed
    639. Passed
    640. Passed
    641. Failed
    642. Failed
    643. Failed
    644. Failed
    645. Failed
    646. Passed
    647. Passed
    648. Passed
    649. Passed
    650. Passed
    651. Failed
    652. Failed
    653. Failed
    654. Failed
    655. Failed
    656. Passed
    657. Passed
    658. Passed
    659. Passed
    660. Passed
    661. Failed
    662. Failed
    663. Failed
    664. Failed
    665. Failed
    666. Passed
    667. Passed
    668. Passed
    669. Passed
    670. Passed
    671. Failed
    672. Failed
    673. Failed
    674. Failed
    675. Failed
    676. Passed
    677. Passed
    678. Passed
    679. Passed
    680. Passed
    681. Failed
    682. Failed
    683. Failed
    684. Failed
    685. Failed
    686. Passed
    687. Passed
    688. Passed
    689. Passed
    690. Passed
    691. Failed
    692. Failed
    693. Failed
    694. Failed
    695. Failed
    696. Passed
    697. Passed
    698. Passed
    699. Passed
    700. Passed
    701. Failed
    702. Failed
    703. Failed
    704. Failed
    705. Failed
    706. Passed
    707. Passed
    708. Passed
    709. Passed
    710. Passed
    711. Failed
    712. Failed
    713. Failed
    714. Failed
    715. Failed
    716. Passed
    717. Passed
    718. Passed
    719. Passed
    720. Passed
    721. Failed
    722. Failed
    723. Failed
    724. Failed
    725. Failed
    726. Passed
    727. Passed
    728. Passed
    729. Passed
    730. Passed
    731. Failed
    732. Failed
    733. Failed
    734. Failed
    735. Failed
    736. Passed
    737. Passed
    738. Passed
    739. Passed
    740. Passed
    741. Failed
    742. Failed
    743. Failed
    744. Failed
    745. Failed
    746. Passed
    747. Passed
    748. Passed
    749. Passed
    750. Passed
    751. Failed
    752. Failed
    753. Failed
    754. Failed
    755. Failed
    756. Passed
    757. Passed
    758. Passed
    759. Passed
    760. Passed
    761. Failed
    762. Failed
    763. Failed
    764. Failed
    765. Failed
    766. Passed
    767. Passed
    768. Passed
    769. Passed
    770. Passed
    771. Failed
    772. Failed
    773. Failed
    774. Failed
    775. Failed
    776. Passed
    777. Passed
    778. Passed
    779. Passed
    780. Passed
    781. Failed
    782. Failed
    783. Failed
    784. Failed
    785. Failed
    786. Passed
    787. Passed
    788. Passed
    789. Passed
    790. Passed
    791. Failed
    792. Failed
    793. Failed
    794. Failed
    795. Failed
    796. Passed
    797. Passed
    798. Passed
    799. Passed
    800. Passed
    801. Failed
    802. Failed
    803. Failed
    804. Failed
    805. Failed
    806. Passed
    807. Passed
    808. Passed
    809. Passed
    810. Passed
    811. Failed
    812. Failed
    813. Failed
    814. Failed
    815. Failed
    816. Passed
    817. Passed
    818. Passed
    819. Passed
    820. Passed
    821. Failed
    822. Failed
    823. Failed
    824. Failed
    825. Failed
    826. Passed
    827. Passed
    828. Passed
    829. Passed
    830. Passed
    831. Failed
    832. Failed
    833. Failed
    834. Failed
    835. Failed
    836. Passed
    837. Passed
    838. Passed
    839. Passed
    840. Passed
    841. Failed
    842. Failed
    843. Failed
    844. Failed
    845. Failed
    846. Passed
    847. Passed
    848. Passed
    849. Passed
    850. Passed
    851. Failed
    852. Failed
    853. Failed
    854. Failed
    855. Failed
    856. Passed
    857. Passed
    858. Passed
    859. Passed
    860. Passed
    861. Failed
    862. Failed
    863. Failed
    864. Failed
    865. Failed
    866. Passed
    867. Passed
    868. Passed
    869. Passed
    870. Passed
    871. Failed
    872. Failed
    873. Failed
    874. Failed
    875. Failed
    876. Passed
    877. Passed
    878. Passed
    879. Passed
    880. Passed
    881. Failed
    882. Failed
    883. Failed
    884. Failed
    885. Failed
    886. Passed
    887. Passed
    888. Passed
    889. Passed
    890. Passed
    891. Failed
    892. Failed
    893. Failed
    894. Failed
    895. Failed
    896. Passed
    897. Passed
    898. Passed
    899. Passed
    900. Passed
    901. Failed
    902. Failed
    903. Failed
    904. Failed
    905. Failed
    906. Passed
    907. Passed
    908. Passed
    909. Passed
    910. Passed
    911. Failed
    912. Failed
    913. Failed
    914. Failed
    915. Failed
    916. Passed
    917. Passed
    918. Passed
    919. Passed
    920. Passed
    921. Failed
    922. Failed
    923. Failed
    924. Failed
    925. Failed
    926. Passed
    927. Passed
    928. Passed
    929. Passed
    930. Passed
    931. Failed
    932. Failed
    933. Failed
    934. Failed
    935. Failed
    936. Passed
    937. Passed
    938. Passed
    939. Passed
    940. Passed
    941. Failed
    942. Failed
    943. Failed
    944. Failed
    945. Failed
    946. Passed
    947. Passed
    948. Passed
    949. Passed
    950. Passed
    951. Failed
    952. Failed
    953. Failed
    954. Failed
    955. Failed
    956. Passed
    957. Passed
    958. Passed
    959. Passed
    960. Passed
    961. Failed
    962. Failed
    963. Failed
    964. Failed
    965. Failed
    966. Passed
    967. Passed
    968. Passed
    969. Passed
    970. Passed
    971. Failed
    972. Failed
    973. Failed
    974. Failed
    975. Failed
    976. Passed
    977. Passed
    978. Passed
    979. Passed
    980. Passed
    981. Failed
    982. Failed
    983. Failed
    984. Failed
    985. Failed
    986. Passed
    987. Passed
    988. Passed
    989. Passed
    990. Passed
    991. Failed
    992. Failed
    993. Failed
    994. Failed
    995. Failed
    996. Passed
    997. Passed
    998. Passed
    999. Passed
    
    opened by warpedgeoid 2
  • divid by 0 in interp()

    divid by 0 in interp()

    The following code

    import colorlover as cl
    cl.interp( cl.scales['3']['div']['RdYlBu'], 5) 
    

    generates:

    ---------------------------------------------------------------------------
    ZeroDivisionError                         Traceback (most recent call last)
    <ipython-input-8-14a39fa30bf3> in <module>()
          1 import colorlover as cl
    ----> 2 cl.interp( cl.scales['3']['div']['RdYlBu'], 5)
    
    /Users/garyfeng/anaconda/lib/python2.7/site-packages/colorlover/__init__.py in interp(scl, r)
       1821         # garyfeng: c_i could be rounded up so scl[c_i+1] will go off range
       1822         #c_i = int(i*math.floor(SCL_FI)/round(r[-1])) # start color index
    -> 1823         c_i = int(math.floor(i*math.floor(SCL_FI)/round(r[-1]))) # start color index
       1824         hsl_o = rgb_to_hsl( scl[c_i] ) # convert rgb to hls
       1825         hsl_f = rgb_to_hsl( scl[c_i+1] ) if c_i < len(scl)-1 else hsl_o
    
    ZeroDivisionError: float division by zero
    
    

    Apparently round(r[-1])==0.

    opened by garyfeng 2
  • Add classifiers to setup.py

    Add classifiers to setup.py

    Classifiers are metadata about packages on PyPI. The information about Python version support shows on the PyPI project page and are used by tools such as caniusepython3.

    opened by wiggin15 1
  • colorlover has no license

    colorlover has no license

    I noticed that the colorlover package has no license file or license declaration in setup.py. Is it intended to be under MIT like plot.ly? If so, could you clarify that by adding a license file.

    opened by jank 1
  • interp giving weird intermediate values?

    interp giving weird intermediate values?

    I'm playing around with interp, and it seems to give some weird intermediate values. For example, in the docs for colorlover there is a section of the 'BuPu' colormap that cycles through hues early on:

    image

    I've found similar things when doing this with my own colormaps, e.g.:

    image

    This doesn't seem to be as big of a problem w/ fewer bins:

    image

    Any idea what's going on?

    opened by choldgraf 1
  • use in Plots.jl?

    use in Plots.jl?

    I don't see a license in the repo. How would you feel about contributing the color dictionary to Plots.jl so that these gradients could be used for all backends (including Plotly)?

    opened by tbreloff 1
  • HSL fixes

    HSL fixes

    Fixes #18 by interpolating the Hue component of HSL colors as angles (rather that a pure linear interpolation). For example, the angle half way between 10 deg and 350 deg should be 0 not 180.

    Also fixed an error in the calculation of the Hue component in rgb_to_hsl (971ef35)

    Results: screen shot 2019-01-19 at 10 37 42 am

    opened by jonmmease 0
  • Circleci 2 migration + maintenance fixes

    Circleci 2 migration + maintenance fixes

    Various maintenance fixes:

    • Migrate to circleci 2.0
    • distutils -> setuptools
    • Add conda recipe
    • Add MANIFEST.in to include README/LICESNE in PyPI packages.
    opened by jonmmease 0
  • cl.flipper( scale=None ) seems not working

    cl.flipper( scale=None ) seems not working

    Dear developers of colorlover tool, I was trying to reverse the colors of "Spectral" in the Diverging category. I thought the function cl.flipper( scale=None ) could achieve this. However, it didn't. From your GitHub webpage, the results of cl.flipper()['div']['3']['RdYlBu'] and cl.scales['3']['div']['RdYlBu'] are the same, the same sequence of the three returned rgb combinations. This perhaps explains why I didn't see reverse Spectral. I tried cl.scales['3']['div']['Spectral_r'], i.e., by adding _r, and it didn't work either. I am not sure if this is a problem or not. Could you please teach me how to reverse the color scale of your tool? Thank you in advance for your insights.

    opened by cylGitHub18 0
  • colorlover notebook no longer on plotly website?

    colorlover notebook no longer on plotly website?

    Perhaps more of an issue with plotly's website but the README points to this page (https://plot.ly/ipython-notebooks/color-scales/) which used to be a notebook of helpful lists of all of the palettes in colorlover

    However that link now redirects to here: (https://plotly.com/python/builtin-colorscales/) and none of colorlovers palettes or features are listed.

    Is there a way to get access to the old notebook somehow?

    Thanks!

    opened by hottwaj 0
  • cl.interp (and others) does not allow np.array for color scale

    cl.interp (and others) does not allow np.array for color scale

    Would be nice if this awesome library would allow creating color scales from numpy arrays. Right now it only detects numeric color scale if it strictly consists of tuples (explicit check in scale_type).

    opened by positron96 0
  • Specify license in setup.py

    Specify license in setup.py

    It would be useful if the license used could also be specified in setup.py, as then it can be displayed correctly by pip-licenses. This would involve a change like:

     setup(
         ...
    +    license='MIT',
         ...
    
    opened by cassava 0
Owner
Plotly
Plotly
Simple python implementation with matplotlib to manually fit MIST isochrones to Gaia DR2 color-magnitude diagrams

Simple python implementation with matplotlib to manually fit MIST isochrones to Gaia DR2 color-magnitude diagrams

Karl Jaehnig 7 Oct 22, 2022
A script written in Python that generate output custom color (HEX or RGB input to x1b hexadecimal)

ColorShell ─ 1.5 Planned for v2: setup.sh for setup alias This script converts HEX and RGB code to x1b x1b is code for colorize outputs, works on ou

Riley 4 Oct 31, 2021
A Graph Learning library for Humans

A Graph Learning library for Humans These novel algorithms include but are not limited to: A graph construction and graph searching class can be found

Richard Tjörnhammar 1 Feb 8, 2022
View part of your screen in grayscale or simulated color vision deficiency.

monolens View part of your screen in grayscale or filtered to simulate color vision deficiency. Watch the demo on YouTube. Install with pip install mo

Hans Dembinski 31 Oct 11, 2022
Simple plotting for Python. Python wrapper for D3xter - render charts in the browser with simple Python syntax.

PyDexter Simple plotting for Python. Python wrapper for D3xter - render charts in the browser with simple Python syntax. Setup $ pip install PyDexter

D3xter 31 Mar 6, 2021
Visual Python is a GUI-based Python code generator, developed on the Jupyter Notebook environment as an extension.

Visual Python is a GUI-based Python code generator, developed on the Jupyter Notebook environment as an extension.

Visual Python 564 Jan 3, 2023
A Python Binder that merge 2 files with any extension by creating a new python file and compiling it to exe which runs both payloads.

Update ! ANONFILE MIGHT NOT WORK ! About A Python Binder that merge 2 files with any extension by creating a new python file and compiling it to exe w

Vesper 15 Oct 12, 2022
Declarative statistical visualization library for Python

Altair http://altair-viz.github.io Altair is a declarative statistical visualization library for Python. With Altair, you can spend more time understa

Altair 8k Jan 5, 2023
Interactive Data Visualization in the browser, from Python

Bokeh is an interactive visualization library for modern web browsers. It provides elegant, concise construction of versatile graphics, and affords hi

Bokeh 17.1k Dec 31, 2022
Cartopy - a cartographic python library with matplotlib support

Cartopy is a Python package designed to make drawing maps for data analysis and visualisation easy. Table of contents Overview Get in touch License an

null 1.2k Jan 1, 2023
A grammar of graphics for Python

plotnine Latest Release License DOI Build Status Coverage Documentation plotnine is an implementation of a grammar of graphics in Python, it is based

Hassan Kibirige 3.3k Jan 1, 2023
a plottling library for python, based on D3

Hello August 2013 Hello! Maybe you're looking for a nice Python interface to build interactive, javascript based plots that look as nice as all those

Mike Dewar 1.4k Dec 28, 2022
UNMAINTAINED! Renders beautiful SVG maps in Python.

Kartograph is not maintained anymore As you probably already guessed from the commit history in this repo, Kartograph.py is not maintained, which mean

null 1k Dec 9, 2022
Tools for writing, submitting, debugging, and monitoring Storm topologies in pure Python

Petrel Tools for writing, submitting, debugging, and monitoring Storm topologies in pure Python. NOTE: The base Storm package provides storm.py, which

AirSage 247 Dec 18, 2021
The Python ensemble sampling toolkit for affine-invariant MCMC

emcee The Python ensemble sampling toolkit for affine-invariant MCMC emcee is a stable, well tested Python implementation of the affine-invariant ense

Dan Foreman-Mackey 1.3k Jan 4, 2023
The windML framework provides an easy-to-use access to wind data sources within the Python world, building upon numpy, scipy, sklearn, and matplotlib. Renewable Wind Energy, Forecasting, Prediction

windml Build status : The importance of wind in smart grids with a large number of renewable energy resources is increasing. With the growing infrastr

Computational Intelligence Group 125 Dec 24, 2022
Tools for exploratory data analysis in Python

Dora Exploratory data analysis toolkit for Python. Contents Summary Setup Usage Reading Data & Configuration Cleaning Feature Selection & Extraction V

Nathan Epstein 599 Dec 25, 2022
A Python Library for Self Organizing Map (SOM)

SOMPY A Python Library for Self Organizing Map (SOM) As much as possible, the structure of SOM is similar to somtoolbox in Matlab. It has the followin

Vahid Moosavi 497 Dec 29, 2022
:bowtie: Create a dashboard with python!

Installation | Documentation | Gitter Chat | Google Group Bowtie Introduction Bowtie is a library for writing dashboards in Python. No need to know we

Jacques Kvam 753 Dec 22, 2022