Unexpected behavior when explicitly providing colors and unevenly spaced levels
See original GitHub issueDescription
When supplying my own colors and unevenly spaced levels explicitly, I observe an unexpected behavior where some colors are omitted and others are repeated.
Steps to reproduce
import proplot as pplt
import numpy as np
N=20
state=np.random.RandomState(51423)
data=np.cumsum(state.rand(N, N), axis=1)
colors=['white','indigo1','indigo3','indigo5','indigo7','indigo9','yellow1','yellow3','yellow5','yellow7','yellow9','violet1','violet3']
fig,axs=pplt.subplots(nrows=2, ncols=1, refheight=3.5)
axs[0].pcolormesh(data, levels=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],
colors=colors, colorbar='r', extend='both', colorbar_kw={'label':'Expected color distribution'})
axs[1].pcolormesh(data,levels=[1., 1.25, 1.5, 2., 2.5, 3., 3.75, 4.5, 6., 7.5, 9., 12.],
colors=colors, colorbar='r', extend='both', colorbar_kw={'label':'Unexpected color distribution'})
Expected behavior: I expected that all 13 named colors would still show when mapped to the unevenly spaced levels on axs[1]
.
Actual behavior: In this example on axs[1]
, some colors are omitted and replaced by others. I also observe this issue when providing my own RGB tuples.
Equivalent steps in matplotlib
Explicitly providing named colors and unevenly spaced levels in Matplotlib gives the desired behavior.
Proplot version
ProPlot 0.9.5 Matplotlib 3.4.3 Python 3.9.7
Issue Analytics
- State:
- Created 2 years ago
- Comments:7
Top Results From Across the Web
Color psychology - Wikipedia
Color psychology is the study of hues as a determinant of human behavior. Color influences perceptions that are not obvious, such as the...
Read more >Color Realism and Color Science
We defend the view that physical objects (for instance, tomatoes, radishes, and rubies) are colored, and that colors are physical properties, specifically ......
Read more >The Causes and Consequences of Color Vision | Evolution
This paper provides a brief introduction to color vision, the genetics of color vision in humans, what colors other animals see, ...
Read more >the geometry of color perception - handprint
The Munsell system can be used to define colors that are perceived to be evenly spaced in hue and chroma across equal value...
Read more >Mouse color and wavelength-specific luminance contrast ...
Here, we use a simple behavior, change detection, to determine where in visual space mice can discriminate changes in chromaticity and luminance at ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks for such a quick turnaround on getting this resolved. Much appreciated!
Here’s your example after the update. Note some ticks on the right “linear” colorbar are missing by default (to prevent overcrowding) while ticks on the left
SegmentedNorm
colorbar are all shown (to avoid hiding the locations of non-linear thresholds in the scaling).