|  | 
|  | 1 | +.. _color_changes: | 
|  | 2 | + | 
|  | 3 | +********************* | 
|  | 4 | +Default Color changes | 
|  | 5 | +********************* | 
|  | 6 | + | 
|  | 7 | +As discussed at length elsewhere [insert links], ``jet`` is an | 
|  | 8 | +empirically bad color map and should not be the default color map. | 
|  | 9 | +Due to the position that changing the appearance of the plot breaks | 
|  | 10 | +backward compatibility, this change has been put off for far longer | 
|  | 11 | +than it should have been.  In addition to changing the default color | 
|  | 12 | +map we plan to take the chance to change the default color-cycle on | 
|  | 13 | +plots and to adopt a different color map for filled plots (``imshow``, | 
|  | 14 | +``pcolor``, ``contourf``, etc) and for scatter like plots. | 
|  | 15 | + | 
|  | 16 | + | 
|  | 17 | +Default Heat Map Colormap | 
|  | 18 | +------------------------- | 
|  | 19 | + | 
|  | 20 | +The choice of a new color map is fertile ground to bike-shedding ("No, | 
|  | 21 | +it should be _this_ color") so we have a proposed set criteria (via | 
|  | 22 | +Nathaniel Smith) to evaluate proposed color maps. | 
|  | 23 | + | 
|  | 24 | +- it should be a sequential colormap, because diverging colormaps are | 
|  | 25 | +  really misleading unless you know where the "center" of the data is, | 
|  | 26 | +  and for a default colormap we generally won't. | 
|  | 27 | + | 
|  | 28 | +- it should be perceptually uniform, i.e., human subjective judgments | 
|  | 29 | +  of how far apart nearby colors are should correspond as linearly as | 
|  | 30 | +  possible to the difference between the numerical values they | 
|  | 31 | +  represent, at least locally. | 
|  | 32 | + | 
|  | 33 | +- it should have a perceptually uniform luminance ramp, i.e. if you | 
|  | 34 | +  convert to greyscale it should still be uniform. This is useful both | 
|  | 35 | +  in practical terms (greyscale printers are still a thing!) and | 
|  | 36 | +  because luminance is a very strong and natural cue to magnitude. | 
|  | 37 | + | 
|  | 38 | +- it should also have some kind of variation in hue, because hue | 
|  | 39 | +  variation is a really helpful additional cue to perception, having | 
|  | 40 | +  two cues is better than one, and there's no reason not to do it. | 
|  | 41 | + | 
|  | 42 | +- the hue variation should be chosen to produce reasonable results | 
|  | 43 | +  even for viewers with the more common types of | 
|  | 44 | +  colorblindness. (Which rules out things like red-to-green.) | 
|  | 45 | + | 
|  | 46 | +- For bonus points, it would be nice to choose a hue ramp that still | 
|  | 47 | +  works if you throw away the luminance variation, because then we | 
|  | 48 | +  could use the version with varying luminance for 2d plots, and the | 
|  | 49 | +  version with just hue variation for 3d plots. (In 3d plots you | 
|  | 50 | +  really want to reserve the luminance channel for lighting/shading, | 
|  | 51 | +  because your brain is *really* good at extracting 3d shape from | 
|  | 52 | +  luminance variation. If the 3d surface itself has massively varying | 
|  | 53 | +  luminance then this screws up the ability to see shape.) | 
|  | 54 | + | 
|  | 55 | +- Not infringe any existing IP | 
|  | 56 | + | 
|  | 57 | +Example script | 
|  | 58 | +++++++++++++++ | 
|  | 59 | + | 
|  | 60 | +Proposed Colormaps | 
|  | 61 | +++++++++++++++++++ | 
|  | 62 | + | 
|  | 63 | +Default Scatter Colormap | 
|  | 64 | +------------------------ | 
|  | 65 | + | 
|  | 66 | +For heat-map like applications it can be desirable to cover as much of | 
|  | 67 | +the luminence scale as possible, however when color mapping markers, | 
|  | 68 | +having markers too close to white can be a problem.  For that reason | 
|  | 69 | +we propose using a different (but maybe related) color map to the | 
|  | 70 | +heat map for marker-based.  The design parameters are the same as | 
|  | 71 | +above, only with a more limited luminence variation. | 
|  | 72 | + | 
|  | 73 | + | 
|  | 74 | +Example script | 
|  | 75 | +++++++++++++++ | 
|  | 76 | +:: | 
|  | 77 | +   import numpy as np | 
|  | 78 | +   import matplotlib.pyplot as plt | 
|  | 79 | + | 
|  | 80 | +   np.random.seed(1234) | 
|  | 81 | + | 
|  | 82 | +   fig, (ax1, ax2) = plt.subplots(1, 2) | 
|  | 83 | + | 
|  | 84 | +   N = 50 | 
|  | 85 | +   x = np.random.rand(N) | 
|  | 86 | +   y = np.random.rand(N) | 
|  | 87 | +   colors = np.random.rand(N) | 
|  | 88 | +   area = np.pi * (15 * np.random.rand(N))**2  # 0 to 15 point radiuses | 
|  | 89 | + | 
|  | 90 | +   ax1.scatter(x, y, s=area, c=colors, alpha=0.5) | 
|  | 91 | + | 
|  | 92 | + | 
|  | 93 | +   X,Y = np.meshgrid(np.arange(0, 2*np.pi, .2), | 
|  | 94 | +                     np.arange(0, 2*np.pi, .2)) | 
|  | 95 | +   U = np.cos(X) | 
|  | 96 | +   V = np.sin(Y) | 
|  | 97 | +   Q = ax2.quiver(X, Y, U, V, units='width') | 
|  | 98 | +   qd = np.random.rand(np.prod(X.shape)) | 
|  | 99 | +   Q.set_array(qd) | 
|  | 100 | + | 
|  | 101 | +Proposed Colormaps | 
|  | 102 | +++++++++++++++++++ | 
|  | 103 | + | 
|  | 104 | +Color Cycle / Qualitative color map | 
|  | 105 | +----------------------------------- | 
|  | 106 | + | 
|  | 107 | +When plotting lines it is frequently desirable to plot multiple lines | 
|  | 108 | +or artists which need to be distinguishable, but there is no inherent | 
|  | 109 | +ordering. | 
|  | 110 | + | 
|  | 111 | + | 
|  | 112 | +Example script | 
|  | 113 | +++++++++++++++ | 
|  | 114 | +:: | 
|  | 115 | +   import numpy as np | 
|  | 116 | +   import matplotlib.pyplot as plt | 
|  | 117 | + | 
|  | 118 | +   fig, (ax1, ax2) = plt.subplots(1, 2) | 
|  | 119 | + | 
|  | 120 | +   x = np.linspace(0, 1, 10) | 
|  | 121 | + | 
|  | 122 | +   for j in range(10): | 
|  | 123 | +       ax1.plot(x, x * j) | 
|  | 124 | + | 
|  | 125 | + | 
|  | 126 | +   th = np.linspace(0, 2*np.pi, 1024) | 
|  | 127 | +   for j in np.linspace(0, np.pi, 10): | 
|  | 128 | +       ax2.plot(th, np.sin(th + j)) | 
|  | 129 | + | 
|  | 130 | +   ax2.set_xlim(0, 2*np.pi) | 
|  | 131 | + | 
|  | 132 | +Proposed Color cycle | 
|  | 133 | +++++++++++++++++++++ | 
0 commit comments