简体   繁体   中英

Adjust y-scale in 2D graph

I want to compare multiple graphs 2D graphs, but each graph has slightly different x-scale. So I want to modify the x-scale for all on say 1-8 units, so that they can be compared, eg

Graph 1:

X: -40.92   -50.35  -60.79  -70.23  -80.67  -90.11  -100.55 -110.00
Y: 85970    85000   85997   86131   86483   84968   85102   85825

Graph2:

X: -40.47   -50.91  -60.34  -70.78  -80.22  -90.66  -100.10 -110.55
Y: 430  481 552 585 644 5029    30256   38372

expected answer: X: 1 2 3 4 5 6 7 8 Y1: . . . . . . . . Y2: . . . . . . . .

Where X' is new scale common to both graphs and Y1 and Y2 are values of Y for graph 1 and graph 2.

You can plot your Y data against anything you want, so in your case, perhaps:

newX = range(1,len(Y)+1)
pylab.plot(newX, Y1)
pylab.plot(newX, Y2)

Of course, your Y values have quite different magnitudes, so you might need a second y-axis to see the data properly. And there are small differences between your X values: if these matter to you, perhaps some kind of interpolation would be useful.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM