https://github.com/djw/core-plot/tree/9282845bddbb8c40ff314bbfa158beff797c91f7/examples
This states that the isFloatingAxis property has been removed from at least version 0.9.
Does anyone know how to float the x axis without this property? In other words, if I want the origin of the graph to be (0,6000) lets say, how can I maintain the x axis inside the plot range, while the y axis is NOT set to:
y.orthogonalCoordinateDecimal = CPTDecimalFromInt(0);
I was able to figure this out by looking in the CPTTestApp example from the CorePlot_0.9 folder. I looked in the class files and found this in Controller.m:
x.axisConstraints = [CPTConstraints constraintWithUpperOffset:132];
For now, this is holding my x axis in the same spot so I can change the orthogonalCoordinateDecimal to 6000 or whatever without the x axis and labels disappearing.
This code should help you. It sets the x-axis to range from 0-6000, and makes visible only that part on plot:
axisSet.xAxis.visibleRange =[CPTPlotRange plotRangeWithLocation:CPTDecimalFromInt(0) length:CPTDecimalFromInt(6000)];
axisSet.xAxis.gridLinesRange = axisSet.xAxis.visibleRange;
Related
I struggle a little bit with overlapping axis numbers of the y and x axis like it is shown in the image. I'd like to keep the size of the numbers and therefore think that simply shifting the numbers away from the axis itself would be an appropriate way to handle this issue.
Is there a possibility to do that?
Thanks in advance,
Joe
Here is a little workaround using text annotations. Basically you clear the current XTick labels and replace them with similar labels, but you can specify the distance from the axis:
clc
clear
close all
x = 1:20;
hPlot = plot(x,sin(x));
set(gca,'xaxisLocation','top');
set(gca,'XTickLabel',[]); %// Clear current XTickLabel
ylim = get(gca,'YLim'); %// Get y limit of the plot to place your text annotations.
for k = 2:2:20
text(k,ylim(2)+0.1,num2str(k),'HorizontalAlignment','Center') %// Play with the 'ylim(1) -0.1' to place the label as you wish.
end
Giving this:
Of course now it's exaggerated and you can do the same for the y axis if you want (using the 'XLim' property of the current axis,gca).
I got a LineChart which actually hold two axes. I really need to manipulate the bounds for xAxis and the ticking, however I can't get the axis as a NumberAxis, I just get it as an Axis for which I can't get the setLowerBound method, neither upperBound or tick settings....
How can I solve this?
As #uluk-biy points out, you can safely use an up-cast here, if the Axis was created as a NumericAxis:
NumericAxis numericAxis = (NumericAxis) axis;
I am implementing core plot framework for graph plot, but I am not able to understand following issues :
How to change the scaling point on XY axis. For example right now by deafault it is showing points on x axis is 1,2,3,4,5....etc and on y axis 1,2,3,4,5,....etc and I want on y axis 100,200,300,400,...etc.
How to set the coordinate of whole graph, means as I run my app the graph is totally downside and not visible and to see the graph I have to drag it upside.
Please help me out ASAP.
Thanks in advance.
You control the visible data using the xRange and yRange of the plot space. See this question for an example.
There are several options for setting up the labels, controlled by the labelingPolicy property. One of the pages in the Plot Gallery example app shows samples of all of the labeling policies. Which one you choose depends on how much you know about the range of data that will be displayed and whether the user can scroll and/or zoom the graph.
1) y_axis.majorIntervalLength = CPTDecimalFromString(100); // for 100 ,200 .....
2)
plotSpace = (CPTXYPlotSpace *)graph.defaultPlotSpace;
plotSpace.allowsUserInteraction = YES;
plotSpace.xRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromFloat(-0.99) length:CPTDecimalFromFloat(7.5)];
plotSpace.yRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromFloat(-4.9) length:CPTDecimalFromFloat(45)];
// you can visible directly graph... or you can set start location as 1st parameter and length as 2nd parameter
I just can't find it. How to set up axis and labels in matlab so they cross at zero point, with the labels just below the axis not on left/bottom of the plot ?
If I didn't make myself clear - I just want the plot to look like like we all used to draw it when in school. Axes crossing, 4 quadrants, labels right below axis, curve ... as it goes.
Anyone knows how to set it up ?
You should check out two submissions on The MathWorks File Exchange:
PlotAxisAtOrigin by Shanrong Zhang
axescenter by Matt Fig
Hopefully these will work with whatever MATLAB version you have (the submission from Matt Fig is the most recently updated one).
As of Matlab release R2015b, this can be achieved with the axis property XAxisLocation and YAxisLocation being set to origin.
In other words,
x = linspace(-5,5);
y = sin(x);
plot(x,y)
ax = gca;
ax.XAxisLocation = 'origin';
ax.YAxisLocation = 'origin';
Example is taken from MATLAB official documentation:
Display Axis Lines through Origin
Controlling Axis Location
Am new to coreplot framework, rite now am working in barchart model and got some idea bt now i want to do double sided barChart (i need y axis both left and right corner)
OtherWise i need to move this following range value for y coordinate when i move over the different x position on the graph....
plotSpace.globalYRange = [CPPlotRange plotRangeWithLocation:CPDecimalFromInteger(0) length:CPDecimalFromInteger(100)];
plotSpace.yRange =plotSpace.globalYRange;
Thanks in advance
You can add as many axes as you need. If you want both y-axes to have the same scale, you can use a single plot space. See the Mac version of CPTestApp for an example of adding a third axis to the graph.