11-18-2008 01:21 PM
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.
Solved! Go to Solution.
11-19-2008 04:24 PM
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
11-20-2008 12:39 PM
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?
11-21-2008 02:11 PM
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
11-21-2008 02:50 PM
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?
11-21-2008 03:02 PM
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
11-21-2008 03:22 PM
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.