python - Matplotlib Scatterplot Marker Size proportional to axis value - why is the number of pixels for the x and y axis different for aspect='equal'? -


my question far see closely related this post.

i need plot data marker size strictly proportional value of axes. (already asked question here).

my approach following:

  • create empty scatterplot pixel reference
  • scatter 2 points on lower left , upper right corner
  • limit axes these 2 points
  • use transdata.transform pixel values of 2 points
  • get pixel distance difference in pixel number of these 2 points
  • (now have distance-to-pixel-ratio, scatter data s=(size*dist_to_pix_ratio)**2; not important right now.)

problem is: when i've described, 2 different values pixel number y-axis , x-axis.

here minimal code:

import matplotlib.pyplot plt  fig = plt.figure(figsize=(7,7)) ax1 = fig.add_subplot(111, aspect='equal')  #setting empty scatterplot pixel reference xedges=[0.0, 1.0] yedges=[0.0, 1.0] emptyscatter=ax1.scatter(xedges, yedges, s=0.0)  #set axes limits ax1.set_xlim(0.00,1.00) ax1.set_ylim(0.00,1.00)      # calculating ratio of pixel-to-unit upright = ax1.transdata.transform((1.0,1.0)) lowleft = ax1.transdata.transform((0.0,0.0)) x_to_pix_ratio = upright[0] - lowleft[0] y_to_pix_ratio = upright[1] - lowleft[1]  print x_to_pix_ratio, y_to_pix_ratio 

which returns:

434.0 448.0 

can explain why not equal?

i'm not sure if it's relevant, i'm using python 2.7.12 , matplotlib 1.5.1


Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -