LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Change point color in graph if it's inside a certain range

Solved!
Go to solution

I have a plot that's got a red line on it, which is the flow rate of some pump. The pumps have a maximum flow rate, and I'd like to turn the points pink when this is hit, and back to red when it's below. How would I accomplish this programmatically?

0 Kudos
Message 1 of 11
(5,832 Views)
Solution
Accepted by topic author ijustlovemath
First what kind of graph are you using? An XY graph would be easiest. Basically the idea is to have multiple plots that visually look like a single plot in screen. One plot would be the normal range with one color points. The other plot would be just the right point with a different color.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 2 of 11
(5,828 Views)
XY. I'd like it to programmatically change the colors, and the legend color. It's already got 4 curves, and I don't think the legend will allow for any more.
0 Kudos
Message 3 of 11
(5,821 Views)
The legend can show dozens, just stretch it down.

Mike.

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 4 of 11
(5,809 Views)

Hi math,

 

I'd like it to programmatically change the colors

It's a property of the plot, so you can access it programmatically!

 

It's already got 4 curves, and I don't think the legend will allow for any more

The legend will allow as many plots as you like to use!

You can even have more plots than are shown in the legend…

 

As Mike said: use a different plot for your pink values!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 11
(5,806 Views)
Which property? Also, don't I have to do something like "active plot" before using the property mode?
0 Kudos
Message 6 of 11
(5,793 Views)
If you are setting a plot property, yes you have to set the Active Plot first.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 7 of 11
(5,759 Views)

Is this program just for your use?

 

If other people will be using it, and the flow rate is a critical thing, I'd suggest something a little less subtle than changing the line from red to pink.

0 Kudos
Message 8 of 11
(5,704 Views)

Also, you can use the plot.color property. I'm not sure how it would work if you had another graph that was only written to when the alarm was triggered, maybe mike or gerd can explain that.

 

plot color.png

0 Kudos
Message 9 of 11
(5,699 Views)

Are you trying to have a single point plot (or, I suppose, line plot) with some points one color (say, Green) and other points another color (say, Red)?  "You can't do that" -- the color of a plot is set for the entire collection of points.

 

Except that you can "cheat".  I had a behavioral test I was programming, where I wanted to plot the Stimulus Value in Green if the response was Correct, and in Red if the response was Incorrect.  Here's how I did it.

 

Start by declaring two arrays to hold the values (I'll call them "Right" and "Wrong").  Set the color of Right to (say) Green, the color of Wrong to Red.  Right and Wrong were "fed" by I32 variables, but I declared the Arrays as Array of Dbl (you'll see why in a minute).

 

During a Trial, you get a Response (to be plotted) and a Boolean that says if the response is Right or Wrong.  If the response is Right, set the Right plot to Value, and the Wrong plot to NaN (Not a Number), and do the reverse if the response is Wrong (i.e. make Right the NaN value).  This uses the "trick" that NaN values are simply not plotted, so the two Plots (of different colors) share the same "plot space", only one Value being plotted for each Response.

 

Hope I explained that clearly ...

 

Bob Schor

Message 10 of 11
(5,681 Views)