Software FX Community

# Same color for all the Point in a Scatter Plot

## Recommended Posts

```Hello,
I draw a scatter plot, but when I 2 points have the same X-value, one point
is painted in red and the other in blue. I would like to have all the points
painted in red. How can I do that?
Thank you very much in advance
Olivier```
##### Share on other sites

```Ok, my first question was not good.
I would like to draw a scatter plot, with many points (X,Y). But when I use
the Scatter graph of ChartFX, I get red and blue points, which is not what I
want. I only want a simple scatter plot with as many points as I give in the
list to the plot.
What am I doing wrong?
Thx,
Oli
"Olivier" <olivier.voyer@cyme.com> wrote in message
news:iw7PRiztGHA.2444@webserver3.softwarefx.com...
> Hello,
>
> I draw a scatter plot, but when I 2 points have the same X-value, one
> point is painted in red and the other in blue. I would like to have all
> the points painted in red. How can I do that?
>
> Thank you very much in advance
>
> Olivier
>```
##### Share on other sites

```Seems that you are creating 2 series and that's the reason you are getting
two colors.
You have several options here:
1) Create one series only
2) Assign: chart.Series[1].Color = chart.Series[0].Color
--
www.chartfx.com```
##### Share on other sites

```Thanks for your answer,
However, I have another problem. When 2 points in a graph have the same
X-coordinate, these two points are not at the same vertical position as I
would expect it. In fact, they are drawn as if they had two different
X-coordinates. So, there are two x-coordinates that have the same label. For
example:
*         *
*
(5,10) (6,12) (5,12)
But I would expect:
*         *
*
(5,10) (6,12)
(5,12)
How can I correct this problem?
Thank you,
Olivier Voyer
CYME International
"SoftwareFX Support" <noreply@softwarefx.com> wrote in message
news:kgGsqh9tGHA.2276@webserver3.softwarefx.com...
> Seems that you are creating 2 series and that's the reason you are getting
> two colors.
>
> You have several options here:
>
> 1) Create one series only
> 2) Assign: chart.Series[1].Color = chart.Series[0].Color
>
> --
> www.chartfx.com
>```
##### Share on other sites

```You must be passing your data incorrectly. When you pass the data as
specified you will get the two point in the same X-Coordinate.
It is important to notice X-Values and labels are NOT the same, X-Values are
numeric and control the position of the pint in the x-axis (in charts that
support X-values such as Line, Scatter, Area), Labels are just strings used
to label the axis and have no influence in the position of the point.
Please attach the code section containing the way you are passing the data
to this chart.
--
www.chartfx.com```
##### Share on other sites

```Yes, you must be right. Here is my code:
==============================
object[] allArrays = new object[2];
double[] myArray = new double[lstMyList.Count];
string[] labelArray = new string[lstMyList.Count];
myArray [0] = 5;
myArray [1] = 10;
myArray [2] = 15;
labelArray[0] = "3";
labelArray[1] = "5";
labelArray[2] = "3";
allArrays[0] = myArray ; // Y-Value
allArrays[1] = labelArray; // (Labels)
ListProvider lstProvider = new ListProvider(allArrays);
base.DataSourceSettings.DataSource = lstProvider;
==============================
Thx,
Olivier
"SoftwareFX Support" <noreply@softwarefx.com> wrote in message
news:X3MQSfJuGHA.2444@webserver3.softwarefx.com...
> You must be passing your data incorrectly. When you pass the data as
> specified you will get the two point in the same X-Coordinate.
>
> It is important to notice X-Values and labels are NOT the same, X-Values
> are numeric and control the position of the pint in the x-axis (in charts
> that support X-values such as Line, Scatter, Area), Labels are just
> strings used to label the axis and have no influence in the position of
> the point.
>
> Please attach the code section containing the way you are passing the data
> to this chart.
>
> --
> www.chartfx.com
>```
##### Share on other sites

```Yes. There is no X-Value. Your labels are strings !
You need to change this as follows:
double[] xValues = new double[lstMyList.Count];
// Initialize array
...
base.DataType[0] = DataType.Value;
base.DataType[1] = DataType.XValue;
ListProvider lstProvider = new ListProvider(allArrays);
base.DataSourceSettings.DataSource = lstProvider;
--
www.chartfx.com```
##### Share on other sites

```Yes. There is no X-Value. Your labels are strings !
You need to change this as follows:
double[] xValues = new double[lstMyList.Count];
// Initialize array
...
base.DataType[0] = DataType.Value;
base.DataType[1] = DataType.XValue;
ListProvider lstProvider = new ListProvider(allArrays);
base.DataSourceSettings.DataSource = lstProvider;
--
www.chartfx.com```
##### Share on other sites

```Thx for your answer
Unfortunately, that didn't work:
base.DataType[0] = DataType.Value;
base.DataType[1] = DataType.XValue;
"DataType" is not a property of the "base" class (which is derived from the
"Chart" class) and the compiler doesn't recognize "DataType.Value" and
"DataType.XValue".
Can you help me again please?
Olivier
CYME International T&D
Errors: The name 'DataType' does not exist in the current context
"SoftwareFX Support" <noreply@softwarefx.com> wrote in message
news:LOwUJojuGHA.2276@webserver3.softwarefx.com...
> Yes. There is no X-Value. Your labels are strings !
>
> You need to change this as follows:
>
> double[] xValues = new double[lstMyList.Count];
>
> // Initialize array
>
> ...
>
> base.DataType[0] = DataType.Value;
> base.DataType[1] = DataType.XValue;
> ListProvider lstProvider = new ListProvider(allArrays);
> base.DataSourceSettings.DataSource = lstProvider;
>
>
> --
> www.chartfx.com
>
>
>
>```
##### Share on other sites

```I should have asked this in the beginning: What version of Chart FX are you
using ?
--
www.chartfx.com```
##### Share on other sites

```Hi again. Thank you for your patience
Version of ChartFX : Chart FX for Visual Studio 2005
Olivier
"SoftwareFX Support" <noreply@softwarefx.com> wrote in message
news:N5NC25luGHA.1228@webserver3.softwarefx.com...
>I should have asked this in the beginning: What version of Chart FX are you
>using ?
>
> --
> www.chartfx.com
>```
##### Share on other sites

```Ok. That explains it.
The code is:
object[] allArrays = new object[2];
double[] myArray = new double[3];
double[] xValues = new double[3];
myArray [0] = 5;
myArray [1] = 10;
myArray [2] = 15;
xValues[0] = 3;
xValues[1] = 5;
xValues[2] = 3;
allArrays[0] = myArray ; // Y-Value
allArrays[1] = xValues; // X-Values
FieldMap("Field1",FieldUsage.Value));
FieldMap("Field2",FieldUsage.XValue));
ListProvider lstProvider = new ListProvider(allArrays);
chart1.DataSourceSettings.DataSource = lstProvider;
To avoid the same confusion and expedite our responses please post to the
appropriate newsgroup: chartfx.vs2005.WinForms
--
www.chartfx.com```
##### Share on other sites

```Ok thank you very much!
Have a nice day,
Olivier
"SoftwareFX Support" <noreply@softwarefx.com> wrote in message
news:w8IvF5vuGHA.2136@webserver3.softwarefx.com...
> Ok. That explains it.
>
> The code is:
>
> object[] allArrays = new object[2];
>
> double[] myArray = new double[3];
>
> double[] xValues = new double[3];
>
> myArray [0] = 5;
>
> myArray [1] = 10;
>
> myArray [2] = 15;
>
> xValues[0] = 3;
>
> xValues[1] = 5;
>
> xValues[2] = 3;
>
> allArrays[0] = myArray ; // Y-Value
>
> allArrays[1] = xValues; // X-Values
>
> FieldMap("Field1",FieldUsage.Value));
>
> FieldMap("Field2",FieldUsage.XValue));
>
> ListProvider lstProvider = new ListProvider(allArrays);
>
> chart1.DataSourceSettings.DataSource = lstProvider;
>
>
> To avoid the same confusion and expedite our responses please post to the
> appropriate newsgroup: chartfx.vs2005.WinForms
>
> --
> www.chartfx.com
>```

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.