kakearney / plotboxpos-pkg

Return the position of the plotted region of a Matlab axis
MIT License
8 stars 1 forks source link

Ratio of limits (xlim, ylim) when these contain Inf values #2

Closed srkuberski closed 6 years ago

srkuberski commented 6 years ago

I have encountered an error when using plotboxpos on axes which limits contain Inf values but are set to manual limit mode. The so computed ratio limDarRatio (line 55) is NaN then and subsequent temporary axes creation fails because of NaN in pos array.

I think a NaN check and default value of 1 for the ratio helps out here.

Many thanks for the good work!

kakearney commented 6 years ago

Thanks for pointing this out. I added in some additional logic that I believe should cover all use of Inf/-Inf in axis limits (26271ba86c3b8da992422587aabc8cb3af182376). If you still encounter errors or incorrect output, please add a short example to this issue.

srkuberski commented 6 years ago

Good that you are aiming to address this issue in a more general way. But, your approach now fails when the axes contains other children than those which have an XData property (e.g., text objects). If you filter out any object not having the right properties, like

hc(~arrayfun( @( h ) isprop( h, 'XData' ) & isprop( h, 'YData' ), hc )) = [];

it works very fine.

kakearney commented 6 years ago

Yup, you're right. Added that line to the most recent version (96927f286818ba42216cd4cc975528ec35b58996).