I want to used this method in core plot 1.0 but that method now work with core plot 1.0 so what will be alternative for this ?
CPTXYAxis *y = axisSet.yAxis;
**//this all method are not work**
y.majorGridLineStyle = majorGridLineStyle;
y.minorGridLineStyle = minorGridLineStyle;
y.visibleRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromFloat(0.0f) length:CPTDecimalFromFloat(100.0f)];
CPTConstraints yConstraints = {CPTConstraintFixed, CPTConstraintFixed};
y.isFloatingAxis=YES;
y.constraints=yConstraints;
i want to try this Example but that give me error Example link
The way constraints are handled changed. See the announcement on the Core Plot discussion board.
Here's a summary of the change:
CPTConstraints allows two basic types of constraint. Note that when
used for floating axis positioning, the axis doesn't clip the
constrained position to the visible area so it is possible to use an
offset that will push the floating axis outside the visible area.
Fixed offset from either the lower or upper bound of the range.
Note that for axes, this range is in view coordinates, so the lower
bound is to the left for a horizontal axis and at the bottom for a
vertical axis. The offset is towards the middle of the range, so a
positive offset from the lower bound goes in the positive direction
but a positive offset from the upper bound goes in a negative
direction.
Relative offset. This is used to maintain a position that is a
certain fraction of the range—0.0 is the lower bound, 1.0 is the
upper bound, and 0.5 is the middle. It is not restricted to these
values; any CGFloat value can be used.
CPTConstraints is immutable, so you have to create a new object
whenever you want to change the constraints.
Related
GestureDetector(
onVerticalDragUpdate: (details) {
var dy = details.delta.dy;
var primaryDy = details.primaryDelta;
},
)
I couldn't find out the difference between a regular delta and a primary, both seems to do the same job. Can anyone explain the difference between these two deltas? (As usual Docs are not very clear, at least to me)
DragUpdateDetailsclass:
delta → Offset The amount the pointer has moved in the coordinate
space of the event receiver since the previous update
Meaning, The distance covered by dragging since the last pointer contact. Delta gives dx for horizontal distance and dy for vertical distance.
primaryDelta → double The amount the pointer has moved along the
primary axis in the coordinate space of the event receiver since the
previous update
primaryDelta gives the absolute distance in only one primary direction of dragging, meaning if the drag is primarily in horizontal axis(GestureDragUpdateCallback + Horizontal only) then this value represents the drag distance in the horizontal axis. If the drag in is vertical axis (GestureDragUpdateCallback + Vertical only) then this value represents the drag amount in the vertical axis.
Note: if the GestureDragUpdateCallback is for a two-dimensional drag (e.g., a pan), then this value is null.
I'm trying to plot some annotations to go along with my step function graphs. I currently have these graphs, and I've been trying to figure out how to draw horizontal arrows that point towards vertical lines. I will also need labeled, vertical lines that are pointing towards horizontal lines.
I have attached an image that shows (in red) what I mean. I've tried the annotation() function, but it's truly a pain to get the arrows where I want them to be. If anyone wouldn't mind explaining how to use that function, or alternative methods for what I'm trying to achieve, that would be amazing!
EDIT: Is there a way to edit the Quiver arrowhead size?
Using Quiver in a 2D Subplot
Not quite sure if this is any better or simpler but I used the quiver() function to plot the lines shown below. The quiver() function takes in a few inputs in this case. In the full script below I used twice the amount of quiver() calls to plot overlapping arrows to create a double headed arrow.
Function Call:
quiver(Start_Point(1),Start_Point(2),X_Displacement,Y_Displacement,0);
• Start_Point → equal to [x y] (x-coordinate y-coordinate)
• Start_Point(1) → The x-coordinate of the arrow's start
• Start_Point(2) → The y-coordinate of the arrow's start
• X_Displacement → The horizontal distance from the start of the array
• Y_Displacement → The vertical distance from the start of the array
Setting the Maximum Size of the Arrow Head:
The maximum size of the arrow head can be set by using the 'MaxHeadSize' property.
clf;
Start_Point(1) = 0;
Start_Point(2) = 0;
X_Displacement = 0; Y_Displacement = 10;
Magnitude = sqrt(X_Displacement.^2 + Y_Displacement.^2);
quiver(Start_Point(1),Start_Point(2),X_Displacement,Y_Displacement,0,'Color','r','MaxHeadSize',1/Magnitude);
hold on
Start_Point(1) = 0;
Start_Point(2) = 0;
X_Displacement = 100; Y_Displacement = 0;
Magnitude = sqrt(X_Displacement.^2 + Y_Displacement.^2);
quiver(Start_Point(1),Start_Point(2),X_Displacement,Y_Displacement,0,'Color','r','MaxHeadSize',1/Magnitude);
Consider the simple code below that generates a straight downward sloping line in MATLAB.
clear, clc, close all
t = 0:0.1:1;
y = -t+1;
plot(t,y)
ax = gca
This is a line with slope -1, so the (acute) angle between the horizontal axis and the line is 45 degrees. Except it isn't when you measure with a protractor on your monitor.
Without changing the range of values displayed on the x and y axes or the height of the figure window, how could I ensure I would measure 45 degrees from the horizontal axis to the line if I held a protractor up to the screen?
My current approach is to change the width of the figure window. In the limit as the figure window is infinitely thin, the line x is a vertical line. Conversely, if the figure window is stretched to the edges of a monitor, it flattens out. Somewhere in the middle, the line has the angle I want. I just can't find a good way to mathematically find this point and instantiate it in code.
Edit: A slightly more generic solution for any acute angle. (I didn't test obtuse angles.)
clear, clc, close all
ang_deg = 70;
slope = tand(ang_deg);
t = 0:0.1:1;
y = -slope*t+1;
f = figure;
f.Position(3) = f.Position(3)*1.5;
plot(t,y)
% For a given height, change the width
ax = gca;
ax.Units = 'pixels';
ax.Position(3) = ax.Position(4)/slope;
You can achieve that with
axis equal
which, according to the documentation,
uses the same length for the data units along each axis.
You may want to also use
axis tight
which
fits the axes box tightly around the data by setting the axis limits equal to the range of the data
Follow up your commands with a declaration that you'll be working in pixels, and then set the width to the height:
ax.Units = 'pixels';
ax.Position(3) = ax.Position(4);
This is the code for plotting I am using
figure
x = -pi:pi/40:pi;
plot(x,cos(5*x),'-ro',x,sin(5*x),'-.b')
hleg1 = legend('cos_x','sin_x');
The output comes like this:
When I try to stretch the time axis, what I get is like this:
But as can be seen, the amplitude gets clipped when I stretch the time axis. How do I avoid this clipping of amplitude when stretching time axis and v.V?
You can try using "Zoom In," the plus-magnifying glass icon and being very careful to select the entire vertical range of the image. To control the minimum and maximum values of the axes more precisely using the axis function.
figure
x = -pi:pi/40:pi;
plot(x,cos(5*x),'-ro',x,sin(5*x),'-.b')
hleg1 = legend('cos_x','sin_x');
axis([1.6, 3.2,-1, 1])
iPhone sdk: Core-plot How to display y Axis on the right side on??
I am now using Core-plot in iphone sdk ,
This is what i have done so far
but i want to put the Yaxis in right hand side.
i have enable the allowsuserInteractive
**plotSpace.allowsUserInteraction=NO;
volumePlotSpace.allowsUserInteraction=YES;**
But i want X axis and Y axis always stay the right hand side and bottom,
Whatever user scale big or small....
like this:
Which version of Core-Plot are you using?
Core-Plot 0.9 allows you to set constraints on axes positions. A code line like this should do the job:
// 'graph' is your CPTXYGraph object
CPTXYAxisSet *axisSet = (CPTXYAxisSet *)graph.axisSet;
// move axis to the rightmost position
axisSet.yAxis.axisConstraints = [CPTConstraints constraintWithUpperOffset:0];
// put ticks on the right hand side of the axis
axisSet.yAxis.tickDirection = CPTSignPositive;
// add some padding to the right so that labels are actually visible
graph.plotAreaFrame.paddingRight = 20.0f;
I'm not aware in which version this was introduced, but at least for Core-Plot 0.2.2 the procedure was a bit different. I don't have it on my box now so I can't check, but this is how to fix Y axis on the left hand side:
CPTXYAxisSet *axisSet = (CPTXYAxisSet *)graph.axisSet;
axisSet.yAxis.isFloatingAxis = YES;
// fixed lower constraint, no upper constraint
CPConstraints yConstraints = {CPConstraintFixed, CPConstraintNone};
axisSet.yAxis.constraints = yConstraints;
I guess that for right hand side yConstraints should be {CPConstraintNone, CPConstraintFixed}.
In coreplot 1.5.1 , you can use CPTConstraints to set the Y axis on left or right, OR , set the X axis on bottom or top
yAxis.axisConstraints = CPTConstraints(lowerOffset: CGFloat(0.0))
lowerOffset means left(Y axis) or bottom(X axis);
upperOffset means right(Y axis) or top(X axis)