python - matplotlib: get axis ratio of plot -


i need produce scatter plots several 2d data sets automatically.

by default aspect ratio set ax.set_aspect(aspect='equal'), of times works because x,y values distributed more or less in squared region.

sometimes though, encounter data set that, when plotted equal ratio, looks this:

enter image description here

i.e.: narrow in given axis. above image, axis approximately 1:8.

in such case, aspect ratio of ax.set_aspect(aspect='auto') result in better plot:

enter image description here

now, don't want set aspect='auto' default data sets because using aspect='equal' correct way of displaying such scatter plot.

i need fall using ax.set_aspect(aspect='auto') only cases such 1 above.

the question: there way know before hand if aspect ratio of plot narrow if aspect='equal' used? getting actual aspect ratio of plotted data set.

this way, based on such number, can adjust aspect ratio more sane looking (i.e.: auto or other aspect ratio) instead of 'equal'.

something ought do,

aspect = (max(x) - min(x)) / (max(y) - min(y)) 

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -