Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

how to change color in a plot?

I need to use 2 color in my waveform plot. I need black color for positive voltage and "no color" for negative voltage. Do I need to use 2 plots? Can I change color in a single plot? If I need 2 plots, how do I set the current point position of both plots the same. Do you have a command like "moveto" function without drawing a line?
0 Kudos
Message 1 of 6
(4,297 Views)
Yes, you will need to use two plots. You can change the color of a plot, but you CAN'T have multiple colors in one plot. It is on our suggested feature list. To plot these plots you will need to use the PlotXY function instead of the PlotY function. That will allow you to specify the X values for each plot so they show up properly.

Best Regards,

Chris Matthews
National Instruments
Message 2 of 6
(4,297 Views)
Every time I do PlotXY, it clear the screen so my old line disappear. Is there anyway to work around this? When I try chartXY, it chart from the previous position of each plot which creates erroneous line. How can I implement two color in a single plot?
0 Kudos
Message 3 of 6
(4,296 Views)
Sorry I should have been more specific. You DON'T call ChartXY on the graph object directly, you call it on the individual plot objects. Here are the steps:

1) Add a plot to the graph (from the ActiveX control property pages or by calling m_graph.Plots.Add function)
2) Change the color of the second plot in the property pages or with m_graph.Plots.Item(2).SetLineColor
3) Construct your X data and Y data into a CNiMatrix (X data in first row), (Y data in second row) for each plot
4) Call m_graph.Plots().Item(1).ChartXY for EACH plot, incrementing the item number.

Your code would look something like this.

CNiReal64Matrix dataPlot1(2, numPoints);
CNiReal64Matrix dataPlot2(2, numPoints);

//Fill data arrays (X first row, Y s
econd row)

m_graph.Plots.Item(1).ChartXY(dataPlot1);
m_graph.Plots.Item(2).ChartXY(dataPlot2);


Hope that helps,

Chris Matthews
National Instruments
0 Kudos
Message 5 of 6
(4,297 Views)
DrObb,

You can get this behavior using the 3D graph in Measurement Studio. The CNiPlot3D object has a custom color map feature that lets you assign colors to magnitude values and a Plot3DCurve function that accepts x, y, z, and magnitude values. Set up the colormap feature (see the documentation of ColorMapColors, ColorMapValues, ColorMapInterpolate, and ColorMapStyle), the call Plot3DCurve with your x and y values and set all z values to 0. Set the magnitude values according to what color you want each point to be. On your CNiGraph3D object, set the longitude to 180 and latitude to 0 to get a straight-on view of the XY plane (I could be wrong on the latitude and longitude values, but you can open the property page in the resource editor and rotate the gr
aph to find the correct values).

Sorry its a little complicated, but I hope this helps.

TonyH
Measurement Studio
Message 4 of 6
(4,296 Views)
Chris,

Please update me on the status of "multiple colors in one plot" solution for Visual Studio VB6?

Thanks,
Mark Hansen
0 Kudos
Message 6 of 6
(4,296 Views)