Setting axis line in core plot in ios - ios

I am plotting a bar graph using core plot for both positive and negative values.I want a line at x=0 seperating the positive and negative values .Can anyone tell me how to set the axis line
thanks

You need to set the orthogonalCoordinateDecimal property of the axes. So for example:
yAxis.orthogonalCoordinateDecimal = CPTDecimalFromDouble(0);
will make 0 the point of the yAxis where the yAxis crosses the xAxis.

In addition to using the orthogonalCoordinateDecimal as #pe60t0 mentioned, set the plot range of the y-axis so it covers both positive and negative values. For example to make the y-axis span from -10 to 10,
plotSpace.yRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromDouble(-10.0)
length:CPTDecimalFromDouble(20.0)];

Related

my vertical x axis labels run into my plotted data. Is there a way to compress the graph so I have a little extra room at the bottom

I am plotting my x axis labels vertically, and using the following line to provide a little space under the axis
axisSet.xAxis.axisConstraints = [CPTConstraints constraintWithLowerOffset:40.0];
But now the vertical length of the label bumps into the first value on the y axis. Is there a way to compress the graph a little so the first value on the y axis begins a little higher? Thanks.
Adjust the axis' labelAlignment and/or labelOffset to reposition the labels.

Margin for scatter series in Shinobi Charts on iOS

I'm using a scatter series in Shinobi Charts but points with maximum and minimum x and y values are being truncated because they're at the edge of the plot area?
How can I add a small margin to the plot area so I can clearly see the scatter points and none are truncated. I realise that I can set the range of each axis myself but that gets into nasty math to work out what a 5px margin would be over the lowest/highest values etc.
There are 2 properties on SChartAxis which can help you: rangePaddingLow and rangePaddingHigh. These values are absolute values, and in the scale of the axis.
For example, if you have an axis which has an automatic range of (0,100), then the following would update the range to (-5, 105):
axis.rangePaddingLow = #5;
axis.rangePaddingHight = #5;
As the axis scale updates, these padding values will be maintained.

CorePlot YAxis with two types of Scaling

Is it possible to achieve different scaling for positive part of Y-axis and different scaling for its negative part of Y-axis.The idea is to show most part of plot area for positive values and less part for negative values.
Set the yRange of the plot space so that 20% of the range is negative. For example, a range with a location of -25 and length of 125 meets this requirement.

Core Plot - X-Axis moving position when plotting less points

I have a strange problem where my x-axis moves down the plot area when I'm plotting less points. My graph has 2 lines plotted - 1 for previous year and 1 for current year values. My original graph always plotted 12 points for both lines, regardless of which month we are in and this works fine. I have now changed my app so that the current year line only plots points upto the current month. E.g. we are in May so I only plot 5 points. When I do this the x-axis moves down the plot area so that it is detached from the y-axis and the labels are hidden - see screenshots :
Why would simply reducing the number of plot points change the x-axis position? I'm using Core Plot 1.1 (static library) and Xcode 4.6.2.
The yRange of the plot space changed so the point where the x-axis crosses the y-axis is now too close to the bottom edge of the graph. You have two options:
Ensure the yRange always puts the crossing point (the "orthogonal coordinate") far enough from the edge that the labels and title remain visible.
Use the axisConstraints to position the axis a fixed distance from the edge of the graph. This will let the crossing point float along the y-axis.
The plotting library changes the x-axis position because generally core plot take the minimum and maximum range among the values of y axis. You when you provide only 5 points then the lowest value is taken from y axis values and there for x- axis position while when you were providing all 12 months values the lowest value of the rest of the month were 0 and therefore x-axis was at zero. You can change the maximum and minimum values for the y range in core plot.

Put a line on zero value of y axis

Helo,
Is it possible to put a line on zero value of y axis ?
Because i have negatives values so i changed orthogonal value of my axis to the lowest one on my datasource.
Thanks
Make second x-axis and position it at zero. You can leave off the labels and tick marks to just get the axis line. See the axis demo in the Plot Gallery app for an example of how to add additional axes to a Core Plot graph.

Resources