当轴比例不同时绘制垂直线

时间:2019-03-28 14:46:31

标签: math graph geometry line stata

考虑以下玩具示例:

clear
set seed 1234567890
set obs 500

generate v1 = rnormal(434.80132, 237.89369)
generate v2 = rnormal(0.08, 0.04)
generate y1 = 10000 * v2

twoway scatter v1 v2 || line y1 v2

enter image description here

我想找到一条垂直于以上那条线的线并绘制一条线。

基本数学告诉我们,如果方程式为y = m * x的直线的斜率为m,则另一条直线的斜率为m的负倒数:

generate y2 = -(1 / 10000) * v2
twoway scatter v1 v2 || line y1 v2 || line y2 v2

enter image description here

很明显,这里不是这种情况,问题似乎是双重的:

  1. 图形的长宽比
  2. 不同刻度的轴

如何以编程方式将这两者集成到我的解决方案中?

请注意,此图的y-xis4英寸,而x-axis5.5英寸(因此长宽比为5.5 / 4 = 1.375)。

我已经咨询了许多帖子,例如:

但是,我还没有一个可行的解决方案。


编辑:

以下是上面代码生成的数据:

v1           v2        y1        y2
269.39346    .1296253  1296.253  -.00001296253
 296.7234   .10551854 1055.1854 -.000010551854
-26.31669   .10365818 1036.5818 -.000010365818
 657.1838    .1518674  1518.674  -.00001518674
 252.1337   .11415068 1141.5068 -.000011415068
524.65295   .08042029  804.2029  -8.042029e-06
302.86755   .04647604  464.7604  -4.647604e-06
 419.6649   .10652875 1065.2875 -.000010652875
 920.3746   .12058274 1205.8274 -.000012058274
382.45035   .11835476 1183.5476 -.000011835476
 563.7043   .05736395 573.63947  -5.736395e-06
  714.242  .028945755 289.45755 -2.8945756e-06
511.74585   .07873922  787.3922  -7.873922e-06
 305.3213   .12720083 1272.0083 -.000012720083
 485.2742   .04365303  436.5303 -4.3653026e-06
143.06741   .09216157  921.6157  -9.216156e-06
 187.2168   .13030003 1303.0002 -.000013030003
 612.5165    .1331835  1331.835  -.00001331835
 361.2785   .08907203  890.7203  -8.907204e-06
 360.4551   .06243951  624.3951  -6.243951e-06
296.04575   .10163532 1016.3532 -.000010163532
569.25415   .09742134  974.2134  -9.742134e-06
 637.6291   .09733213  973.3213  -9.733213e-06
 560.2654   .21330532 2133.0532  -.00002133053
 448.2809   .14670238 1467.0238 -.000014670238
 683.3372    .1697338 1697.3383 -.000016973383
 523.0644 -.004095574 -40.95574   4.095574e-07
 411.0599  .030772524 307.72525 -3.0772524e-06
 441.5038   .06584484  658.4484  -6.584484e-06
  336.168    .0958923   958.923   -9.58923e-06
 198.6761   .08582716  858.2715  -8.582716e-06
246.97536     .152105   1521.05   -.0000152105
 460.7311   .09324597  932.4597  -9.324597e-06
 287.2187  .021772934 217.72934 -2.1772935e-06
 38.66368  .036870584  368.7058  -3.687058e-06
 500.0821   .14235458 1423.5458 -.000014235457
 352.3894   .07493528  749.3528  -7.493528e-06
 811.4477   .04826602  482.6602  -4.826602e-06
 679.0712   .06238959  623.8959  -6.238959e-06
301.30457   .09074442  907.4442 -9.0744425e-06
 757.7222   .05119324  511.9324  -5.119325e-06
  570.274   .10332661 1033.2661  -.00001033266
590.91846   .10045127 1004.5127 -.000010045127
 620.4365   .14892302 1489.2302 -.000014892303
130.16528   .08897128  889.7128  -8.897128e-06
 336.9956    .1393297  1393.297  -.00001393297
 839.7582    .0996195   996.195   -9.96195e-06
 390.4998    .0865124   865.124  -8.651239e-06
 326.7999  .033503372  335.0337  -3.350337e-06
 350.7236   .05849207  584.9207  -5.849207e-06
 625.7621   .13081506 1308.1506 -.000013081506
 661.3865   .10882486 1088.2485 -.000010882486
 772.1646   .05676838  567.6838  -5.676838e-06
288.92468   .04983922  498.3922  -4.983922e-06
 452.0564   .08711468  871.1469  -8.711469e-06
119.64562   .14033437 1403.3436 -.000014033437
540.64465   .01785021  178.5021  -1.785021e-06
 486.0001    .0352254   352.254   -3.52254e-06
 313.4424  .069143936  691.4393  -6.914393e-06
 664.7051   .05293872  529.3872  -5.293872e-06
 331.3703   .06169248  616.9249  -6.169249e-06
-62.07745   .06645174  664.5175  -6.645174e-06
  993.134   .07217993  721.7993  -7.217993e-06
601.41437   .07325878  732.5878  -7.325878e-06
 567.1587   .13941422 1394.1422 -.000013941422
118.95367   .05569748  556.9748  -5.569748e-06
 437.1982   .05619644 561.96436  -5.619644e-06
283.20987   .04376043  437.6043  -4.376043e-06
  362.279    .1073577 1073.5769  -.00001073577
173.81154   .08425744  842.5744 -8.4257435e-06
 365.7731   .06203346  620.3346  -6.203346e-06
 695.8716   .08280326  828.0327  -8.280326e-06
 105.1409   .08470224  847.0224  -8.470224e-06
 438.4622   .06138157  613.8157  -6.138157e-06
  704.993   .05607803  560.7803  -5.607803e-06
 11.55953    .1063125 1063.1249  -.00001063125
520.18304   .15763256 1576.3256 -.000015763257
 685.0488    .1517116  1517.116 -.000015171158
  645.567   .04092862  409.2862  -4.092862e-06
  361.465   .07043068  704.3068  -7.043068e-06
1050.0239    .1012046 1012.0459  -.00001012046
 99.06884   .06545984  654.5984  -6.545984e-06
 699.0544   .09549447  954.9447  -9.549447e-06
 547.5491   .11651776 1165.1776 -.000011651776
 367.7509   .07570159  757.0159  -7.570159e-06
554.36414   .06114044  611.4044  -6.114044e-06
 174.2912   .05117374  511.7374  -5.117374e-06
 615.7756  .022821637 228.21637  -2.282164e-06
 678.1454    .1108198  1108.198  -.00001108198
522.73535   .07071783  707.1783  -7.071783e-06
 411.2797   .04971372  497.1372  -4.971372e-06
 308.1041   .05743588 574.35876  -5.743588e-06
-375.5049   .05214334  521.4334  -5.214334e-06
  40.3021   .16943806 1694.3806 -.000016943806
578.10266   .04062266  406.2266 -4.0622663e-06
 198.2699  .035349682  353.4968  -3.534968e-06
 254.9718   .00995418  99.54179   -9.95418e-07
 538.3042   .04819309  481.9309  -4.819309e-06
 608.1482   .10872427 1087.2428 -.000010872427
 40.12729   .04191337  419.1337 -4.1913368e-06

1 个答案:

答案 0 :(得分:1)

一条线的视觉斜率就是:

slope = m * height * domain / (width * range)

此处 width height 是图的物理尺寸(您用5.5”说过4”,而 domain < / em>和 range 是它覆盖的 x y 值的范围(此处约为0.225和{{1} }。

调用 m 系数(在这种情况下,大约为2300 v (用于视觉),我们知道:

7.1e-5

在您的示例中,这大约等于slope2 = -1 / slope1 m2 * v * m1 * v = -1 m2 = -1 / (m1 * v^2)