简体   繁体   中英

Core Plot: Change y-axis (Labels and Scale) to plot a new graph


I have one graph correctly plotted in my plotspace and I am trying to plot a second graph triggered by a segmented control button instead of the first one.
The x-axis (xRange and globalXRange) and their corresponding values between graph 1 and 2 are staying the same, just the corresponding y-axis (scale and labels) are changing. This requires a scale and label change on the y-axis...

For the first plot I already set:

// PLOT RANGE Y-Axis
    self.plotSpace.yRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromDouble(-1.2) length:CPTDecimalFromDouble(6.5)];
    self.plotSpace.globalYRange = self.plotSpace.yRange;

// Visibility of Y-Axis
    self.axisSet.yAxis.visibleRange   = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromInteger(0)
                                                                length:CPTDecimalFromInteger(5)];

This is working perfect.

When changing self.plotSpace.yRange and self.plotSpace.grobalYRange with new CPTPlotRanges ( I am doing this in the same way as above inside of my segment - if-else statement) , both: y-axis scales and labels are not changing as desired, wrt the new y-axis ranges (should be from 0 - 100 and not still from 0 - 5). Just the minorTicksPerInterval changes properly.

How to do that? BTW: I am not looking for 2 y-axis in the same plot. Any suggestions...

The globalYRange constrains the new values assigned to the yRange . Set globalYRange to nil before changing the yRange .

self.plotSpace.globalYRange = nil;
self.plotSpace.yRange = newRange;
self.plotSpace.globalYRange = self.plotSpace.yRange;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM