def display_to_paper(x, y, layout):
 num_x = (x - layout['margin']['l'])
 den_x = (layout['width'] - (layout['margin']['l'] + layout['margin']['r']))
 num_y = (y - layout['margin']['b'])
 den_y = (layout['height'] - (layout['margin']['b'] + layout['margin']['t']))
 return ((num_x / den_x), (num_y / den_y))

def display_to_paper ( x , y , layout ) : num_x = ( x - layout [ 'margin' ] [ 'l' ] ) den_x = ( layout [ 'width' ] - ( layout [ 'margin' ] [ 'l' ] + layout [ 'margin' ] [ 'r' ] ) ) num_y = ( y - layout [ 'margin' ] [ 'b' ] ) den_y = ( layout [ 'height' ] - ( layout [ 'margin' ] [ 'b' ] + layout [ 'margin' ] [ 't' ] ) ) return ( ( num_x / den_x ) , ( num_y / den_y ) )
convert mpl display coordinates to plotly paper coordinates .