Core-Plot X-Axis Label Position Offset - core-plot

I'm trying to shift the x-axis labels upwards. Is there a property that I can set to do that? I've tried adding some bottom padding to the plot frame, but all that does is to squeeze the entire plot upwards.

Another question answered on Stack Overflow led me to change 'orthogonalCoordinateDecimal'. For instance:
axisSet.xAxis.orthogonalCoordinateDecimal = CPTDecimalFromString(#"0")
This caused my X-axis to pass through the origin. To raise my X-axis in relation to my graph, I changed the value to '25000', as in:
axisSet.xAxis.orthogonalCoordinateDecimal = CPTDecimalFromString(#"25000")
On thing to be mindful of is scale. My values in this case ranged from 0 - 185,000 so a shift of 25,000 is approximately equivalent to a shift of 4 when the upper value of the axis is 30 (days in my case, just for example). I was originally trying to shift the 0-185,000 axis by 5.0, and wondering why it had no effect, thinking it was a measurement of screen real estate instead of a scaled value.

The property your looking for is axisSet.xAxis.labelOffset

It is not totally clear, may be you need this
x.axisConstraints = [CPTConstraints constraintWithLowerOffset:0.0];
Or to display labels above axis you can use this:
x.tickDirection = CPTSignPositive;

Related

Highchart - Chart type, gap in the x and y axis (0,0)

Please refer the fiddle codehttp://jsfiddle.net/yuvarajkumarg/az290eyq/1/
In Highchart of type Chart, when we plot for height = 0 and pressure = 2, we get a gap as shown in jsfiddle. I want point to be plotted on the X-axis(2,0). But the graph looks like it is plotted on (2,2) since the y-axis plot starts way above the x-axis. How to remove the gap ?
The issue is the categorized axis.
There are probably a few ways around the issue, but I would do it this way (on your xAxis):
tickmarkPlacement: 'on',
min:0.5,
max:6.5
Example:
http://jsfiddle.net/az290eyq/2/
You could also do it by not using categories, and using the axis label formatter in order to display the numeric sequence that you need.
[[ edit for comments:
For the min and max values - the x axis values for a categorized axis are the category array index values. So the first category is x = 0, the second is x = 1, etc.
Because Highcharts puts the the label in the center of the value's space, setting the min/max to the actual min/max value +/- 0.5 will align the center of the space with the start/end of the axis.
So, you can calculate this dynamically by using 0.5 for the min, and counting the categories array and using (count -1.5) as the max.
Additionally, setting the tickmarkPlacement proerty to 'on' moves the tick mark to the center of the space as well, aligning the ticks with the start/end of the axis as well.

coreplot Xaxis start value iOS 7

I am developing an Area chart like the following and facing the following issue.
curve shape is not looking proper, i need a smooth curve.
X-axis values are Dynamic, it May start with 40 or May be 60 or
any other value.how to calculate that ?
Any Help will be greatly Appreciated.
To make the line smoother, either give it more data points or make a curved plot.
plot.interpolation = CPTScatterPlotInterpolationCurved;
If you know the range of data values, just set the xRange directly. Remember to set the location to the min value and the length to (max - min). You can also have the graph scale the plot space for you.
[plotSpace scaleToFitPlots:[graph allPlots]];

How to set a fixed position to the x-axis in core-plot

In my application I have a core-plot graph. The labels of the x-axis display in the graph area. This is a capture:
I don't know what is wrong. I'm using expandRangeByFactor for yRange with this code
[yRange expandRangeByFactor:CPTDecimalFromCGFloat(2.1f)];
But the problem is that when the data changes, the x-axis labels move up or down. I don't understand this behavior.
Is possible to fix the x-axis labels to one position, always at the bottom of graph.
Thank you in advance.
It's hard to tell what's wrong without seeing your code, but you could try setting an axis constraint on the x axis:
CPTXYAxisSet *axisSet = (CPTXYAxisSet *)graph.axisSet;
axisSet.xAxis.axisConstraints = [CPTConstraints constraintWithLowerOffset:0.0];

How to determine/calculate where the Y axis tick marks are being plotted in CorePlot?

I'm working with CorePlot to generate a bar graph with horizontal bars (CPTXYGraph and CPTBarPlot).
There are only 10 bars being plotted at any given time, but the labels for them are arbitrarily long. As a result of that the Y axis labels rotation is set to 0.5. For the longest labels there are clipping issues with the label going outside of the left and/or bottom of the plot area.
I've fixed this in the X direction by determining the width of the longest label (as rendered in the appropriate font) and rotated the appropriate way to set the left padding in the plotAreaFrame.
Due to the rotation of the labels, if the plot at the bottom of the graph has a long name it can still extend off the bottom edge of the graph and get clipped there.
I know how tall vertically the rotated label is, but where I'm stuck is trying to determine where in the plot area the axis label is being plotted so that I can determine how much bottom padding is required.
I'm not sure if I should be trying to determine how tall the X axis label section is and then subdividing the remaining height to determine where the ticks should fall, or if there's some other better way to go about it.
The label is offset from end of the nearest tick mark by the labelOffset. The position of the end of the tick mark depends on the tickDirection, tickLabelDirection, and majorTickLength.
There are methods that allow you to convert a point from the plot space coordinate system to the view coordinate system. I've ended up solving the problem with code like the following:
// Tell the graph to lay itself out if it needs to.
[self.graph layoutIfNeeded];
// Create a point that represents 0,1 as plotted on the graph.
NSDecimal plotPoint[2];
plotPoint[CPTCoordinateX] = CPTDecimalFromInt (0);
plotPoint[CPTCoordinateY] = CPTDecimalFromInt (1);
// Convert that point from the plot coordinate system to the view coordinate system
CGPoint point = [self.graph.defaultPlotSpace plotAreaViewPointForPlotPoint: plotPoint];
// If the difference between the height of the rotated label and the position that it
// will be plotted at is at least the bottom padding, then the height is too large,
// so fix the padding.
if (labelHeight - point.y >= self.graph.plotAreaFrame.paddingBottom)
[self.graph.plotAreaFrame setPaddingBottom: (labelHeight - point.y)];
My graphs have a default bottom padding already set as a minimum, allowing this code to bump it up if there isn't enough already.

CorePlot axisLine and gridLine length too long

I'm using CorePlot for my current project and its amazing.
The only problem I came across is the length of the axis and grids.
I'm only using a positiv coordinate system with labels on the left and bottom side.
And my problem is the length of the axis and grids in direction to my labels.
I tried to use:
axisSet.xAxis.orthogonalCoordinateDecimal = CPTDecimalFromString(#"-value");
axisSet.yAxis.orthogonalCoordinateDecimal = CPTDecimalFromString(#"-value");
or
x.labelOffset = value;
y.labelOffset = value;
but this is only setting the distance of my labels different and not affecting the grids length.
In my example the y-axis and there grid overlaps my label:#{1,2,3,4,5,6,7,8}
Did somebody dealed with the same problem? THX for all answer to the right way!
Use the visibleRange and gridLinesRange to limit the axes and grid lines, respectively. See the "Control Chart" in the Plot Gallery example app for sample code.

Resources