ios - Scale scatter plot to Y-axis based on Circle radius using core plot -


i have scatter-plot plot circles. draws fine , scale depending on aspect ratio users device. circles can vary in size incredibly, want scale plotspace accordingly. problem when use

[graph.defaultplotspace scaletofitplots:graph.allplots]; 

the scaling done respect y-axis. perfect circles, since work aspect ratio, since portrait orientation, , scaling done respect y-axis, circles cut off in x-axis. since x-axis shorter in regard of aspect ratio i'd scale respect instead. possible?

what i'm trying achieve "zoom out" or "scale" plotspace circles fit in plotspace, can't seem figure out without breaking aspect ratio , getting stretches circles.

it looks this: enter image description here

and want this: enter image description here

edit:

code use scale:

[self.mgraph layoutifneeded]; [self.mgraph.defaultplotspace scaletofitplots:self.mgraph.allplots];  float width = self.mgraph.plotareaframe.bounds.size.width; float height = self.mgraph.plotareaframe.bounds.size.height;  float aspectratio = width / height;  cptmutableplotrange *xrange = [plotspace.xrange mutablecopy]; [xrange expandrangebyfactor:cptdecimalfromcgfloat(1.0f * aspectratio)]; plotspace.xrange = xrange; cptmutableplotrange *yrange = [plotspace.yrange mutablecopy]; [yrange expandrangebyfactor:cptdecimalfromcgfloat(1.0f)]; plotspace.yrange = yrange; 

you can compute aspect ratio of plot area size of plotarea layer. call -layoutifneeded on graph first make sure size up-to-date. use computed aspect ratio adjust plot ranges computed -scaletofitplots:.


after scaling, size of plot area , lengths of plot ranges:

cgsize pasize = self.mgraph.plotareaframe.plotarea.bounds.size; double xlen = plotspace.xrange.lengthdouble; double ylen = plotspace.yrange.lengthdouble; 

you want ratio xlen / ylen end same pasize.width / pasize.height. expand xrange or yrange factor greater 1 (1) make ratios equal.


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -