Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The plot you've shown doesn't have the color set by the vertical axis of the plot (which is what I would consider the <em>y-value</em>). Instead, it just has 8 different plots overlain, each with a different color, without stating what the color means.</p> <p>Here's an example of something that looks like your plot:</p> <pre><code>import numpy as np import matplotlib.pyplot as plt from matplotlib import cm # some fake data: x = np.linspace(0, 2*np.pi, 1000) fs = np.arange(1, 5.) ys = np.sin(x*fs[:, None]) for y, f in zip(ys, fs): plt.plot(x, y, lw=3, c=cm.hot(f/5)) </code></pre> <p><img src="https://i.stack.imgur.com/gULpI.png" alt="colors"></p> <p>If you actually want the color of one line to change with respect to its value, you have to kind of hack it, because any given <code>Line2D</code> object can only have one color, as far as I know. One way to do this is to make a scatter plot, where each dot can have any color.</p> <pre><code>x = np.linspace(0, 2*np.pi, 1000) y = np.sin(2*x) plt.scatter(x,y, c=cm.hot(np.abs(y)), edgecolor='none') </code></pre> <p>Notes:</p> <ul> <li>The color vector should range between <code>0</code> and <code>1</code>, so if <code>y.max() &gt; 1</code>, then normalize by it: <code>c=cm.hot(y/y.max())</code> and make sure it's all positive.</li> <li>I used <code>edgecolor='none'</code> because by default the <code>scatter</code> markers have a black outline which makes the it look less like a uniform line.</li> <li>If your data is spaced too far, you'll have to interpolate the data if you don't want gaps between markers.</li> </ul> <p><img src="https://i.stack.imgur.com/Jeqt4.png" alt="more colors"></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload