Page 1 of 1
How to draw non-linear custom weibull scale?
Posted: Fri Sep 04, 2009 4:09 am
by 8119814
Hello,
I need to plot a Weibull CDF(Cumulative Distribution) graph. Is it possible to draw a Weibull scale on t-chart? i.e custom axis scale. If yes, then please show some example on how it can be done. I don't want the graph to be drawn on a linear or log scale. I want to plot it purely on Weibull scale.
Cheers
Re: How to draw non-linear custom weibull scale?
Posted: Fri Sep 04, 2009 8:01 am
by narcis
Hello Glenn,
If you are trying to plot a scale as in
Wikipedia Weibull distribution's entry image below
Then you can easily achieve that either manually setting axes scales using Minimum, Maximum and Increment properties as described in tutorial 4. Tutorials are available at TeeChart's program group. If that's not enough you can manually customise and parse axes labels in the GetAxisLabel event. Examples are also available in tutorial 4.
Finally, if that doesn't fit your needs you can also use custom axis labels as shown in the
All Features\Welcome!\Axes\Labels\Custom labels example at the features demo, available at TeeChart's program group.
Hope this helps
Re: How to draw non-linear custom weibull scale?
Posted: Fri Sep 04, 2009 12:02 pm
by 8119814
Hello,
I want the following graph:-
- Weibull.JPG (28.34 KiB) Viewed 19883 times
The example that you show plots the CDF on linear scale. I want the scaling to be as the above graph, i.e, Weibull scale. How can this form of graph be achieved?
Thanks
Re: How to draw non-linear custom weibull scale?
Posted: Fri Sep 04, 2009 2:24 pm
by narcis
Hello,
In that case I think the best option would be:
-
Left axis: using custom labels using a linear scale for the values where they are located but Weibull scale for the values of the labels, as in the example below.
-
Bottom axis: Logarithmic scale as in the example.
Code: Select all
public Form1()
{
InitializeComponent();
InitializeChart();
}
private void InitializeChart()
{
tChart1.Aspect.View3D = false;
Steema.TeeChart.Styles.Line line1 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
line1.Pointer.Visible = true;
tChart1.Axes.Bottom.Logarithmic = true;
tChart1.Axes.Bottom.SetMinMax(10000, 1000000);
tChart1.Axes.Bottom.MinorTickCount = 8;
tChart1.Axes.Bottom.MinorGrid.Visible = true;
tChart1.Axes.Bottom.MinorGrid.Style = System.Drawing.Drawing2D.DashStyle.Solid;
tChart1.Axes.Bottom.Grid.Style = System.Drawing.Drawing2D.DashStyle.Solid;
tChart1.Axes.Bottom.Grid.Color = Color.Red;
tChart1.Axes.Bottom.Labels.Font.Color = Color.Red;
tChart1.Axes.Left.SetMinMax(1, 10);
tChart1.Axes.Left.MinorTicks.Visible = false;
tChart1.Axes.Left.Grid.Style = System.Drawing.Drawing2D.DashStyle.Solid;
for (int i = 0; i < 10; i++)
{
line1.Add(10000*i, i);
}
//add custom Weibull labels
AddWeibullLabels(Color.Red);
}
private void AddWeibullLabels(Color color)
{
tChart1.Axes.Left.Labels.Items.Clear();
(tChart1.Axes.Left.Labels.Items.Add(1, "10000")).Font.Color = color;
(tChart1.Axes.Left.Labels.Items.Add(2.8, " ")).Font.Color = color;
(tChart1.Axes.Left.Labels.Items.Add(3.9, " ")).Font.Color = color;
(tChart1.Axes.Left.Labels.Items.Add(4.75, " ")).Font.Color = color;
(tChart1.Axes.Left.Labels.Items.Add(5.5, "50000")).Font.Color = color;
(tChart1.Axes.Left.Labels.Items.Add(6.2, " ")).Font.Color = color;
(tChart1.Axes.Left.Labels.Items.Add(6.8, " ")).Font.Color = color;
(tChart1.Axes.Left.Labels.Items.Add(7.5, " ")).Font.Color = color;
(tChart1.Axes.Left.Labels.Items.Add(8.5, "90000")).Font.Color = color;
(tChart1.Axes.Left.Labels.Items.Add(10, "99000")).Font.Color = color;
}
Hope this helps!
Re: How to draw non-linear custom weibull scale?
Posted: Mon Sep 07, 2009 7:03 am
by 8119814
Hello,
Thanks. It works.
Cheers
Re: How to draw non-linear custom weibull scale?
Posted: Mon Sep 07, 2009 9:43 am
by narcis
Hi Gleen,
You're welcome. I'm glad to hear that.
Also, an alternative solution could be using a dummy series for plotting the Weibull scale. This series should have a point for each grid line/label in the axis, axis labels should be set to text format and points in that series should be transparent.
Re: How to draw non-linear custom weibull scale?
Posted: Mon Sep 07, 2009 11:52 am
by 8119814
Hello,
We are using T-Chart version 1 for .NET. Our chosen language is Managed C++. The above approaches you suggest work for the new versions of T-Chart only. Any suggestions on how all this can be achieved in T-Chart Version 1 for .NET with managed C++?
Cheers
Re: How to draw non-linear custom weibull scale?
Posted: Mon Sep 07, 2009 11:58 am
by narcis
Hello Glenn,
I have check that this works using last TeeChart for .NET v1 release available with managed C# and I wouldn't expect any problem with managed C++. Are you having any specific problem porting the code to C++?
Re: How to draw non-linear custom weibull scale?
Posted: Mon Sep 07, 2009 12:40 pm
by 8119814
Hello,
The following line doesn't work in Managed C++ with T-Chart .NET version 1:-
(tChart1.Axes.Left.Labels.Items.Add(1, "10000")).Font.Color = color;
Labels doesn't have any member called "Items" is the error.
How do we put custom labels on the left axis?
Thanks for your quick responses.
Cheers
Re: How to draw non-linear custom weibull scale?
Posted: Mon Sep 07, 2009 1:17 pm
by narcis
Hello Glenn,
Code below works fine for me here in a Visual C++ WinForms project using latest TeeChart for .NET v1 release available. Does this work fine for you?
Code: Select all
private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) {
tChart1->Aspect->View3D = false;
tChart1->Axes->Bottom->Logarithmic = true;
tChart1->Axes->Bottom->SetMinMax(10000, 1000000);
tChart1->Axes->Bottom->MinorTickCount = 8;
tChart1->Axes->Bottom->MinorGrid->Visible = true;
tChart1->Axes->Bottom->MinorGrid->Style = System::Drawing::Drawing2D::DashStyle::Solid;
tChart1->Axes->Bottom->Grid->Style = System::Drawing::Drawing2D::DashStyle::Solid;
tChart1->Axes->Bottom->Grid->Color = Color::Red;
tChart1->Axes->Bottom->Labels->Font->Color = Color::Red;
tChart1->Axes->Left->SetMinMax(1, 10);
tChart1->Axes->Left->MinorTicks->Visible = false;
tChart1->Axes->Left->Grid->Style = System::Drawing::Drawing2D::DashStyle::Solid;
Steema::TeeChart::Styles::Line ^ line1 = gcnew Steema::TeeChart::Styles::Line(tChart1->Chart);
line1->Pointer->Visible = true;
for (int i = 0; i < 10; i++)
{
line1->Add(10000 * i, i);
}
//add custom Weibull labels
AddWeibullLabels(Color::Red);
}
private: System::Void AddWeibullLabels(Color color) {
tChart1->Axes->Left->Labels->Items->Clear();
(tChart1->Axes->Left->Labels->Items->Add(1, "10000"))->Font->Color = color;
(tChart1->Axes->Left->Labels->Items->Add(2.8, " "))->Font->Color = color;
(tChart1->Axes->Left->Labels->Items->Add(3.9, " "))->Font->Color = color;
(tChart1->Axes->Left->Labels->Items->Add(4.75, " "))->Font->Color = color;
(tChart1->Axes->Left->Labels->Items->Add(5.5, "50000"))->Font->Color = color;
(tChart1->Axes->Left->Labels->Items->Add(6.2, " "))->Font->Color = color;
(tChart1->Axes->Left->Labels->Items->Add(6.8, " "))->Font->Color = color;
(tChart1->Axes->Left->Labels->Items->Add(7.5, " "))->Font->Color = color;
(tChart1->Axes->Left->Labels->Items->Add(8.5, "90000"))->Font->Color = color;
(tChart1->Axes->Left->Labels->Items->Add(10, "99000"))->Font->Color = color;
}
Thanks in advance.
Re: How to draw non-linear custom weibull scale?
Posted: Mon Sep 07, 2009 1:31 pm
by narcis
Hello Glenn,
Also, if the kind of project I described is not the same as yours please attach a simple example project we can run "as-is" to reproduce the problem here.
Thanks in advance.
Re: How to draw non-linear custom weibull scale?
Posted: Tue Sep 08, 2009 3:53 am
by 8119814
Hello,
We are using TeeChart.NET Version 1, Build 1.0.1189.31308. The language supported there is Managed C++. The example you show above is in C++/CLI. Could you please show us an example that would work with TeeChart.NET Version 1, Build 1.0.1189.31308.
Please find the sample project attached
. It is a Visual C++, .NET WinForms project using VS 2003.
Thanks for the alacrity.
Re: How to draw non-linear custom weibull scale?
Posted: Tue Sep 08, 2009 7:58 am
by narcis
Hi Glenn,
Thanks for the project.
First of all please notice there's a newer build of TeeChart for .NET v1 build available at the client download area.
Having said that, I couldn't open your project with VS2003 as I got this error message:
Project 'C:\temp\WeibullTry\WeibullTry.vcproj' failed to open.
Anyway, I could open it in VS2003 and with the last TeeChart or .NET v1 release available I got it working implementing
AddWeibullLabels method like this:
Code: Select all
private: void AddWeibullLabels(Color color)
{
tChart1->Axes->Left->Labels->Items->Clear();
(tChart1->Axes->Left->Labels->Items->Add(1, "10000"))->Font->Color = color;
(tChart1->Axes->Left->Labels->Items->Add(2.8, " "))->Font->Color = color;
(tChart1->Axes->Left->Labels->Items->Add(3.9, " "))->Font->Color = color;
(tChart1->Axes->Left->Labels->Items->Add(4.75, " "))->Font->Color = color;
(tChart1->Axes->Left->Labels->Items->Add(5.5, "50000"))->Font->Color = color;
(tChart1->Axes->Left->Labels->Items->Add(6.2, " "))->Font->Color = color;
(tChart1->Axes->Left->Labels->Items->Add(6.8, " "))->Font->Color = color;
(tChart1->Axes->Left->Labels->Items->Add(7.5, " "))->Font->Color = color;
(tChart1->Axes->Left->Labels->Items->Add(8.5, "90000"))->Font->Color = color;
(tChart1->Axes->Left->Labels->Items->Add(10, "99000"))->Font->Color = color;
}
Can you please check if this works fine for you?
Re: How to draw non-linear custom weibull scale?
Posted: Tue Sep 08, 2009 10:48 am
by 8119814
Hello,
Thanks a lot for your responses. As you suggested, I downloaded and used the last build for .Net Version 1 and the code just works fine.
Cheers