SourceForge logo
SourceForge logo
Menu

matplotlib-users

From: Rita <rmo...@gm...> - 2013年02月27日 09:50:30
Hi,
I am currently plotting cpu utilization over time (plot_time). I would like
the color of my line to be red when at 100%. 80-90% a bit less red, more
yellow, and lower numbers will be green. Any thoughts of doing this?
-- 
--- Get your facts first, then you can distort them as you please.--
From: Phil E. <pel...@gm...> - 2013年02月27日 10:13:09
Joe Kington's answer is the best solution I've seen to this problem:
http://stackoverflow.com/questions/13622909/matplotlib-how-to-colorize-a-large-number-of-line-segments-as-independent-gradi
There is also an example in the gallery:
http://matplotlib.org/examples/pylab_examples/multicolored_line.html
HTH
On 27 February 2013 09:49, Rita <rmo...@gm...> wrote:
> Hi,
>
> I am currently plotting cpu utilization over time (plot_time). I would
> like the color of my line to be red when at 100%. 80-90% a bit less red,
> more yellow, and lower numbers will be green. Any thoughts of doing this?
>
>
> --
> --- Get your facts first, then you can distort them as you please.--
>
>
> ------------------------------------------------------------------------------
> Everyone hates slow websites. So do we.
> Make your web apps faster with AppDynamics
> Download AppDynamics Lite for free today:
> http://p.sf.net/sfu/appdyn_d2d_feb
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
From: Jakob G. <ga...@il...> - 2013年02月27日 10:26:27
Hi
have a look at http://matplotlib.org/examples/pylab_examples/multicolored_line.html and
http://matplotlib.org/examples/pylab_examples/show_colormaps.html.
br
Jakob
On 02/27/2013 10:49 AM, Rita wrote:
> Hi,
>
> I am currently plotting cpu utilization over time (plot_time). I would like the color of my line to be
> red when at 100%. 80-90% a bit less red, more yellow, and lower numbers will be green. Any thoughts of
> doing this?
>
>
> --
> --- Get your facts first, then you can distort them as you please.--
>
>
> ------------------------------------------------------------------------------
> Everyone hates slow websites. So do we.
> Make your web apps faster with AppDynamics
> Download AppDynamics Lite for free today:
> http://p.sf.net/sfu/appdyn_d2d_feb
>
>
>
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
From: Paul H. <pmh...@gm...> - 2013年02月27日 16:03:07
On Wed, Feb 27, 2013 at 1:49 AM, Rita <rmo...@gm...> wrote:
> Hi,
>
> I am currently plotting cpu utilization over time (plot_time). I would
> like the color of my line to be red when at 100%. 80-90% a bit less red,
> more yellow, and lower numbers will be green. Any thoughts of doing this?
>
A few years ago, Gökhan Sever posted this technique, which is the simplest
and best I've seen:
##
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.cm as cm
x = np.linspace(0, 3 * np.pi, 5000)
y = np.sin(x)
z = np.cos(0.5 * (x[:-1] + x[1:])) # 1st derivative
cmap_z = cm.coolwarm(z)
fig, ax1 = plt.subplots(nrows=1, ncols=1)
ax1.scatter(x, y, c=cmap_z, marker='_', s=5)
fig.show()
##
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /