I am very new in all this of programming and I am beginning with C#
now I have an application which should show some points in a chart, but i would like to fix the x and y axis in a way that the graph area always has as minimum 50 and maximum 50, but the graphic area doesn't auto-fit the graph, I don't know if I explain it well, I mean I want the points for x and y axis always display from 0 to 50. does some one know how to set this?
you can easily set limits like this:
chart1.ChartAreas[0].AxisX.Maximum = 50;
chart1.ChartAreas[0].AxisX.Minimum = 0;
chart1.ChartAreas[0].AxisY.Maximum = 50;
chart1.ChartAreas[0].AxisY.Minimum = 0;
Related
So I use an open source .NET library for plotting: FPlot
Here's the function that I'm trying to draw:
f(x,y) = x^2+3*y^2+2*x*y
Here's what I want it to look like:
Clarification:
I don't need the exact same appearence as in the image, I just need the plot to be mathematically correct
There are only 10 conours in the picture, I need as much as can be fit on the screen
Here's how I tried to do this:
var graphFunction = new Function2D();
graphFunction.source = "return (pow(x,2)+3*pow(y,2)+2*x*y)/10;";
/* I'm dividing by 10 because otherwise the whole plot is solid color */
graphFunction.Compile(true);
That's how the FPlot generated plot looks up close:
This is exactly what I want, but when I zoom out here's what happens:
Theese extra ellipses are not supposed to be there, in fact they are not there, this is just a graphical artefact, because when you zoom into one of theese 'fake' ellipses this is what you see:
The problem can be in this line:
graphFunction.source = "return (pow(x,2)+3*pow(y,2)+2*x*y)/10;";
...or in the FPlot source code. Any Ideas?
UPDATE:
So, z value in graph seems to be the problem. When value of a function, z = f(x,y) in a graph exceeds the z1 (max z) value it resets to z = z%z1 (same happens when z is lower then z0), which causes these "lines" - they are not countour lines, like I thought.
So that means the solution is: set z0 to min f(x,y) on screen, and set z1 to max f(x,y) on screen.
Make the displaying borders of your FPlotLibrary.GraphControl have the same value in all 3 dimensions and the problem goes away:
graphControl1.x0 = -40;
graphControl1.x1 = 40;
graphControl1.y0 = -40;
graphControl1.y1 = 40;
graphControl1.z0 = -40;
graphControl1.z1 = 40;
Btw, the "problem" reproduces, for instance, if you do
graphControl1.x0 = -40;
graphControl1.x1 = 40;
graphControl1.y0 = -40;
graphControl1.y1 = 40;
graphControl1.z0 = -1;
graphControl1.z1 = 1;
Can someone tell me how to change the min and max values on the x axis on a C# chart? I want to go from 0 to 13, but it goes from -1 to 14 right now.
If you are using System.Windows.Forms.DataVizualisation.Charting you can set the Axis range by manipulating the chart's ChartAreas property. So something like
myChart.ChartAreas[0].AxisX.Maximum = 13;
myChart.ChartAreas[0].AxisX.Minimum = 0;
This will work better :
myChart.ChartAreas[0].AxisX.IsMarginVisible = false;
You might try myChart.ChartAreas[0].AxisX.RoundAxisValues(). It is on by default for the Y axis and I find it generally works better for the X Axis as well.
New Chart().SetYAxis("GPA",0,4);
If You using The chart Class
you could set the Y or X axis using the SetYAxis Method
chart1.ChartAreas[0].AxisX.Minimum = 0;
chart1.ChartAreas[0].AxisX.Maximum = 10;
chart1.ChartAreas[0].AxisY.Minimum = -5;
chart1.ChartAreas[0].AxisY.Maximum = 5;
Im working on a polar chart with mschart, and I need to make this "hole" on the middle of the chart. I mean, i need the "0" of the Y axis not to be on the center. I saw this plot somewhere on stackoverflow. It´s exactly what i need, how can I do that?
In order to create a radar plot that look like the provided example
// disable grid a long X
chart1.ChartAreas[0].AxisX.MajorGrid.Enabled = false;
chart1.ChartAreas[0].AxisX.MajorTickMark.Enabled = false;
// set Y axis
chart1.ChartAreas[0].AxisY.Minimum = -20; // creates the 'hole' by setting min Y
chart1.ChartAreas[0].AxisY.MajorGrid.IntervalOffset = 20; // so the major grid does not fill the 'hole'
chart1.ChartAreas[0].AxisY.MajorGrid.Interval = 5;
chart1.ChartAreas[0].AxisY.MajorGrid.LineDashStyle = ChartDashStyle.Dash;
I need to stop autosizing (or autoscaling) of Y Axis in c# chart and set it manually.
Any advice? Thanks
You can set the minimum and maximum of the Y axis like so:
chart.ChartAreas[0].AxisY.Minimum = 0;
chart.ChartAreas[0].AxisY.Maximum = 10;
I'm trying to make chart in C# which should be readable easily. I managed to draw sin() graph, but it's not really readable, as X and Y axis don't stand out, I feel like it's the middle of nowhere. I tried to set line width using following code:
area.AxisX.LineWidth = 3;
But it only made line in the bottom of chart fatter, not main axis (Y = 0) like I need.
Anyone know how I would accomplish that? Is Y axis (X = 0) same? If no, could you please specify how to bold it too?
I think what you are looking for is the MajorGridLines:
area.AxisY.MajorGrid.LineWidth = 3
Or maybe this:
area.AxisX.LineWidth = 3;
area.AxisX.Crossing = 0;
area.AxisY.LineWidth = 3;
area.AxisY.Crossing = 0;
Crossing will put the axis at the value you set it to.