LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Change the color of a point on XY graph having "Line and symbol" Plot type

Hi All,

I am trying to plot a XY graph in labVIEW which looks like the attached image. The plot type used must be "Line and symbol" which means that a line joins consecutive points on the graph(like the black line joining two points in the image). I want to be able to change the color of the point programmatically (all point below a threshold must have green color, above the threshold, it should change to red.).

Can someone share any ideas to accomplish this?

 

Regards

Aveo

0 Kudos
Message 1 of 2
(2,907 Views)

I'm going to assume that you are making a plot with a single set of points, similar to what you showed on your picture.  Which brings up my favorite rant -- where is your VI?  Attach your VI!  We are not here to do your work for you, but to help you to do your work, and in order to understand what help you need, we need to see your VI, not a picture of the VI (since we cannot edit, closely inspect, or test-run a picture).

 

So if you looked up the Properties for an XY Graph, you'll notice that you can color the Points/Fills and the Lines with any single color you want (you can color lines differently from points, but all the lines have to be the same color and all the points have to be the same color).  So how can you color one point differently?  Simple answer, you can't.

 

More complicated answer is that you can't unless you get tricky.  Let's say you have 5 points, and want points 1, 2, 4, and 5 to be Green, and point 3 to be red.  Plot all 5 points as Green.  Now plot only point 3 as Red (be sure to plot it second, so it "covers up" the Green).  

 

But what if it is a smaller symbol or otherwise can't cover up the Green?  Well, just plot 1, 2, 4, 5 in Green, and 3 in Red.

 

"Messy", you say?  Yep.  But at least with a Graph, you can address individual points.

 

But what if you want to do the same thing with a Chart, where every second you get a new point, and want (on a point-by-point basis) to plot it either as a Red Circle or a Green Square?  "Impossible", you say?  "No, you just need to be even more devious", I reply.

 

Again, the trick comes down to plotting two points on the Chart for every data point that you want to see.  One point plots as a Red Circle, the other as a Green Square.  The trick is to move the one you don't want to see off the graph.  If you are only plotting points, this isn't such a huge issue (unless you are auto-scaling your plot!), but if you "connect the dots", then what do you do?

 

Become even more devious.  Make sure that the data you are plotting are reals (such as Dbl) -- convert integers to Dbls if necessary -- and make the "don't-look-at-me" points values that are Not a Number, so cannot be plotted.  Here's an example:NaN.pngThis is just a Dbl constant with "NaN" written inside it.

 

So with a bit of effort, you can do some fancy tricks with LabVIEW Charts and Graphs.

 

Bob Schor 

0 Kudos
Message 2 of 2
(2,856 Views)