LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I fix the color ramp values in a contour plot

Hi, 

 

I'm wanting to be able to fix certain values in a contour plot to be certain colors, i.e. if I return a value being sampled as 4.33 I want it to show green, if I sample a value of 6 I want it to show red. Regardless of what the maximum value being sampled, I want the color map to be the same. 

 

I thought I could fudge this by having an array bigger than what I am plotting, and picking a non-visible element and fixing to the max value that I want to set to red. This doesn't seem to be the only part to the solution. I have attached my code I am working with, could someone please take a look and give me any advice? I greatly appreciate it. 

0 Kudos
Message 1 of 8
(2,971 Views)

Do you want to have white regions outside your "Level List"? I think, you have to convert your "Plot Specific:Contour:Contour Level List" to the correct 'Color Ramp Index".

 

Color Ramp FP.png.jpg

 

Color Ramp BD.png.jpg

 

You had some extremely narrow Level regions (in values of few percent), so I decreased the number of levels and increased the step size for demonstration.

Message 2 of 8
(2,933 Views)

Ghighuphu, 

 

For above the ramp index, i.e. values above 6 I want everything to be the red. There shouldn't be values below 0, so in reality the 0 value could be the purple. 

 

The application is I'm plotting fuel concentration in a rig. The "target range is from 4.1 to 4.4 which is why I want that range to be green. Then anything outside that range I want to slowly turn to dark blue/purple for lean mixtures, and turn slowly to yellow, orange and red for rich mixtures. 

 

I was doing what you showed in your block diagram, but mine doesn't look anything like yours, I have a large region of black plotted now. Not sure what I failed to do?? 

0 Kudos
Message 3 of 8
(2,921 Views)

Dear bhorn63,

 

I am glad you could follow the logic of my code.

 

I could not find it documented in the help, but the plot needs N+1 colors defined in the "Color Ramp Array", when there are N values in the "Color Ramp Index" array. And there should be also N values in the "Plot Specific:Contour:Contour Level List" array -- also a constant in your code. Drag the bottom of the array constant in your cluster (also a constant) and define one more colorbox value. Let us know about your result.

Message 4 of 8
(2,899 Views)

Note: The structure which you tried to mimic from my code is called "In Place Element Structure"; with "Unbundle/Bundle Elements" nodes -- you get it from the right-click menu executed on the sides of the structure. Your solution is appropriate as well in this specific case of use.

Message 5 of 8
(2,896 Views)

This was not part of your question. But it striked me, that you created your own inter-/extrapolation algorithm.

 

Navigation window.png

 

I hope it is a termporarily solution. Have a look at my code suggestion below. I think it makes more sense on the long term. Good luck!

Message 6 of 8
(2,883 Views)

Thanks for all of the help! I was finally able to force certain values to the colors I wanted. I had to have a fundge point that I tuned. i.e. there was a point on my contour not being shown by my chart, that I had to fine tune the value to get my contour plot to work. It is a constant in my block diagram as you'll see.

 

This does a pretty good job of forcing the values/intervals. But it's off by a few hundredths. For example, I want 4.1 to start the green, and 4.09 to be the lightest shade of blue. But in the code, that boundary is at 4.13/4.14. On the high end of my goal (green) range, the boundary I was trying to set was at 4.4, but it appears to be at 4.37/4.38. This is pretty close, and for now it is acceptable. But if you're curious and want to mess with it and find out the answer, please let me know. 

 

Other than that, it's going to serve the purpose, thanks for the help with defining the color array/index. I never would have realized the N+1. 

 

For the algorithm that I hard coded, I appreciate the help on that too, the reason I did the hardcode way, is because I'm not always sure where I'm going to be sampling from. So this allows me to intuitively change where I'm forcing my values to be at. I realize it's not the best format. 🙂 

 

Thanks again! 

0 Kudos
Message 7 of 8
(2,868 Views)
Dear bhorn63,

Ad precision: I think you should change some settings to get a plot with non-interpolated colours. So you get sharp colour boundaries. Or create an array with more contrasting colours. A difference in light green and blueish green is very subjective.

I would even think of some kind of zooming, if you require one percentile resolution.

Ad hard coming the interpolation: maybe using a 5x9 array as a direct user control makes more sense... so to speak, hard coding the 2D array 🙂

Cheers
0 Kudos
Message 8 of 8
(2,852 Views)