Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I change the color of plots (lines, point) in Scattergraph Plot collection

Solved!
Go to solution

For example, I go thru a foreach loop and plot two points. How do I distinguish this set of plots from the rest to come? How do I change the point style, color and have seperate lines (instead of on line connecting everything) for each of my plots? I know how to set everything up, but it still does what it wants to do. TIA.

0 Kudos
Message 1 of 7
(5,349 Views)

Hello maramckmc,

 

I'm a little unclear exactly what you're trying to implement.  Are you looking for a unique identifier for each plot object in the collection?  Have you set the style, plot color, etc. seperately for each individual plot object?  

 

Perhaps if you could post a little bit of code resembling what you're currently trying to implement, I could be a little more help.

 

NickB

National Instruments 

Message 2 of 7
(5,327 Views)

For every different plot on my scattergrah, I would like an unique color to distinguish it from the others. I am setting up and legend to distinguish the different plots.

 

ScatterPlot _data = new ScatterPlot();

ScatterPlot _data2 = new ScatterPlot();

 

//Add data plot to the graph collection

_graph3.Plots.Add(_data);

_graph3.Plots.Add(_data2);

 

//Set _data and _data2 equal to scatterPlot3

_data = scatterPlot3

_data2 = scatterPlot3

 

 

if (_plot3.Data[0] != null)

{

//set data point style and color and line color

_data.PointColor = Color.Red;

_data.LineColor = Color. Blue;

}

_data.PlotXYAppend(xValue, yValue);

 

if (_plot3.Data[0] != null)

{

//set data2 point style and color and line color

_data2.PointColor = Color.Green;

_data2.LineColor = Color. Yellow;

}

_data2.PlotXYAppend(xValue, yValue);

 

//end of code

 

However, I always seem to get the to plots in the same color. Also, should I make two seperate ScatterPlots for one graph?

0 Kudos
Message 3 of 7
(5,310 Views)
Solution
Accepted by topic author maramckmc

Hello,

 

The problem you are seeing occurs because of the following lines of code:

 

//Set _data and _data2 equal to scatterPlot3

_data = scatterPlot3

_data2 = scatterPlot3

 

When you do this, you are setting both _data and _data2 to reference a single plot object - scatterPlot3.  So, although you have (from the code you posted at least) three plots in your collection, they all point to the same ScatterPlot object.  Thus when you change the color for one, it changes the color for them all.  However, I think you have happened upon the correct solution in your last sentance.  If you want to have multiple plots on your ScatterGraph, each with it's own color and style, they will have to each be distinct, unique plots in your ScatterGraph's plot collection.  Based on the code you've posted, you will see this if you simply comment out the two lines posted above.

 

Please let me know if anything is still unclear.

 

NickB

National Instruments 

0 Kudos
Message 4 of 7
(5,114 Views)

Nickb,

 

Thanks. That solved my problem with the colors. However, I do not have a line, just plots??...Any idea as to why this is happening?

0 Kudos
Message 5 of 7
(5,108 Views)

Hmmm... I'm not exactly sure what you mean by 'no lines, just plots', but if it means there are only points showing up, you may just need to add this piece of code for your plots, where scatterPlot1 is replaced by your plots:

 

scatterPlot1.LineStyle = LineStyle.Solid;

 

If this does not do it for you, could you shoot a quick screenshot of what you're describing?  Thanks!

 

NickB

National Instruments 

0 Kudos
Message 6 of 7
(5,106 Views)

Yes, only my points are shown. I'll try your suggestion. Thanks.

 

Another quick question, say, for example, my _plot3.Data has 4 indexes. Should I make a new Scatter Plot for each one or could I only use one? I will still want different colors to distinquish the different plots.

0 Kudos
Message 7 of 7
(5,103 Views)